[jbpm-commits] JBoss JBPM SVN: r3210 - in jbpm4/trunk/modules: task/src/main/java/org/jbpm/task/internal and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 4 20:28:25 EST 2008


Author: alex.guizar at jboss.com
Date: 2008-12-04 20:28:25 -0500 (Thu, 04 Dec 2008)
New Revision: 3210

Added:
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/UpdateTask.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleState.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/RoleImpl.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneDefinitionImpl.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneImpl.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskDefinitionImpl.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskExecution.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskDbSessionBinding.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskServiceBinding.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/descriptor/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java
Removed:
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/cmd/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/db/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/xml/
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskDbTest.java
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskTest.java
Modified:
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/TaskDefinition.java
   jbpm4/trunk/modules/task/src/main/resources/jbpm.task.hbm.xml
   jbpm4/trunk/modules/task/src/main/resources/jbpm.task.wire.bindings.xml
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java
   jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml
   jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
   jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
Log:
JBPM-1858 reorganized task module to match pvm packages
reviewed wire bindings and descriptions

Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/TaskDefinition.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/TaskDefinition.java	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/TaskDefinition.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -25,8 +25,8 @@
 
 import org.jbpm.model.ObservableElement;
 import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.task.impl.SwimlaneDefinitionImpl;
-import org.jbpm.task.impl.TaskDefinitionImpl;
+import org.jbpm.task.internal.model.SwimlaneDefinitionImpl;
+import org.jbpm.task.internal.model.TaskDefinitionImpl;
 
 /** design-time declaration of a task.
  * 

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java (from rev 3186, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/cmd/CreateTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.session.DbSession;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.model.TaskDefinitionImpl;
+import org.jbpm.task.internal.model.TaskImpl;
+import org.jbpm.task.session.TaskDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateTask implements Command<Task> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected String taskId;  
+  protected Long taskDefinitionDbid;
+  protected Long executionDbid;
+  
+  public CreateTask() {
+  }
+
+  public CreateTask(String taskId) {
+    this.taskId = taskId;
+  }
+
+  public CreateTask(String taskId, long taskDefinitionDbid) {
+    this.taskId = taskId;
+    this.taskDefinitionDbid = taskDefinitionDbid;
+  }
+
+  public CreateTask(String taskId, long taskDefinitionDbid, long executionDbid) {
+    this.taskId = taskId;
+    this.taskDefinitionDbid = taskDefinitionDbid;
+    this.executionDbid = executionDbid;
+  }
+
+  public Task execute(Environment environment) throws Exception {
+    TaskDefinitionImpl taskDefinition = null;
+    ExecutionImpl execution = null;
+
+    if (taskDefinitionDbid!=null) {
+      TaskDbSession dbSession = environment.get(TaskDbSession.class);
+      taskDefinition = dbSession.get(TaskDefinitionImpl.class, taskDefinitionDbid);
+    }
+
+    if (executionDbid!=null) {
+      DbSession dbSession = environment.get(DbSession.class);
+      execution = dbSession.get(ExecutionImpl.class, executionDbid);
+    }
+    
+    Task task = null;
+    if (taskDefinition==null) {
+      task = TaskImpl.create(taskId);
+    } else if (execution==null) {
+      task = TaskImpl.create(taskId, taskDefinition);
+    } else {
+      task = TaskImpl.create(taskId, taskDefinition, execution);
+    }
+    
+    return task;
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/cmd/DeleteTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.DbSession;
+import org.jbpm.task.internal.model.TaskImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteTask implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long taskDbid;
+  
+  public DeleteTask(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
+    dbSession.delete(task);
+    return null;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/cmd/GetTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.DbSession;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.model.TaskImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetTask implements Command<Task> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  
+  public GetTask(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public Task execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    return dbSession.get(TaskImpl.class, taskDbid);
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/UpdateTask.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/cmd/UpdateTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/UpdateTask.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/UpdateTask.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.DbSession;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UpdateTask implements Command<Void> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Task task;
+
+  public UpdateTask(Task task) {
+    this.task = task;
+  }
+
+  public Void execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    dbSession.save(task);
+    return null;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/UpdateTask.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.hibernate;
+
+import org.jbpm.pvm.internal.hibernate.HibernateDbSession;
+import org.jbpm.task.session.TaskDbSession;
+
+/**
+ * @author Alejandro Guizar
+ * 
+ */
+public class HibernateTaskDbSession extends HibernateDbSession implements
+    TaskDbSession {
+
+}

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/LifeCycle.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.model.Node;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.task.TaskException;
+
+/**
+ * @author Tom Baeyens
+ */
+public class LifeCycle {
+  
+  private static LifeCycleParser lifeCycleParser = new LifeCycleParser();
+  private static Map<String, ProcessDefinitionImpl> lifeCycleProcesses = new HashMap<String, ProcessDefinitionImpl>();
+
+  public static String initialise(TaskImpl task) {
+    ProcessDefinitionImpl lifeCycle = getLifeCycle(task);
+    Map<String, Object> lifeCycleVariables = new HashMap<String, Object>();
+    lifeCycleVariables.put("task", task);
+    ClientProcessInstance lifeCycleExecution = lifeCycle.createProcessInstance();
+    lifeCycleExecution.setVariables(lifeCycleVariables);
+    lifeCycleExecution.start();
+    return lifeCycleExecution.getNode().getName();
+  }
+
+  public static ProcessDefinitionImpl getLifeCycle(TaskImpl task) {
+    if (task==null) {
+      throw new TaskException("task is null");
+    }
+    String resource = task.getLifeCycleResource();
+    if (resource==null) {
+      throw new TaskException("task "+task.getClass().getName()+" did'nt return a lifecycle");
+    }
+    ProcessDefinitionImpl lifeCycleProcess;
+    synchronized (lifeCycleProcesses) { 
+      lifeCycleProcess = lifeCycleProcesses.get(resource);
+      if (lifeCycleProcess==null) {
+        lifeCycleProcess = (ProcessDefinitionImpl) lifeCycleParser
+            .createParse()
+            .setResource(resource)
+            .execute()
+            .checkProblems("task lifecycle")
+            .getDocumentObject();
+        lifeCycleProcesses.put(resource, lifeCycleProcess);
+      }
+    }
+    return lifeCycleProcess;
+  }
+
+  protected void fireLifeCycleEvent(String eventName, TaskImpl task) {
+    ExecutionImpl lifeCycleExecution = new ExecutionImpl();
+    ProcessDefinitionImpl lifeCycleProcess = getLifeCycle(task);
+    lifeCycleExecution.setProcessDefinition(lifeCycleProcess);
+    String state = task.getState();
+    Node node = lifeCycleProcess.getNode(state);
+    lifeCycleExecution.setNode((NodeImpl) node);
+    lifeCycleExecution.signal(eventName);
+    task.state = lifeCycleExecution.getNode().getName();
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/LifeCycleParser.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class LifeCycleParser extends Parser {
+
+  public Object parseDocumentElement(Element element, Parse parse) {
+    ProcessDefinitionImpl lifeCycleProcess = new ProcessDefinitionImpl();
+    
+    List<Element> stateElements = XmlUtil.elements(element, "state");
+    if (stateElements!=null) {
+      for (Element stateElement: stateElements) {
+        parseState(stateElement, lifeCycleProcess, parse);
+      }
+      for (Element stateElement: stateElements) {
+        parseTransitions(stateElement, lifeCycleProcess, parse);
+      }
+    }
+    
+    String initialStateName = null;
+    if (element.hasAttribute("initial")) {
+      initialStateName = element.getAttribute("initial");
+      NodeImpl initial = (NodeImpl) lifeCycleProcess.getNode(initialStateName);
+      if (initial!=null) {
+        lifeCycleProcess.setInitial(initial);
+      } else {
+        parse.addProblem("initial "+initialStateName+" doesn't exist");
+      }
+    }
+    
+    return lifeCycleProcess;
+  }
+
+  public void parseTransitions(Element element, ProcessDefinitionImpl lifeCycleProcess, Parse parse) {
+    if (! element.hasAttribute("name")) {
+      parse.addProblem("state doesn't have a name: "+XmlUtil.toString(element));
+      return;
+    }
+    String stateName = element.getAttribute("name");
+    NodeImpl state = (NodeImpl) lifeCycleProcess.getNode(stateName);
+    
+    List<Element> transitionElements = XmlUtil.elements(element, "transition");
+    if (transitionElements!=null) {
+      for (Element transitionElement: transitionElements) {
+        parseTransition(transitionElement, state, parse);
+      }
+    }
+  }
+
+  public void parseTransition(Element element, NodeImpl state, Parse parse) {
+    if (! element.hasAttribute("name")) {
+      parse.addProblem("transition doesn't have a name: "+XmlUtil.toString(element));
+      return;
+    }
+    String transitionName = element.getAttribute("name");
+    if (! element.hasAttribute("to")) {
+      parse.addProblem("transition "+transitionName+" doesn't have a to attribute indicating the destination state: "+XmlUtil.toString(element));
+      return;
+    }
+    String destinationName = element.getAttribute("to");
+    NodeImpl destination = (NodeImpl) state.getProcessDefinition().getNode(destinationName);
+    if (destination!=null) {
+      state.createOutgoingTransition(destination, transitionName);
+    } else {
+      parse.addProblem("destination "+destinationName+" of "+transitionName+" is unknown");
+    }
+  }
+
+  public void parseState(Element element, ProcessDefinitionImpl lifeCycleProcess, Parse parse) {
+    if (! element.hasAttribute("name")) {
+      parse.addProblem("state doesn't have an id: "+XmlUtil.toString(element));
+      return;
+    }
+    String stateName = element.getAttribute("name");
+    NodeImpl state = lifeCycleProcess.createNode(stateName);
+    state.setBehaviour(new LifeCycleState());
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleState.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/LifeCycleState.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleState.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleState.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.util.Map;
+
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+
+/**
+ * @author Tom Baeyens
+ */
+public class LifeCycleState implements ExternalActivity {
+
+  private static final long serialVersionUID = 1L;
+
+  public void execute(ActivityExecution execution) throws Exception {
+    execution.waitForSignal();
+  }
+
+  public void signal(ActivityExecution execution, String signalName,
+      Map<String, Object> parameters) throws Exception {
+    execution.take(signalName);
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleState.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/RoleImpl.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/RoleImpl.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/RoleImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/RoleImpl.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.io.Serializable;
+
+import org.jbpm.task.Role;
+
+
+/** the relation between a task and a person.
+ * @author Tom Baeyens
+ */
+public class RoleImpl implements Serializable, Role {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long dbid;
+  protected int dbversion;
+  protected String identityId;
+  protected String roleType;
+  protected String description;
+  protected TaskImpl task;
+  protected SwimlaneImpl swimlane;
+  
+  public String toString() {
+    return roleType.toString()+"("+identityId+")";
+  }
+  
+  public TaskImpl getTask() {
+    return task;
+  }
+  public void setTask(TaskImpl task) {
+    this.task = task;
+  }
+  public String getDescription() {
+    return description;
+  }
+  public void setDescription(String description) {
+    this.description = description;
+  }
+  public long getDbid() {
+    return dbid;
+  }
+  public SwimlaneImpl getSwimlane() {
+    return swimlane;
+  }
+  public void setSwimlane(SwimlaneImpl swimlane) {
+    this.swimlane = swimlane;
+  }
+  public String getIdentityId() {
+    return identityId;
+  }
+  public void setIdentityId(String identityId) {
+    this.identityId = identityId;
+  }
+  public String getRoleType() {
+    return roleType;
+  }
+  public void setRoleType(String roleType) {
+    this.roleType = roleType;
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/RoleImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneDefinitionImpl.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/SwimlaneDefinitionImpl.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneDefinitionImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneDefinitionImpl.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.task.SwimlaneDefinition;
+
+/**
+ * is a process role (aka participant).
+ */
+public class SwimlaneDefinitionImpl implements Serializable, SwimlaneDefinition {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String name = null;
+
+  /**
+   * expression that resolves to 1 single actorId.
+   */
+  protected String actorIdExpression = null;
+
+  /**
+   * expression that resolves to a comma separated list of actorIds.
+   */
+  protected String candidatesExpression = null;
+
+  /**
+   * expression that resolves to an AssignmentHandler implementation.
+   */
+  protected String assignmentExpression = null;
+
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+
+  public void setActorIdExpression(String actorIdExpression) {
+    // Note: combination of actorIdExpression and candidatesExpression is allowed 
+    this.actorIdExpression = actorIdExpression;
+    this.assignmentExpression = null;
+  }
+  public void setCandidatesExpression(String pooledActorsExpression) {
+    // Note: combination of actorIdExpression and pooledActorsExpression is allowed 
+    this.candidatesExpression = pooledActorsExpression;
+    this.assignmentExpression = null;
+  }
+  public void setAssignmentExpression(String assignmentExpression) {
+    // assignment expressions and assignmentDelegation are mutually exclusive
+    this.actorIdExpression = null;
+    this.candidatesExpression = null;
+    this.assignmentExpression = assignmentExpression;
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getName() {
+    return name;
+  }
+  public String getActorIdExpression() {
+    return actorIdExpression;
+  }
+  public String getCandidatesExpression() {
+    return candidatesExpression;
+  }
+  public String getAssignmentExpression() {
+    return assignmentExpression;
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneDefinitionImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneImpl.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/SwimlaneImpl.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneImpl.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.task.Role;
+import org.jbpm.task.Swimlane;
+import org.jbpm.task.SwimlaneDefinition;
+import org.jbpm.task.Task;
+import org.jbpm.task.TaskException;
+
+/**
+ * runtime process role for a specific process instance.
+ */
+public class SwimlaneImpl implements Serializable, Swimlane {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String name = null;
+  protected String assignee = null;
+  protected Set<RoleImpl> candidates = null;
+  protected SwimlaneDefinition swimlaneDefinition = null;
+  
+  // assignment methods ///////////////////////////////////////////////////////
+
+  public String getAssignee() {
+    return assignee;
+  }
+
+  public void setAssignee(String assignee) {
+    this.assignee = assignee;
+  }
+
+  // candidates ///////////////////////////////////////////////////////////////
+
+  public Collection<Role> getCandidates() {
+    if (candidates==null) {
+      return Collections.EMPTY_LIST;
+    }
+    return (Collection)candidates;
+  }
+  
+  public Role createCandidate(String identityId) {
+    if (identityId==null) {
+      throw new TaskException("identityId is null");
+    }
+    RoleImpl role = new RoleImpl();
+    role.setIdentityId(identityId);
+    role.setRoleType(Task.ROLETYPE_CANDIDATE);
+    role.setSwimlane(this);
+    if (candidates==null) {
+      candidates = new HashSet<RoleImpl>();
+    }
+    candidates.add(role);
+    return role;
+  }
+  
+  public void removeCandidate(Role candidate) {
+    if (candidate==null) {
+      throw new TaskException("candidate is null");
+    }
+    if ( (candidates!=null)
+         && (candidates.remove(candidate))
+       ) {
+      ((RoleImpl)candidate).setTask(null);
+    }
+  }
+
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+  
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getName() {
+    return name;
+  }
+  public SwimlaneDefinition getSwimlaneDefinition() {
+    return swimlaneDefinition;
+  }
+  public void setSwimlaneDefinition(SwimlaneDefinition swimlaneDefinition) {
+    this.swimlaneDefinition = swimlaneDefinition;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/SwimlaneImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskDefinitionImpl.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/TaskDefinitionImpl.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskDefinitionImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskDefinitionImpl.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jbpm.model.ObservableElement;
+import org.jbpm.pvm.internal.model.ProcessElementImpl;
+import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.task.TaskDefinition;
+
+/**
+ * defines a task and how the actor(s) must be calculated at runtime.
+ */
+public class TaskDefinitionImpl extends ProcessElementImpl implements Serializable, TaskDefinition {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected String name;
+  protected String description;
+
+  /** @see #isBlocking() */
+  protected boolean isBlocking;
+  
+  /** @see #isSignalling() */
+  protected boolean isSignalling = true;
+
+  protected String dueDateDuration;
+  protected List<TaskDefinitionImpl> subTaskDefinitions;
+  protected int priority = Priority.NORMAL;
+  protected SwimlaneDefinitionImpl swimlaneDefinition;
+  protected String assigneeExpression;
+  protected String candidatesExpression;
+  protected Descriptor assignerDescriptor;
+  
+
+  public String getForm() {
+    return (String) (properties!=null ? properties.get("form") : null);
+  }
+  
+  public ObservableElement getParent() {
+    // TODO Auto-generated method stub
+    // huh ?
+    return null;
+  }
+
+  public boolean hasEvent(String eventName) {
+    // TODO Auto-generated method stub
+    // huh ?
+    return false;
+  }
+
+
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public String getAssigneeExpression() {
+    return assigneeExpression;
+  }
+  public void setAssigneeExpression(String assigneeExpression) {
+    this.assigneeExpression = assigneeExpression;
+  }
+  public Descriptor getAssignerDescriptor() {
+    return assignerDescriptor;
+  }
+  public void setAssignerDescriptor(Descriptor assignerDescriptor) {
+    this.assignerDescriptor = assignerDescriptor;
+  }
+  public String getCandidatesExpression() {
+    return candidatesExpression;
+  }
+  public void setCandidatesExpression(String candidatesExpression) {
+    this.candidatesExpression = candidatesExpression;
+  }
+  public boolean isBlocking() {
+    return isBlocking;
+  }
+  public void setBlocking(boolean isBlocking) {
+    this.isBlocking = isBlocking;
+  }
+  public boolean isSignalling() {
+    return isSignalling;
+  }
+  public void setSignalling(boolean isSignalling) {
+    this.isSignalling = isSignalling;
+  }
+  public int getPriority() {
+    return priority;
+  }
+  public void setPriority(int priority) {
+    this.priority = priority;
+  }
+  public List<TaskDefinitionImpl> getSubTaskDefinitions() {
+    return subTaskDefinitions;
+  }
+  public void setSubTaskDefinitions(List<TaskDefinitionImpl> subTaskDefinitions) {
+    this.subTaskDefinitions = subTaskDefinitions;
+  }
+  public SwimlaneDefinitionImpl getSwimlaneDefinition() {
+    return swimlaneDefinition;
+  }
+  public void setSwimlaneDefinition(SwimlaneDefinitionImpl swimlaneDefinition) {
+    this.swimlaneDefinition = swimlaneDefinition;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public String getDescription() {
+    return description;
+  }
+  public void setDescription(String description) {
+    this.description = description;
+  }
+  public String getDueDateDuration() {
+    return dueDateDuration;
+  }
+  public void setDueDateDuration(String dueDateDuration) {
+    this.dueDateDuration = dueDateDuration;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskDefinitionImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskExecution.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/TaskExecution.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskExecution.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskExecution.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.util.Map;
+
+import org.jbpm.task.Swimlane;
+import org.jbpm.task.Task;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface TaskExecution {
+
+  Map<String, ? extends Task> getTasks();
+  Map<String, ? extends Swimlane> getSwimlanes();
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskExecution.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java (from rev 3186, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/TaskImpl.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,420 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.Execution;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.task.Role;
+import org.jbpm.task.Swimlane;
+import org.jbpm.task.Task;
+import org.jbpm.task.TaskDefinition;
+import org.jbpm.task.TaskException;
+
+/**
+ * is one task instance that can be assigned to an actor (read: put in 
+ * someones task list) and that can trigger the continuation of execution 
+ * of the token upon completion.
+ */
+public class TaskImpl extends ScopeInstanceImpl implements Serializable, Task {
+
+  private static final long serialVersionUID = 1L;
+  // private static final Logger log = Logger.getLogger(TaskImpl.class.getName());
+  
+  // could be made configurable:
+  public static final String CONTEXTKEY_TASK_CLASS_NAME = "taskClassName";
+  public static final String[] SEARCHORDER_TASK_CLASS_NAME = new String[]{
+    // PvmEnvironment.CONTEXTNAME_APPLICATION
+  };
+
+  protected String id;
+  protected String name;
+  protected String description;
+
+  protected String assignee;
+  protected Set<RoleImpl> roles;
+
+  protected Date create;
+  protected Date dueDate;
+  protected Integer progress;
+
+  // protected VariableMap variableMap;
+  protected List<CommentImpl> comments;
+
+  protected int priority = Priority.NORMAL;
+
+  protected String state;
+
+  protected ExecutionImpl execution;
+  protected boolean isSignalling = true;
+  protected boolean isBlocking;
+
+  protected TaskDefinitionImpl taskDefinition;
+  protected SwimlaneImpl swimlane;
+  
+  protected TaskImpl superTask;
+  protected Set<TaskImpl> subTasks;
+  
+  protected TaskImpl() {
+  }
+  
+  // creating a task
+  
+  public static TaskImpl create(String taskId) {
+    return create(taskId, null, null);
+  }
+
+  public static TaskImpl create(String taskId, TaskDefinitionImpl taskDefinition) {
+    return create(taskId, taskDefinition, null);
+  }
+  
+  public static TaskImpl create(String taskId, TaskDefinitionImpl taskDefinition, ExecutionImpl execution) {
+    TaskImpl task = null;
+    // if a task class name is configured
+    Environment environment = Environment.getCurrent();
+    String taskClassName = (environment!=null ? (String) environment.get(TaskImpl.CONTEXTKEY_TASK_CLASS_NAME, TaskImpl.SEARCHORDER_TASK_CLASS_NAME) : null);
+    if (taskClassName!=null) {
+      // dynamically instantiate it
+      ClassLoader classLoader = environment.getClassLoader();
+      Class<?> taskClass = ReflectUtil.loadClass(classLoader, taskClassName);
+      task = (TaskImpl) ReflectUtil.newInstance(taskClass);
+  
+    // otherwise just use the default task implementation type 
+    } else {
+      task = new TaskImpl();
+    }
+
+    task.create = Clock.getCurrentTime();
+
+    task.setId(taskId);
+    task.setTaskDefinition(taskDefinition);
+    task.setExecution(execution);
+    
+    // initialise the task state
+    task.state = LifeCycle.initialise(task); 
+
+    return task;
+  }
+
+  public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
+    this.taskDefinition = taskDefinition;
+    if (taskDefinition!=null) {
+      this.name = taskDefinition.getName();
+      this.description = taskDefinition.getDescription();
+      this.isBlocking = taskDefinition.isBlocking();
+      this.isSignalling = taskDefinition.isSignalling();
+      this.priority = taskDefinition.getPriority();
+      
+      String durationText = taskDefinition.getDueDateDuration();
+      if (durationText!=null) {
+        this.dueDate = calculateDueDate(new Duration(durationText));
+      }
+    }
+  }
+  
+  protected static Date calculateDueDate(Duration dueDate) {
+    // TODO
+    return null;
+  }
+
+  // assigning a task /////////////////////////////////////////////////////////
+  
+  public String getAssignee() {
+    return assignee;
+  }
+
+  public void setAssignee(String assignee) {
+    this.assignee = assignee;
+    // TODO fire the assignment event
+  }
+
+  // roles ////////////////////////////////////////////////////////////////////
+  
+  public Set<RoleImpl> getRoles() {
+    if (roles==null) {
+      return Collections.EMPTY_SET;
+    }
+    return roles;
+  }
+  
+  public Set<RoleImpl> getAllRoles() {
+    Set<RoleImpl> allRoles = null;
+    if (roles!=null) {
+      allRoles = new HashSet<RoleImpl>(roles);
+    } else {
+      allRoles = new HashSet<RoleImpl>();
+    }
+    if (swimlane!=null) {
+      allRoles.addAll((Set)swimlane.getCandidates());
+    }
+    return allRoles;
+  }
+  
+  public Role addRole(String identityId, String roleType) {
+    if (identityId==null) {
+      throw new TaskException("userId is null");
+    }
+    if (roleType==null) {
+      throw new TaskException("roleType is null");
+    }
+    RoleImpl role = new RoleImpl();
+    role.setIdentityId(identityId);
+    role.setTask(this);
+    role.setRoleType(roleType);
+    if (roles==null) {
+      roles = new HashSet<RoleImpl>();
+    }
+    roles.add(role);
+    return role;
+  }
+  
+  public void removeRole(Role role) {
+    if (role==null) {
+      throw new TaskException("role is null");
+    }
+    if ( (roles!=null)
+         && (roles.remove(role))
+       ) {
+      ((RoleImpl)role).setTask(null);
+    }
+  }
+  
+  // completion ///////////////////////////////////////////////////////////////
+
+  public void submit() {
+    submit(null);
+  }
+
+  public void submit(Map<String, Object> variables) {
+  }
+
+  // comments /////////////////////////////////////////////////////////////////
+
+  public List<Comment> getComments() {
+    if (comments==null) {
+      return Collections.EMPTY_LIST;
+    }
+    return (List) comments;
+  }
+
+  public Comment createComment(String commentText) {
+    if (comments==null) {
+      comments = new ArrayList<CommentImpl>();
+    }
+    CommentImpl comment = new CommentImpl(commentText);
+    comments.add(comment);
+    return comment;
+  }
+
+  public void removeComment(Comment comment) {
+    if (comment==null) {
+      throw new TaskException("comment is null");
+    }
+    if (comments!=null) {
+      comments.remove(comment);
+    }
+  }
+  
+  // subtasks /////////////////////////////////////////////////////////////////
+  
+  public Set<Task> getSubTasks() {
+    if (subTasks==null) {
+      return Collections.emptySet();
+    }
+    return (Set) subTasks;
+  }
+
+  public Task createSubTask(String name) {
+    if (subTasks==null) {
+      subTasks = new HashSet<TaskImpl>();
+    }
+    TaskImpl subtask = new TaskImpl();
+    subtask.setName(name);
+    addSubTask(subtask);
+    return subtask;
+  }
+  
+  public Task createSubTask(String subTaskId, TaskDefinition subTaskDefinition) {
+    if (subTaskDefinition==null) {
+      throw new TaskException("subtaskDefinition is null");
+    }
+    if (subTasks==null) {
+      subTasks = new HashSet<TaskImpl>();
+    }
+    TaskImpl subtask = create(subTaskId, taskDefinition);
+    addSubTask(subtask);
+    return subtask;
+  }
+  
+  public Task addSubTask(TaskImpl subtask) {
+    if (subTasks==null) {
+      subTasks = new HashSet<TaskImpl>();
+    }
+    subtask.setSuperTask(this);
+    subTasks.add(subtask);
+    return subtask;
+  }
+
+  public void removeSubTask(Task subtask) {
+    if (subtask==null) {
+      throw new TaskException("subtask is null");
+    }
+    if ( (subTasks!=null)
+         && (subTasks.remove(subtask))
+       ) {
+      ((TaskImpl)subtask).setSuperTask(null);
+    }
+  }
+  
+  // equals ///////////////////////////////////////////////////////////////////
+  // hack to support comparing hibernate proxies against the real objects
+  // since this always falls back to ==, we don't need to overwrite the hashcode
+  public boolean equals(Object o) {
+    return EqualsUtil.equals(this, o);
+  }
+
+  public String getLifeCycleResource() {
+    // the default lifecycle can be overridden in subclasses
+    return "jbpm.task.default.lifecycle.xml";
+  }
+  
+  // modified getters and setters /////////////////////////////////////////////
+  public void setProgress(Integer progress) {
+    if ( (progress<0)
+         || (progress>100)
+       ) {
+      throw new TaskException("task progress is a percentage (integer) and must be expressed between 0 and 100");
+    }
+    this.progress = progress;
+  }
+  
+  // getters and setters //////////////////////////////////////////////////////
+  
+  public String getDescription() {
+    return description;
+  }
+  public void setDescription(String description) {
+    this.description = description;
+  }
+  public String getName() {
+    return name;
+  }
+  public void setName(String name) {
+    this.name = name;
+  }
+  public boolean isBlocking() {
+    return isBlocking;
+  }
+  public void setBlocking(boolean isBlocking) {
+    this.isBlocking = isBlocking;
+  }
+  public boolean isSignalling() {
+    return isSignalling;
+  }
+  public void setSignalling(boolean isSignalling) {
+    this.isSignalling = isSignalling;
+  }
+  public int getPriority() {
+    return priority;
+  }
+  public void setPriority(int priority) {
+    this.priority = priority;
+  }
+  public void setComments(List<CommentImpl> comments) {
+    this.comments = comments;
+  }
+  public Date getCreate() {
+    return create;
+  }
+  public void setCreate(Date create) {
+    this.create = create;
+  }
+  public Date getDueDate() {
+    return dueDate;
+  }
+  public void setDueDate(Date dueDate) {
+    this.dueDate = dueDate;
+  }
+  public ExecutionImpl getExecution() {
+    return execution;
+  }
+  public void setExecution(Execution execution) {
+    this.execution = (ExecutionImpl) execution;
+  }
+  public String getState() {
+    return state;
+  }
+  public Swimlane getSwimlane() {
+    return swimlane;
+  }
+  public void setSwimlane(SwimlaneImpl swimlane) {
+    this.swimlane = swimlane;
+  }
+  public long getDbid() {
+    return dbid;
+  }
+  public TaskDefinition getTaskDefinition() {
+    return taskDefinition;
+  }
+  public TaskImpl getSuperTask() {
+    return superTask;
+  }
+  public void setSuperTask(TaskImpl superTask) {
+    this.superTask = superTask;
+  }
+  public Integer getProgress() {
+    return progress;
+  }
+  public String getId() {
+    return id;
+  }
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  public String getAssignedUserId() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public void setAssignedUserId(String assignedUserId) {
+    // TODO Auto-generated method stub
+    
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java (from rev 3186, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/impl/TaskServiceImpl.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.util.List;
+
+import org.jbpm.TaskService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.task.Role;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.cmd.CreateTask;
+import org.jbpm.task.internal.cmd.UpdateTask;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskServiceImpl implements TaskService {
+  
+  protected CommandService commandService;
+  
+  public TaskServiceImpl() {
+  }
+
+  public TaskServiceImpl(CommandService commandService) {
+    this.commandService = commandService;
+  }
+
+  public void updateTask(Task task) {
+    commandService.execute(new UpdateTask(task));
+  }
+
+  public CommandService getCommandService() {
+    return commandService;
+  }
+  public void setCommandService(CommandService commandService) {
+    this.commandService = commandService;
+  }
+
+  public void deleteTask(String taskId) {
+    // TODO Auto-generated method stub
+    
+  }
+
+  public List<Task> getPersonalTaskList(String userId, int firstResult, int maxResults) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public Task getTask(String taskId) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public Task newTask(String taskId) {
+    return commandService.execute(new CreateTask(taskId));
+  }
+
+  public void submitTask(String taskId) {
+    // TODO Auto-generated method stub
+  }
+
+  public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public List<String> getCandidates(String taskId) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public List<Role> getRoles(String taskId) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskDbSessionBinding.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/xml/TaskDbSessionBinding.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskDbSessionBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskDbSessionBinding.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.binding.WireDescriptorBinding;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.task.internal.wire.descriptor.HibernateTaskDbSessionDescriptor;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskDbSessionBinding extends WireDescriptorBinding {
+
+  public TaskDbSessionBinding() {
+    super("task-db-session");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    HibernateTaskDbSessionDescriptor descriptor = new HibernateTaskDbSessionDescriptor();
+
+    if (element.hasAttribute("session")) {
+      descriptor.setSessionName(element.getAttribute("session"));
+    }
+
+    return descriptor;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskDbSessionBinding.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskServiceBinding.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/xml/TaskServiceBinding.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskServiceBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskServiceBinding.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.wire.binding;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.wire.binding.WireDescriptorBinding;
+import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.task.internal.model.TaskServiceImpl;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskServiceBinding extends WireDescriptorBinding {
+
+  public TaskServiceBinding() {
+    super("task-service");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    ObjectDescriptor descriptor = new ObjectDescriptor(TaskServiceImpl.class);
+    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    return descriptor;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/binding/TaskServiceBinding.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/xml/TaskDbSessionDescriptor.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.wire.descriptor;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+import org.jbpm.task.internal.hibernate.HibernateTaskDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateTaskDbSessionDescriptor extends AbstractDescriptor {
+
+  private static final long serialVersionUID = 1L;
+
+  private String sessionName;
+
+  public Object construct(WireContext wireContext) {
+    return new HibernateTaskDbSession();
+  }
+
+  public void initialize(Object object, WireContext wireContext) {
+    // get the hibernate-session
+    Session session = null;
+    if (sessionName != null) {
+      session = (Session) wireContext.get(sessionName);
+    } else {
+      session = wireContext.get(Session.class);
+    }
+
+    if (session == null) {
+      throw new WireException("couldn't find hibernate-session "
+          + (sessionName != null ? "'" + sessionName + "'" : "by type ")
+          + "to create pvm-db-session");
+    }
+
+    // inject the session
+    ((HibernateTaskDbSession) object).setSession(session);
+  }
+
+  public Class<?> getType(WireDefinition wireDefinition) {
+    return HibernateTaskDbSession.class;
+  }
+
+  public void setSessionName(String sessionName) {
+    this.sessionName = sessionName;
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/wire/descriptor/HibernateTaskDbSessionDescriptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java (from rev 3185, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/db/TaskDbSession.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.session;
+
+import org.jbpm.session.DbSession;
+
+/** 
+ * Persistence interface for tasks.
+ * @author Alejandro Guizar
+ */
+public interface TaskDbSession extends DbSession {
+
+  // TODO
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Modified: jbpm4/trunk/modules/task/src/main/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/task/src/main/resources/jbpm.task.hbm.xml	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/main/resources/jbpm.task.hbm.xml	2008-12-05 01:28:25 UTC (rev 3210)
@@ -2,7 +2,7 @@
 <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
           "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping auto-import="false" package="org.jbpm.task.impl" default-access="field">
+<hibernate-mapping auto-import="false" package="org.jbpm.task.internal.model" default-access="field">
 
   <!-- ### TASK DEFINITION ################################################ -->
   <class name="TaskDefinitionImpl" discriminator-value="T">
@@ -157,7 +157,7 @@
   <query name="findTasks">
     <![CDATA[
      select task
-     from org.jbpm.task.impl.TaskImpl as task
+     from org.jbpm.task.internal.model.TaskImpl as task
     ]]>
   </query>
 

Modified: jbpm4/trunk/modules/task/src/main/resources/jbpm.task.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/task/src/main/resources/jbpm.task.wire.bindings.xml	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/main/resources/jbpm.task.wire.bindings.xml	2008-12-05 01:28:25 UTC (rev 3210)
@@ -1,6 +1,6 @@
 <wire-bindings>
 
-  <binding tag="task-db-session" class="org.jbpm.task.xml.TaskDbSessionBinding" category="descriptor" />
-  <binding tag="task-service" class="org.jbpm.task.xml.TaskServiceBinding" category="descriptor" />
+  <binding class="org.jbpm.task.internal.wire.binding.TaskDbSessionBinding" />
+  <binding class="org.jbpm.task.internal.wire.binding.TaskServiceBinding" />
 
 </wire-bindings>

Deleted: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskDbTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskDbTest.java	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskDbTest.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -1,384 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.task;
-
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class TaskDbTest extends DbTestCase {
-
-  public void testNothing() {
-  }
-
-  /*
-  public void testTask() {
-    Date now = new Date();
-    Date inFiveMinutes = new Date(now.getTime()+ (5*60*1000));
-
-    TaskImpl task;
-    try {
-      Clock.setCurrentTime(now);
-      task = TaskImpl.create();
-    } finally {
-      Clock.setCurrentTime(null);
-    }
-    task.setName("hello");
-    task.setDescription("say hello to your neighbour developer");
-    task.setDueDate(inFiveMinutes);
-    task.setPriority(Priority.HIGHEST);
-    
-    task = reload(task, TaskImpl.class);
-    
-    assertEquals("hello", task.getName());
-    assertEquals("say hello to your neighbour developer", task.getDescription());
-    assertEquals(now, task.getCreate());
-    assertEquals(inFiveMinutes, task.getDueDate());
-    assertEquals(Priority.HIGHEST, task.getPriority());
-    
-  }
-
-  public void testTaskAssignment() {
-    TaskImpl task = TaskImpl.create();
-    task.setAssignee("john doe");
-
-    task = reload(task, TaskImpl.class);
-    
-    assertEquals("john doe", task.getAssignee());
-  }
-
-  public void testTaskReassignmentAssignment() {
-    TaskImpl task = TaskImpl.create();
-    task.setAssignee("johndoe");
-    assertEquals("johndoe", task.getAssignee());
-
-    task = reload(task, TaskImpl.class);
-    
-    task.setAssignee("joesmoe");
-
-    task = reload(task, TaskImpl.class);
-    
-    assertEquals("joesmoe", task.getAssignee());
-  }
-
-  public void testTaskRoles() {
-    TaskImpl task = TaskImpl.create();
-    
-    assertNotNull(task.getRoles());
-    assertEquals(0, task.getRoles().size());
-    
-    task.addRole("john doe", RoleType.CLIENT).setDescription("uses the result");
-    task.addRole("joe smoe", RoleType.OWNER).setDescription("does what he wants");
-    task.addRole("jack black", RoleType.CANDIDATE).setDescription("can take this task");
-    task.addRole("jim slim", RoleType.VIEWER).setDescription("is allowed to see");
-    task.addRole("jeff nef", RoleType.REPLACED_ASSIGNEE).setDescription("is sick");
-
-    task = reload(task, TaskImpl.class);
-
-    Map<String, RoleImpl> roleMap = getRoleMap(task.getRoles());
-    
-    assertEquals(RoleType.CLIENT, roleMap.get("john doe").getRoleType());
-    assertEquals("uses the result", roleMap.get("john doe").getDescription());
-
-    assertEquals(RoleType.OWNER, roleMap.get("joe smoe").getRoleType());
-    assertEquals("does what he wants", roleMap.get("joe smoe").getDescription());
-
-    assertEquals(RoleType.CANDIDATE, roleMap.get("jack black").getRoleType());
-    assertEquals("can take this task", roleMap.get("jack black").getDescription());
-
-    assertEquals(RoleType.VIEWER, roleMap.get("jim slim").getRoleType());
-    assertEquals("is allowed to see", roleMap.get("jim slim").getDescription());
-
-    assertEquals(RoleType.REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
-    assertEquals("is sick", roleMap.get("jeff nef").getDescription());
-    
-    assertEquals(5, roleMap.size());
-    
-    task.removeRole(roleMap.get("john doe"));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(4, task.getRoles().size());
-    task.removeRole(getRoleMap(task.getRoles()).get("joe smoe"));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(3, task.getRoles().size());
-    task.removeRole(getRoleMap(task.getRoles()).get("jack black"));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(2, task.getRoles().size());
-    task.removeRole(getRoleMap(task.getRoles()).get("jim slim"));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(1, task.getRoles().size());
-    task.removeRole(getRoleMap(task.getRoles()).get("jeff nef"));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(0, getRoleMap(task.getRoles()).size());
-  }
-
-  public static Map<String, RoleImpl> getRoleMap(Set<RoleImpl> roles) {
-    Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
-    for (RoleImpl role: roles) {
-      roleMap.put(role.getIdentityId(), role);
-    }
-    return roleMap;
-  }
-  
-  public void testTaskAllRoles() {
-    SwimlaneImpl manager = new SwimlaneImpl();
-
-    manager.createCandidate("joe smoe").setDescription("too much tostesteron");
-    manager.createCandidate("jack black").setDescription("the pigeon");
-    manager.createCandidate("jim slim").setDescription("lame duck");
-    
-    manager = reload(manager, SwimlaneImpl.class);
-    
-    TaskImpl task = TaskImpl.create();
-    assertNotNull(task.getAllRoles());
-    assertEquals(0, task.getAllRoles().size());
-
-    task.addRole("john doe", RoleType.CLIENT).setDescription("uses the result");
-    assertEquals(1, task.getAllRoles().size());
-
-    task.addRole("jeff nef", RoleType.REPLACED_ASSIGNEE).setDescription("is sick");
-    task.setSwimlane(manager);
-    
-    task = reload(task, TaskImpl.class);
-    
-    Map<String, RoleImpl> roleMap = getRoleMap(task.getAllRoles());
-    
-    assertEquals(RoleType.CLIENT, roleMap.get("john doe").getRoleType());
-    assertEquals("uses the result", roleMap.get("john doe").getDescription());
-
-    assertEquals(RoleType.CANDIDATE, roleMap.get("joe smoe").getRoleType());
-    assertEquals("too much tostesteron", roleMap.get("joe smoe").getDescription());
-
-    assertEquals(RoleType.CANDIDATE, roleMap.get("jack black").getRoleType());
-    assertEquals("the pigeon", roleMap.get("jack black").getDescription());
-
-    assertEquals(RoleType.CANDIDATE, roleMap.get("jim slim").getRoleType());
-    assertEquals("lame duck", roleMap.get("jim slim").getDescription());
-
-    assertEquals(RoleType.REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
-    assertEquals("is sick", roleMap.get("jeff nef").getDescription());
-    
-    assertEquals(5, roleMap.size());
-    
-    task.removeRole(roleMap.get("john doe"));
-    
-    task = reload(task, TaskImpl.class);
-    manager = environment.get(DbSession.class).get(SwimlaneImpl.class, manager.getDbid());
-    
-    assertEquals(4, task.getAllRoles().size());
-    manager.removeCandidate(getRoleMap(task.getAllRoles()).get("joe smoe"));
-
-    task = reload(task, TaskImpl.class);
-    manager = environment.get(DbSession.class).get(SwimlaneImpl.class, manager.getDbid());
-
-    assertEquals(3, task.getAllRoles().size());
-    manager.removeCandidate(getRoleMap(task.getAllRoles()).get("jack black"));
-
-    task = reload(task, TaskImpl.class);
-    manager = environment.get(DbSession.class).get(SwimlaneImpl.class, manager.getDbid());
-
-    assertEquals(2, task.getAllRoles().size());
-    manager.removeCandidate(getRoleMap(task.getAllRoles()).get("jim slim"));
-
-    task = reload(task, TaskImpl.class);
-    manager = environment.get(DbSession.class).get(SwimlaneImpl.class, manager.getDbid());
-
-    assertEquals(1, task.getAllRoles().size());
-    task.removeRole(getRoleMap(task.getAllRoles()).get("jeff nef"));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(0, task.getAllRoles().size());
-  }
-
-  public void testTaskComment() {
-    EnvironmentFactory environmentFactory = EnvironmentFactory.parseXmlString("<environment/>");
-    TaskImpl task = TaskImpl.create();
-    
-    Environment environment = environmentFactory.openEnvironment();
-    try {
-      environment.setUserId("john doe");
-      task.createComment("should I really do this ?  yuk.");
-    } finally {
-      environment.close();
-    }
-    
-    task = reload(task, TaskImpl.class);
-    
-    environment = environmentFactory.openEnvironment();
-    try {
-      environment.setUserId("joe smoe");
-      task.createComment("yes, you should really do it.");
-    } finally {
-      environment.close();
-    }
-    
-    task = reload(task, TaskImpl.class);
-    
-    List<Comment> comments = task.getComments();
-    assertNotNull(comments);
-    
-    assertEquals("should I really do this ?  yuk.", comments.get(0).getMessage());
-    assertEquals("john doe", comments.get(0).getUserId());
-    
-    assertEquals("yes, you should really do it.", comments.get(1).getMessage());
-    assertEquals("joe smoe", comments.get(1).getUserId());
-  }
-
-  public void testTaskCommentReplies() {
-    TaskImpl task = TaskImpl.create();
-    Comment comment = task.createComment("hi, how are you?");
-    Comment reply = comment.createReply("i'm fine, thanks");
-    reply = reply.createReply("nice wheather, huh");
-    reply.createReply("snow's great fun");
-
-    task = reload(task, TaskImpl.class);
-
-    comment = task.createComment("are you going to the office?");
-    reply = comment.createReply("no not now");
-    reply = reply.createReply("when are you going");
-    reply.createReply("later");
-
-    task = reload(task, TaskImpl.class);
-
-    List<Comment> comments = task.getComments();
-    assertEquals("hi, how are you?", comments.get(0).getMessage());
-    assertEquals("i'm fine, thanks", comments.get(0).getReplies().get(0).getMessage());
-    assertEquals("nice wheather, huh", comments.get(0).getReplies().get(0).getReplies().get(0).getMessage());
-    assertEquals("snow's great fun", comments.get(0).getReplies().get(0).getReplies().get(0).getReplies().get(0).getMessage());
-    
-    assertEquals("are you going to the office?", comments.get(1).getMessage());
-    assertEquals("no not now", comments.get(1).getReplies().get(0).getMessage());
-    assertEquals("when are you going", comments.get(1).getReplies().get(0).getReplies().get(0).getMessage());
-    assertEquals("later", comments.get(1).getReplies().get(0).getReplies().get(0).getReplies().get(0).getMessage());
-    
-    comment = task.getComments().get(0);
-    comment.removeReply(comment.getReplies().get(0));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals("hi, how are you?", comment.getMessage());
-    assertTrue(comment.getReplies().isEmpty());
-    assertEquals(2, task.getComments().size());
-
-    task.removeComment(task.getComments().get(1));
-
-    task = reload(task, TaskImpl.class);
-
-    assertEquals(1, task.getComments().size());
-    assertEquals("hi, how are you?", comment.getMessage());
-  }
-
-  public void testTaskWithDefinition() {
-    TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
-    taskDefinition.setName("hello");
-    taskDefinition.setPriority(Priority.HIGH);
-
-    taskDefinition = reload(taskDefinition, TaskDefinitionImpl.class);
-
-    TaskImpl task = TaskImpl.create(taskDefinition);
-
-    task = reload(task, TaskImpl.class);
-    
-    assertEquals("hello", task.getName());
-    assertEquals(Priority.HIGH, task.getPriority());
-    assertEquals("hello", task.getTaskDefinition().getName());
-  }
-
-  public void testSubTasks() {
-    TaskImpl improveWorld = TaskImpl.create();
-    improveWorld.setName("improve the world");
-    
-    improveWorld.createSubTask("try to automate everything");
-    
-    improveWorld = reload(improveWorld, TaskImpl.class);
-
-    improveWorld.createSubTask("discover the problem is in the workflow part");
-    TaskImpl writeWorkflowEngine = (TaskImpl) improveWorld.createSubTask("write an open source workflow engine");
-    writeWorkflowEngine.createSubTask("create a sf.net project");
-    Task commitCode = writeWorkflowEngine.createSubTask("commit code to cvs");
-    writeWorkflowEngine.createSubTask("nurture it and grow it");
-    writeWorkflowEngine.createSubTask("harvest a beautiful project");
-
-    improveWorld.createSubTask("automate everything with workflow");
-    improveWorld.createSubTask("create peace everywhere");
-
-    improveWorld = reload(improveWorld, TaskImpl.class);
-    
-    writeWorkflowEngine = environment.get(DbSession.class).get(TaskImpl.class, writeWorkflowEngine.getDbid());
-
-    Set<String> expectedSubtaskNames = new HashSet<String>();
-    expectedSubtaskNames.add("try to automate everything");
-    expectedSubtaskNames.add("discover the problem is in the workflow part");
-    expectedSubtaskNames.add("write an open source workflow engine");
-    expectedSubtaskNames.add("automate everything with workflow");
-    expectedSubtaskNames.add("create peace everywhere");
-    
-    Set<Task> subtasks = improveWorld.getSubTasks();
-    Set<String> subtaskNames = new HashSet<String>();
-    for (Task subtask: subtasks) {
-      subtaskNames.add(subtask.getName());
-    }
-    
-    assertEquals(expectedSubtaskNames, subtaskNames);
-
-    expectedSubtaskNames = new HashSet<String>();
-    expectedSubtaskNames.add("create a sf.net project");
-    expectedSubtaskNames.add("commit code to cvs");
-    expectedSubtaskNames.add("nurture it and grow it");
-    expectedSubtaskNames.add("harvest a beautiful project");
-    
-    subtasks = writeWorkflowEngine.getSubTasks();
-    subtaskNames = new HashSet<String>();
-    for (Task subtask: subtasks) {
-      subtaskNames.add(subtask.getName());
-    }
-
-    assertEquals(expectedSubtaskNames, subtaskNames);
-    
-    writeWorkflowEngine = reload(writeWorkflowEngine, TaskImpl.class);
-    commitCode = environment.get(DbSession.class).get(TaskImpl.class, commitCode.getDbid());
-    writeWorkflowEngine.removeSubTask(commitCode);
-    expectedSubtaskNames.remove("commit code to cvs");
-
-    writeWorkflowEngine = reload(writeWorkflowEngine, TaskImpl.class);
-
-    subtasks = writeWorkflowEngine.getSubTasks();
-    subtaskNames = new HashSet<String>();
-    for (Task subtask: subtasks) {
-      subtaskNames.add(subtask.getName());
-    }
-
-    assertEquals(expectedSubtaskNames, subtaskNames);
-  }
-  */
-}

Modified: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -24,36 +24,14 @@
 import org.jbpm.test.DbTestCase;
 
 /**
- * @author Tom Baeyens
+ * @author Alejandro Guizar
  */
 public class TaskServiceTest extends DbTestCase {
 
-  public void testTaskService() {
-    /*
-    Task task = taskService.createTask();
-    task.setName("doing the dishes");
-    Date now = new Date();
-    task.setDueDate(now);
-    taskService.updateTask(task);
-
-    long taskDbid = task.getDbid();
-    task = taskService.getTask(taskDbid);
-    assertEquals("doing the dishes", task.getName());
-    assertEquals(now, task.getDueDate());
-    
-    taskService.deleteTask(taskDbid);
-    
-    // verify that the task table is empty
-    CommandService commandService = null;
-    commandService.execute(new Command() {
-      public Object execute(Environment environment) throws Exception {
-        Session session = environment.get(Session.class);
-        List tasks = session.createQuery("from "+TaskImpl.class.getName()).list();
-        assertEquals(0, tasks.size());
-        return null;
-      }
-    });
-    */
+  public void testNewTask() {
+    String taskId = getName();
+    Task task = createTask(taskId);
+    assertEquals(taskId, task.getId());
   }
 
 }

Deleted: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskTest.java	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskTest.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -1,312 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.task;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.pvm.internal.util.Clock;
-import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.task.impl.RoleImpl;
-import org.jbpm.task.impl.SwimlaneImpl;
-import org.jbpm.task.impl.TaskImpl;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class TaskTest extends JbpmTestCase {
-
-  public void testTask() {
-    Date now = new Date();
-    Date inFiveMinutes = new Date(now.getTime()+ (5*60*1000));
-
-    TaskImpl task;
-    try {
-      Clock.setCurrentTime(now);
-      task = TaskImpl.create(getName());
-    } finally {
-      Clock.setCurrentTime(null);
-    }
-    task.setName("hello");
-    task.setDescription("say hello to your neighbour developer");
-    task.setDueDate(inFiveMinutes);
-    task.setPriority(Priority.HIGHEST);
-    
-    assertEquals("hello", task.getName());
-    assertEquals("say hello to your neighbour developer", task.getDescription());
-    assertEquals(now, task.getCreate());
-    assertEquals(inFiveMinutes, task.getDueDate());
-    assertEquals(Priority.HIGHEST, task.getPriority());
-  }
-
-  public void testTaskAssignment() {
-    TaskImpl task = TaskImpl.create(getName());
-    task.setAssignee("john doe");
-    assertEquals("john doe", task.getAssignee());
-  }
-
-  public void testTaskReassignmentAssignment() {
-    TaskImpl task = TaskImpl.create(getName());
-    task.setAssignee("johndoe");
-    assertEquals("johndoe", task.getAssignee());
-    task.setAssignee("joesmoe");
-    assertEquals("joesmoe", task.getAssignee());
-  }
-
-  public void testTaskRoles() {
-    TaskImpl task = TaskImpl.create(getName());
-    
-    assertNotNull(task.getRoles());
-    assertEquals(0, task.getRoles().size());
-    
-    task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
-    task.addRole("joe smoe", Task.ROLETYPE_OWNER).setDescription("does what he wants");
-    task.addRole("jack black", Task.ROLETYPE_CANDIDATE).setDescription("can take this task");
-    task.addRole("jim slim", Task.ROLETYPE_VIEWER).setDescription("is allowed to see");
-    task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
-    
-    Set<RoleImpl> roles = task.getRoles();
-    Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
-    for (RoleImpl role: roles) {
-      roleMap.put(role.getIdentityId(), role);
-    }
-    
-    assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
-    assertEquals("uses the result", roleMap.get("john doe").getDescription());
-
-    assertEquals(Task.ROLETYPE_OWNER, roleMap.get("joe smoe").getRoleType());
-    assertEquals("does what he wants", roleMap.get("joe smoe").getDescription());
-
-    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
-    assertEquals("can take this task", roleMap.get("jack black").getDescription());
-
-    assertEquals(Task.ROLETYPE_VIEWER, roleMap.get("jim slim").getRoleType());
-    assertEquals("is allowed to see", roleMap.get("jim slim").getDescription());
-
-    assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
-    assertEquals("is sick", roleMap.get("jeff nef").getDescription());
-    
-    assertEquals(5, roles.size());
-    
-    task.removeRole(roleMap.get("john doe"));
-    assertEquals(4, task.getRoles().size());
-    task.removeRole(roleMap.get("joe smoe"));
-    assertEquals(3, task.getRoles().size());
-    task.removeRole(roleMap.get("jack black"));
-    assertEquals(2, task.getRoles().size());
-    task.removeRole(roleMap.get("jim slim"));
-    assertEquals(1, task.getRoles().size());
-    task.removeRole(roleMap.get("jeff nef"));
-    assertEquals(0, roles.size());
-  }
-
-  public void testTaskAllRoles() {
-    TaskImpl task = TaskImpl.create(getName());
-    
-    assertNotNull(task.getAllRoles());
-    assertEquals(0, task.getAllRoles().size());
-    
-    task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
-    
-    SwimlaneImpl manager = new SwimlaneImpl();
-    task.setSwimlane(manager);
-
-    manager.createCandidate("joe smoe").setDescription("tostesteron ambition");
-    manager.createCandidate("jack black").setDescription("the pigeon");
-    manager.createCandidate("jim slim").setDescription("lame duck");
-    
-    task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
-    
-    Set<RoleImpl> roles = task.getAllRoles();
-    Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
-    for (RoleImpl role: roles) {
-      roleMap.put(role.getIdentityId(), role);
-    }
-    
-    assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
-    assertEquals("uses the result", roleMap.get("john doe").getDescription());
-
-    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("joe smoe").getRoleType());
-    assertEquals("tostesteron ambition", roleMap.get("joe smoe").getDescription());
-
-    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
-    assertEquals("the pigeon", roleMap.get("jack black").getDescription());
-
-    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jim slim").getRoleType());
-    assertEquals("lame duck", roleMap.get("jim slim").getDescription());
-
-    assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
-    assertEquals("is sick", roleMap.get("jeff nef").getDescription());
-    
-    assertEquals(5, roles.size());
-    
-    task.removeRole(roleMap.get("john doe"));
-    assertEquals(4, task.getAllRoles().size());
-    manager.removeCandidate(roleMap.get("joe smoe"));
-    assertEquals(3, task.getAllRoles().size());
-    manager.removeCandidate(roleMap.get("jack black"));
-    assertEquals(2, task.getAllRoles().size());
-    manager.removeCandidate(roleMap.get("jim slim"));
-    assertEquals(1, task.getAllRoles().size());
-    task.removeRole(roleMap.get("jeff nef"));
-    assertEquals(0, task.getAllRoles().size());
-  }
-
-  /*
-  public void testTaskComment() {
-    EnvironmentFactory environmentFactory = EnvironmentFactory.parseXmlString("<environment/>");
-    TaskImpl task = TaskImpl.create();
-    
-    Environment environment = environmentFactory.openEnvironment();
-    try {
-      environment.setUserId("john doe");
-      task.createComment("should I really do this ?  yuk.");
-    } finally {
-      environment.close();
-    }
-    
-    environment = environmentFactory.openEnvironment();
-    try {
-      environment.setUserId("joe smoe");
-      task.createComment("yes, you should really do it.");
-    } finally {
-      environment.close();
-    }
-    
-    List<Comment> comments = task.getComments();
-    assertNotNull(comments);
-    
-    assertEquals("should I really do this ?  yuk.", comments.get(0).getMessage());
-    assertEquals("john doe", comments.get(0).getUserId());
-    
-    assertEquals("yes, you should really do it.", comments.get(1).getMessage());
-    assertEquals("joe smoe", comments.get(1).getUserId());
-  }
-
-  public void testTaskCommentReplies() {
-    TaskImpl task = TaskImpl.create();
-    Comment comment = task.createComment("hi, how are you?");
-    Comment reply = comment.createReply("i'm fine, thanks");
-    reply = reply.createReply("nice wheather, huh");
-    reply.createReply("snow's great fun");
-    
-    comment = task.createComment("are you going to the office?");
-    reply = comment.createReply("no not now");
-    reply = reply.createReply("when are you going");
-    reply.createReply("later");
-    
-    List<Comment> comments = task.getComments();
-    assertEquals("hi, how are you?", comments.get(0).getMessage());
-    assertEquals("i'm fine, thanks", comments.get(0).getReplies().get(0).getMessage());
-    assertEquals("nice wheather, huh", comments.get(0).getReplies().get(0).getReplies().get(0).getMessage());
-    assertEquals("snow's great fun", comments.get(0).getReplies().get(0).getReplies().get(0).getReplies().get(0).getMessage());
-    
-    assertEquals("are you going to the office?", comments.get(1).getMessage());
-    assertEquals("no not now", comments.get(1).getReplies().get(0).getMessage());
-    assertEquals("when are you going", comments.get(1).getReplies().get(0).getReplies().get(0).getMessage());
-    assertEquals("later", comments.get(1).getReplies().get(0).getReplies().get(0).getReplies().get(0).getMessage());
-    
-    comment = task.getComments().get(0);
-    comment.removeReply(comment.getReplies().get(0));
-    
-    assertEquals("hi, how are you?", comment.getMessage());
-    assertTrue(comment.getReplies().isEmpty());
-    assertEquals(2, task.getComments().size());
-
-    task.removeComment(task.getComments().get(1));
-    
-    assertEquals(1, task.getComments().size());
-    assertEquals("hi, how are you?", comment.getMessage());
-  }
-
-  public void testTaskWithDefinition() {
-    TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
-    taskDefinition.setName("hello");
-    taskDefinition.setPriority(Priority.HIGH);
-    
-    TaskImpl task = TaskImpl.create(taskDefinition);
-    assertEquals("hello", task.getName());
-    assertEquals(Priority.HIGH, task.getPriority());
-    assertEquals("hello", task.getTaskDefinition().getName());
-  }
-
-  public void testSubTasks() {
-    TaskImpl improveWorld = TaskImpl.create();
-    improveWorld.setName("improve the world");
-    
-    improveWorld.createSubTask("try to automate everything");
-    improveWorld.createSubTask("discover the problem is in the workflow part");
-    Task writeWorkflowEngine = improveWorld.createSubTask("write an open source workflow engine");
-    writeWorkflowEngine.createSubTask("create a sf.net project");
-    Task commitCode = writeWorkflowEngine.createSubTask("commit code to cvs");
-    writeWorkflowEngine.createSubTask("nurture it and grow it");
-    writeWorkflowEngine.createSubTask("harvest a beautiful project");
-    
-    improveWorld.createSubTask("automate everything with workflow");
-    improveWorld.createSubTask("create peace everywhere");
-
-    Set<String> expectedSubtaskNames = new HashSet<String>();
-    expectedSubtaskNames.add("try to automate everything");
-    expectedSubtaskNames.add("discover the problem is in the workflow part");
-    expectedSubtaskNames.add("write an open source workflow engine");
-    expectedSubtaskNames.add("automate everything with workflow");
-    expectedSubtaskNames.add("create peace everywhere");
-    
-    Set<Task> subtasks = improveWorld.getSubTasks();
-    Set<String> subtaskNames = new HashSet<String>();
-    for (Task subtask: subtasks) {
-      subtaskNames.add(subtask.getName());
-    }
-    
-    assertEquals(expectedSubtaskNames, subtaskNames);
-
-    expectedSubtaskNames = new HashSet<String>();
-    expectedSubtaskNames.add("create a sf.net project");
-    expectedSubtaskNames.add("commit code to cvs");
-    expectedSubtaskNames.add("nurture it and grow it");
-    expectedSubtaskNames.add("harvest a beautiful project");
-    
-    subtasks = writeWorkflowEngine.getSubTasks();
-    subtaskNames = new HashSet<String>();
-    for (Task subtask: subtasks) {
-      subtaskNames.add(subtask.getName());
-    }
-
-    assertEquals(expectedSubtaskNames, subtaskNames);
-    
-    writeWorkflowEngine.removeSubTask(commitCode);
-    
-    expectedSubtaskNames.remove("commit code to cvs");
-
-    subtasks = writeWorkflowEngine.getSubTasks();
-    subtaskNames = new HashSet<String>();
-    for (Task subtask: subtasks) {
-      subtaskNames.add(subtask.getName());
-    }
-
-    assertEquals(expectedSubtaskNames, subtaskNames);
-  }
-  */
-}

Copied: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java (from rev 3186, jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskTest.java)
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -0,0 +1,313 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task.internal.model;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.model.RoleImpl;
+import org.jbpm.task.internal.model.SwimlaneImpl;
+import org.jbpm.task.internal.model.TaskImpl;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskTest extends JbpmTestCase {
+
+  public void testTask() {
+    Date now = new Date();
+    Date inFiveMinutes = new Date(now.getTime()+ (5*60*1000));
+
+    TaskImpl task;
+    try {
+      Clock.setCurrentTime(now);
+      task = TaskImpl.create(getName());
+    } finally {
+      Clock.setCurrentTime(null);
+    }
+    task.setName("hello");
+    task.setDescription("say hello to your neighbour developer");
+    task.setDueDate(inFiveMinutes);
+    task.setPriority(Priority.HIGHEST);
+    
+    assertEquals("hello", task.getName());
+    assertEquals("say hello to your neighbour developer", task.getDescription());
+    assertEquals(now, task.getCreate());
+    assertEquals(inFiveMinutes, task.getDueDate());
+    assertEquals(Priority.HIGHEST, task.getPriority());
+  }
+
+  public void testTaskAssignment() {
+    TaskImpl task = TaskImpl.create(getName());
+    task.setAssignee("john doe");
+    assertEquals("john doe", task.getAssignee());
+  }
+
+  public void testTaskReassignmentAssignment() {
+    TaskImpl task = TaskImpl.create(getName());
+    task.setAssignee("johndoe");
+    assertEquals("johndoe", task.getAssignee());
+    task.setAssignee("joesmoe");
+    assertEquals("joesmoe", task.getAssignee());
+  }
+
+  public void testTaskRoles() {
+    TaskImpl task = TaskImpl.create(getName());
+    
+    assertNotNull(task.getRoles());
+    assertEquals(0, task.getRoles().size());
+    
+    task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
+    task.addRole("joe smoe", Task.ROLETYPE_OWNER).setDescription("does what he wants");
+    task.addRole("jack black", Task.ROLETYPE_CANDIDATE).setDescription("can take this task");
+    task.addRole("jim slim", Task.ROLETYPE_VIEWER).setDescription("is allowed to see");
+    task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
+    
+    Set<RoleImpl> roles = task.getRoles();
+    Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
+    for (RoleImpl role: roles) {
+      roleMap.put(role.getIdentityId(), role);
+    }
+    
+    assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
+    assertEquals("uses the result", roleMap.get("john doe").getDescription());
+
+    assertEquals(Task.ROLETYPE_OWNER, roleMap.get("joe smoe").getRoleType());
+    assertEquals("does what he wants", roleMap.get("joe smoe").getDescription());
+
+    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
+    assertEquals("can take this task", roleMap.get("jack black").getDescription());
+
+    assertEquals(Task.ROLETYPE_VIEWER, roleMap.get("jim slim").getRoleType());
+    assertEquals("is allowed to see", roleMap.get("jim slim").getDescription());
+
+    assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
+    assertEquals("is sick", roleMap.get("jeff nef").getDescription());
+    
+    assertEquals(5, roles.size());
+    
+    task.removeRole(roleMap.get("john doe"));
+    assertEquals(4, task.getRoles().size());
+    task.removeRole(roleMap.get("joe smoe"));
+    assertEquals(3, task.getRoles().size());
+    task.removeRole(roleMap.get("jack black"));
+    assertEquals(2, task.getRoles().size());
+    task.removeRole(roleMap.get("jim slim"));
+    assertEquals(1, task.getRoles().size());
+    task.removeRole(roleMap.get("jeff nef"));
+    assertEquals(0, roles.size());
+  }
+
+  public void testTaskAllRoles() {
+    TaskImpl task = TaskImpl.create(getName());
+    
+    assertNotNull(task.getAllRoles());
+    assertEquals(0, task.getAllRoles().size());
+    
+    task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
+    
+    SwimlaneImpl manager = new SwimlaneImpl();
+    task.setSwimlane(manager);
+
+    manager.createCandidate("joe smoe").setDescription("tostesteron ambition");
+    manager.createCandidate("jack black").setDescription("the pigeon");
+    manager.createCandidate("jim slim").setDescription("lame duck");
+    
+    task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
+    
+    Set<RoleImpl> roles = task.getAllRoles();
+    Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
+    for (RoleImpl role: roles) {
+      roleMap.put(role.getIdentityId(), role);
+    }
+    
+    assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
+    assertEquals("uses the result", roleMap.get("john doe").getDescription());
+
+    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("joe smoe").getRoleType());
+    assertEquals("tostesteron ambition", roleMap.get("joe smoe").getDescription());
+
+    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
+    assertEquals("the pigeon", roleMap.get("jack black").getDescription());
+
+    assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jim slim").getRoleType());
+    assertEquals("lame duck", roleMap.get("jim slim").getDescription());
+
+    assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
+    assertEquals("is sick", roleMap.get("jeff nef").getDescription());
+    
+    assertEquals(5, roles.size());
+    
+    task.removeRole(roleMap.get("john doe"));
+    assertEquals(4, task.getAllRoles().size());
+    manager.removeCandidate(roleMap.get("joe smoe"));
+    assertEquals(3, task.getAllRoles().size());
+    manager.removeCandidate(roleMap.get("jack black"));
+    assertEquals(2, task.getAllRoles().size());
+    manager.removeCandidate(roleMap.get("jim slim"));
+    assertEquals(1, task.getAllRoles().size());
+    task.removeRole(roleMap.get("jeff nef"));
+    assertEquals(0, task.getAllRoles().size());
+  }
+
+  /*
+  public void testTaskComment() {
+    EnvironmentFactory environmentFactory = EnvironmentFactory.parseXmlString("<environment/>");
+    TaskImpl task = TaskImpl.create();
+    
+    Environment environment = environmentFactory.openEnvironment();
+    try {
+      environment.setUserId("john doe");
+      task.createComment("should I really do this ?  yuk.");
+    } finally {
+      environment.close();
+    }
+    
+    environment = environmentFactory.openEnvironment();
+    try {
+      environment.setUserId("joe smoe");
+      task.createComment("yes, you should really do it.");
+    } finally {
+      environment.close();
+    }
+    
+    List<Comment> comments = task.getComments();
+    assertNotNull(comments);
+    
+    assertEquals("should I really do this ?  yuk.", comments.get(0).getMessage());
+    assertEquals("john doe", comments.get(0).getUserId());
+    
+    assertEquals("yes, you should really do it.", comments.get(1).getMessage());
+    assertEquals("joe smoe", comments.get(1).getUserId());
+  }
+
+  public void testTaskCommentReplies() {
+    TaskImpl task = TaskImpl.create();
+    Comment comment = task.createComment("hi, how are you?");
+    Comment reply = comment.createReply("i'm fine, thanks");
+    reply = reply.createReply("nice wheather, huh");
+    reply.createReply("snow's great fun");
+    
+    comment = task.createComment("are you going to the office?");
+    reply = comment.createReply("no not now");
+    reply = reply.createReply("when are you going");
+    reply.createReply("later");
+    
+    List<Comment> comments = task.getComments();
+    assertEquals("hi, how are you?", comments.get(0).getMessage());
+    assertEquals("i'm fine, thanks", comments.get(0).getReplies().get(0).getMessage());
+    assertEquals("nice wheather, huh", comments.get(0).getReplies().get(0).getReplies().get(0).getMessage());
+    assertEquals("snow's great fun", comments.get(0).getReplies().get(0).getReplies().get(0).getReplies().get(0).getMessage());
+    
+    assertEquals("are you going to the office?", comments.get(1).getMessage());
+    assertEquals("no not now", comments.get(1).getReplies().get(0).getMessage());
+    assertEquals("when are you going", comments.get(1).getReplies().get(0).getReplies().get(0).getMessage());
+    assertEquals("later", comments.get(1).getReplies().get(0).getReplies().get(0).getReplies().get(0).getMessage());
+    
+    comment = task.getComments().get(0);
+    comment.removeReply(comment.getReplies().get(0));
+    
+    assertEquals("hi, how are you?", comment.getMessage());
+    assertTrue(comment.getReplies().isEmpty());
+    assertEquals(2, task.getComments().size());
+
+    task.removeComment(task.getComments().get(1));
+    
+    assertEquals(1, task.getComments().size());
+    assertEquals("hi, how are you?", comment.getMessage());
+  }
+
+  public void testTaskWithDefinition() {
+    TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
+    taskDefinition.setName("hello");
+    taskDefinition.setPriority(Priority.HIGH);
+    
+    TaskImpl task = TaskImpl.create(taskDefinition);
+    assertEquals("hello", task.getName());
+    assertEquals(Priority.HIGH, task.getPriority());
+    assertEquals("hello", task.getTaskDefinition().getName());
+  }
+
+  public void testSubTasks() {
+    TaskImpl improveWorld = TaskImpl.create();
+    improveWorld.setName("improve the world");
+    
+    improveWorld.createSubTask("try to automate everything");
+    improveWorld.createSubTask("discover the problem is in the workflow part");
+    Task writeWorkflowEngine = improveWorld.createSubTask("write an open source workflow engine");
+    writeWorkflowEngine.createSubTask("create a sf.net project");
+    Task commitCode = writeWorkflowEngine.createSubTask("commit code to cvs");
+    writeWorkflowEngine.createSubTask("nurture it and grow it");
+    writeWorkflowEngine.createSubTask("harvest a beautiful project");
+    
+    improveWorld.createSubTask("automate everything with workflow");
+    improveWorld.createSubTask("create peace everywhere");
+
+    Set<String> expectedSubtaskNames = new HashSet<String>();
+    expectedSubtaskNames.add("try to automate everything");
+    expectedSubtaskNames.add("discover the problem is in the workflow part");
+    expectedSubtaskNames.add("write an open source workflow engine");
+    expectedSubtaskNames.add("automate everything with workflow");
+    expectedSubtaskNames.add("create peace everywhere");
+    
+    Set<Task> subtasks = improveWorld.getSubTasks();
+    Set<String> subtaskNames = new HashSet<String>();
+    for (Task subtask: subtasks) {
+      subtaskNames.add(subtask.getName());
+    }
+    
+    assertEquals(expectedSubtaskNames, subtaskNames);
+
+    expectedSubtaskNames = new HashSet<String>();
+    expectedSubtaskNames.add("create a sf.net project");
+    expectedSubtaskNames.add("commit code to cvs");
+    expectedSubtaskNames.add("nurture it and grow it");
+    expectedSubtaskNames.add("harvest a beautiful project");
+    
+    subtasks = writeWorkflowEngine.getSubTasks();
+    subtaskNames = new HashSet<String>();
+    for (Task subtask: subtasks) {
+      subtaskNames.add(subtask.getName());
+    }
+
+    assertEquals(expectedSubtaskNames, subtaskNames);
+    
+    writeWorkflowEngine.removeSubTask(commitCode);
+    
+    expectedSubtaskNames.remove("commit code to cvs");
+
+    subtasks = writeWorkflowEngine.getSubTasks();
+    subtaskNames = new HashSet<String>();
+    for (Task subtask: subtasks) {
+      subtaskNames.add(subtask.getName());
+    }
+
+    assertEquals(expectedSubtaskNames, subtaskNames);
+  }
+  */
+}


Property changes on: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Modified: jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml	2008-12-05 01:28:25 UTC (rev 3210)
@@ -3,7 +3,7 @@
 <jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
 
   <process-engine>
-  
+
     <deployer-manager>
       <assign-file-type>
         <file extension=".jpdl.xml" type="jpdl" />
@@ -12,17 +12,18 @@
       <check-problems />
       <save />
     </deployer-manager>
-    
+
     <process-service />
     <execution-service />
     <management-service />
-  
+    <task-service />
+
     <command-service>
       <retry-interceptor />
       <environment-interceptor />
       <standard-transaction-interceptor />
     </command-service>
-    
+
     <hibernate-configuration>
       <properties resource="hibernate.properties" />
       <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
@@ -32,12 +33,12 @@
       <mapping resource="jbpm.pvm.variable.hbm.xml" />
       <mapping resource="jbpm.pvm.job.hbm.xml" />
       <mapping resource="jbpm.task.hbm.xml" />
-      <cache-configuration resource="jbpm.pvm.cache.xml" 
-                           usage="nonstrict-read-write" />
+      <cache-configuration resource="jbpm.pvm.cache.xml"
+        usage="nonstrict-read-write" />
     </hibernate-configuration>
-    
+
     <hibernate-session-factory />
-    
+
     <job-executor auto-start="false" />
     <job-test-helper />
 
@@ -45,14 +46,14 @@
     <variable-types resource="jbpm.pvm.types.xml" />
 
     <business-calendar>
-      <monday    hours="9:00-12:00 and 12:30-17:00"/>
-      <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
-      <wednesday hours="9:00-12:00 and 12:30-17:00"/>
-      <thursday  hours="9:00-12:00 and 12:30-17:00"/>
-      <friday    hours="9:00-12:00 and 12:30-17:00"/>
-      <holiday period="01/07/2008 - 31/08/2008"/>
+      <monday hours="9:00-12:00 and 12:30-17:00" />
+      <tuesday hours="9:00-12:00 and 12:30-17:00" />
+      <wednesday hours="9:00-12:00 and 12:30-17:00" />
+      <thursday hours="9:00-12:00 and 12:30-17:00" />
+      <friday hours="9:00-12:00 and 12:30-17:00" />
+      <holiday period="01/07/2008 - 31/08/2008" />
     </business-calendar>
-  
+
   </process-engine>
 
   <environment>
@@ -62,6 +63,7 @@
     <job-db-session />
     <message-session />
     <timer-session />
+    <task-db-session />
   </environment>
 
 </jbpm-configuration>

Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -31,8 +31,8 @@
 import org.jbpm.ProcessEngine;
 import org.jbpm.ProcessService;
 import org.jbpm.TaskService;
+import org.jbpm.task.Task;
 
-
 /**
  * @author Tom Baeyens
  */
@@ -46,8 +46,9 @@
   protected TaskService taskService;
   
   protected List<ProcessDefinition> processDefinitions;
+  protected List<Task> tasks;
 
-  public void setUp() throws Exception {
+  protected void setUp() throws Exception {
     super.setUp();
 
     initializeProcessEngine();
@@ -55,6 +56,7 @@
     processService = processEngine.getProcessService();
     executionService = processEngine.getExecutionService();
     managementService = processEngine.getManagementService();
+    taskService = processEngine.getTaskService();
   }
 
   protected synchronized void initializeProcessEngine() {
@@ -72,7 +74,7 @@
     }
   }
 
-  public void tearDown() throws Exception {
+  protected void tearDown() throws Exception {
     if (processDefinitions!=null) {
       for (ProcessDefinition processDefinition : processDefinitions) {
         processService.deleteProcessDefinitionAndInstances(processDefinition.getId());
@@ -103,4 +105,15 @@
     
     return null;
   }
+
+  public Task createTask(String taskId) {
+    Task task = taskService.newTask(taskId);
+
+    if (tasks == null) {
+      tasks = new ArrayList<Task>();
+    }
+    tasks.add(task);
+
+    return task;
+  }
 }

Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java	2008-12-04 23:15:16 UTC (rev 3209)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java	2008-12-05 01:28:25 UTC (rev 3210)
@@ -39,13 +39,13 @@
 
   static protected Log log = Log.getLog(JbpmTestCase.class.getName());
 
-  public void setUp() throws Exception {
+  protected void setUp() throws Exception {
     assertNull(Environment.getCurrent());
     LogFormatter.resetIndentation();
     log.info("=== starting "+getName()+" =============================");
   }
 
-  public void tearDown() throws Exception {
+  protected void tearDown() throws Exception {
     log.info("=== ending "+getName()+" =============================\n");
     assertNull(Environment.getCurrent());
   }
@@ -54,7 +54,7 @@
     if ( (value==null)
          || (value.indexOf(expected)==-1)
        ) {
-      throw new AssertionFailedError("expected presence of '"+expected+"' but was '"+value+"'");
+      fail("expected presence of '"+expected+"' but was '"+value+"'");
     }
   }
   




More information about the jbpm-commits mailing list