[jbpm-commits] JBoss JBPM SVN: r5256 - in jbpm4/branches/jbpm-4.0: modules/api/src/main/java/org/jbpm/api/history and 33 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jul 7 16:01:14 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-07-07 16:01:12 -0400 (Tue, 07 Jul 2009)
New Revision: 5256

Added:
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTask.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryTaskQueryCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskActivityStart.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskCreated.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskUpdated.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
Removed:
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Comment.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskHandler.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskHandlerTest.java
Modified:
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/ExecutionService.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/HistoryService.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/TaskService.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Discussable.java
   jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/task/Task.java
   jbpm4/branches/jbpm-4.0/modules/devguide/src/main/docbook/en/images/jbpm.erd.png
   jbpm4/branches/jbpm-4.0/modules/distro/src/main/files/readme.html
   jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java
   jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java
   jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
   jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
   jbpm4/branches/jbpm-4.0/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
   jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
   jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
   jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AssignTaskCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/TimerSession.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.history.hbm.xml
   jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.task.hbm.xml
   jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java
   jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/eventlistener/HqlEventListenerTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/SubTaskTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskListTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryCandidatesTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java
   jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskReassignTest.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java
   jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java
   jbpm4/branches/jbpm-4.0/qa/hudson-jbpm4-jboss.bat
Log:
JBPM-2390 fix tasks and task comments the history

Modified: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/ExecutionService.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/ExecutionService.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/ExecutionService.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -119,6 +119,10 @@
   /** end a process instance */
   void endProcessInstance(String processInstanceId, String state);
 
-  /** delete a process instance */
+  /** delete a process instance.  The history information will still be 
+   * in the database. */
   void deleteProcessInstance(String processInstanceId);
+
+  /** delete a process instance, including the history information. */
+  void deleteProcessInstanceCascade(String processInstanceId);
 }

Modified: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/HistoryService.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/HistoryService.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/HistoryService.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -25,6 +25,7 @@
 
 import org.jbpm.api.history.HistoryActivityInstanceQuery;
 import org.jbpm.api.history.HistoryProcessInstanceQuery;
+import org.jbpm.api.history.HistoryTaskQuery;
 
 
 /** exposes the history information for ongoing and past 
@@ -40,6 +41,9 @@
   /** search in history activity instance information */ 
   HistoryActivityInstanceQuery createHistoryActivityInstanceQuery();
 
+  /** search in history task information */ 
+  HistoryTaskQuery createHistoryTaskQuery();
+
   /** returns the average duration in milliseconds for each activity in the given process definition */
   Map<String, Long> avgDurationPerActivity(String processDefinitionId);
   

Modified: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/TaskService.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/TaskService.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/TaskService.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,8 +21,8 @@
  */
 package org.jbpm.api;
 
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.api.history.HistoryActivityInstance;
-import org.jbpm.api.model.Comment;
 import org.jbpm.api.task.Participation;
 import org.jbpm.api.task.Task;
 
@@ -32,7 +32,7 @@
 
 /** task management.
  * 
- * @author Tome Baeyens
+ * @author Tom Baeyens
  * @author Alejandro Guizar
  * @author Heiko Braun <heiko.braun at jboss.com>
  */
@@ -87,13 +87,18 @@
   void completeTask(String taskId, String outcome);
 
   /** Deletes the task without completing it.
+   * The history information is kept in the DB.
    * If this task was created in the context of a process execution, 
    * the execution remains active and the {@link ExecutionService#signalExecutionById(String)} 
    * is to be given explicitly. */ 
   void deleteTask(String taskId);
 
+  /** deletes this task, including all history information */
+  void deleteTaskCascade(String taskId);
+
   /** Deletes the task without completing indicating the reason.  Example reasons 
    * could be: "failed", "error", "exited", "obsolete" or "deleted".
+   * The history information is kept in the DB.
    * The reason ends up as the state in the {@link HistoryActivityInstance}. 
    * If this task was created in the context of a process execution, 
    * the execution remains active and the {@link ExecutionService#signalExecutionById(String)} 
@@ -140,15 +145,15 @@
   List<Task> getSubTasks(String taskId);
 
   /** add a comment to a task */
-  Comment addTaskComment(String taskId, String message);
+  HistoryComment addTaskComment(String taskId, String message);
 
   /** get the list of comments made to a task.  this will 
    * fetch all the comments and recursively all replies to those 
    * comments. */
-  List<Comment> getTaskComments(String taskId);
+  List<HistoryComment> getTaskComments(String taskId);
 
   /** add a reply to another comment */
-  Comment addReplyComment(String commentId, String message);
+  HistoryComment addReplyComment(String commentId, String message);
 
   /** delete a comment.
    * this will recursively delete all replies to this comment. */

Copied: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java (from rev 5254, jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryComment.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,56 @@
+/*
+ * 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.api.history;
+
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.model.Discussable;
+
+/** a free text comment that can be made to an {@link Execution} 
+ * or a task.  
+ * 
+ * This class also supports threaded discussions with the 
+ * {@link #getComments() parent-child relation}.
+ * 
+ * @author Tom Baeyens
+ */
+public interface HistoryComment extends Discussable {
+
+  /** the unique id for this comment that is used as a reference in the service methods */
+  String getId();
+
+  /** the id of the user that made this comment.  The term actorId is an abstract 
+   * reference to an entity in an external identity component. */
+  String getUserId();
+
+  /** the actual message.  Both plain text as well as HTML can be stored 
+   * as the message. */
+  String getMessage();
+
+  /** time that specifies when the comment was made */
+  Date getTime();
+  
+  /** threaded replies to this comment */
+  List<HistoryComment> getComments();
+}
\ No newline at end of file

Modified: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstanceQuery.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -41,12 +41,18 @@
   /** duration property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
   String PROPERTY_DURATION = "duration";
 
+  /** select only the process instances with the given id */
   HistoryProcessInstanceQuery processInstanceId(String processInstanceId);
+
+  /** select only process instances within the given process definition */
   HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId);
+
+  /** select only process instances in the given state */
   HistoryProcessInstanceQuery state(String state);
 
   /** order selected process instances ascending for certain {@link #PROPERTY_STARTTIME properties} */
   HistoryProcessInstanceQuery orderAsc(String property);
+
   /** order selected process instances ascending for certain {@link #PROPERTY_STARTTIME properties} */
   HistoryProcessInstanceQuery orderDesc(String property);
 

Copied: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTask.java (from rev 5254, jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTask.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTask.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTask.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,66 @@
+/*
+ * 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.api.history;
+
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.api.task.Task;
+
+
+/** history record for a task instance.  
+ * 
+ * In contrast to the {@link Task}, this entity will remain 
+ * after the task has been completed for history purposes.
+ *  
+ * @author Tom Baeyens
+ */
+public interface HistoryTask {
+
+  String STATE_COMPLETED = "completed";
+
+  /** the unique id for this task that is used as a reference in the service methods */
+  String getId();
+
+  List<? extends HistoryComment> getComments();
+
+  /** the execution that was related to this activity occurrence */
+  String getExecutionId();
+
+  /** time when the activity was entered */
+  Date getCreateTime();
+
+  /** might be null in case the activity is still active */
+  Date getEndTime();
+
+  /** duration in milleseconds */
+  long getDuration();
+
+  /** history task state */  
+  String getState();
+
+  /** userId of the person that is responsible for this task */  
+  String getAssignee();
+
+  /** the outcome of this task */
+  String getOutcome();
+}
\ No newline at end of file

Copied: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java (from rev 5254, jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,92 @@
+/*
+ * 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.api.history;
+
+import java.util.Date;
+import java.util.List;
+
+
+/** query for history tasks.
+ * 
+ * @author Tom Baeyens
+ */
+public interface HistoryTaskQuery {
+
+  /** id property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_ID = "dbid";
+  /** starttime property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_STARTTIME = "startTime";
+  /** endtime property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_ENDTIME = "endTime";
+  /** executionId property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_EXECUTIONID = "executionId";
+  /** outcome property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_OUTCOME = "outcome";
+  /** outcome property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_ASSIGNEE = "assignee";
+  /** state property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_STATE = "state";
+  /** duration property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
+  String PROPERTY_DURATION = "duration";
+
+  /** only select the history task for the given id */
+  HistoryTaskQuery taskId(String taskId);
+  
+  /** only select history tasks within the given execution */
+  HistoryTaskQuery executionId(String executionId);
+  
+  /** only select history tasks for the given assignee */
+  HistoryTaskQuery assignee(String assignee);
+
+  /** only select history tasks in the given state */
+  HistoryTaskQuery state(String state);
+
+  /** only select history tasks that have the given outcome */
+  HistoryTaskQuery outcome(String outcome);
+
+  /** order selected history tasks ascending for certain {@link #PROPERTY_ID properties} */
+  HistoryTaskQuery orderAsc(String property);
+
+  /** order selected process definitions descending for certain {@link #PROPERTY_ID properties} */
+  HistoryTaskQuery orderDesc(String property);
+
+  /** select a specific page in the result set */
+  HistoryTaskQuery page(int firstResult, int maxResults);
+
+  /** only select history tasks started after the given time */
+  HistoryTaskQuery startedAfter(Date time);
+
+  /** only select history tasks started before the given time */
+  HistoryTaskQuery startedBefore(Date time);
+
+  /** only select history tasks that took less then the given duration in milliseconds */
+  HistoryTaskQuery tookLessThen(long durationInMillis);
+
+  /** only select history tasks that took longer then the given duration in milliseconds */
+  HistoryTaskQuery tookLongerThen(long durationInMillis);
+
+  /** execute the query and obtain the list of {@link HistoryTask}s */
+  List<HistoryTask> list();
+  
+  /** execute the query and obtain the unique {@link HistoryTask} */
+  HistoryTask uniqueResult();
+}

Deleted: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Comment.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Comment.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Comment.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -1,55 +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.api.model;
-
-import java.util.Date;
-import java.util.List;
-
-import org.jbpm.api.Execution;
-
-/** a free text comment that can be made to an {@link Execution} 
- * or a task.  
- * 
- * This class also supports threaded discussions with the 
- * {@link #getComments() parent-child relation}.
- * 
- * @author Tom Baeyens
- */
-public interface Comment extends Discussable {
-
-  /** the unique id for this comment that is used as a reference in the service methods */
-  String getId();
-
-  /** the id of the user that made this comment.  The term actorId is an abstract 
-   * reference to an entity in an external identity component. */
-  String getUserId();
-
-  /** the actual message.  Both plain text as well as HTML can be stored 
-   * as the message. */
-  String getMessage();
-
-  /** time that specifies when the comment was made */
-  Date getTime();
-  
-  /** threaded replies to this comment */
-  List<Comment> getComments();
-}
\ No newline at end of file

Modified: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Discussable.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Discussable.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/model/Discussable.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.jbpm.api.TaskService;
+import org.jbpm.api.history.HistoryComment;
 
 
 /** something that people can discuss like a task 
@@ -37,11 +38,11 @@
 public interface Discussable {
 
   /** all comments. */
-  List<Comment> getComments();
+  List<HistoryComment> getComments();
   
   /** create a comment */
-  Comment createComment(String message);
+  HistoryComment createComment(String message);
   
   /** remove a comment */
-  void removeComment(Comment comment);
+  void removeComment(HistoryComment comment);
 }

Modified: jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/task/Task.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/task/Task.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/api/src/main/java/org/jbpm/api/task/Task.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -25,9 +25,13 @@
 import java.util.Date;
 
 import org.jbpm.api.TaskService;
+import org.jbpm.api.history.HistoryTask;
 
-/** a task.
+/** a runtime task.
  * 
+ * In contrast to {@link HistoryTask}, a Task only represents the runtime 
+ * state of a task and hence it will be deleted after it is completed.
+ * 
  * @author Tom Baeyens
  */
 public interface Task extends Serializable {
@@ -70,14 +74,14 @@
   void setAssignee(String assignee);
 
   /** date and time when this task was created */
-  Date getCreate();
+  Date getCreateTime();
 
   /** date and time when this task must be completed. This might be null. */
-  Date getDueDate();
+  Date getDuedate();
 
   /** update the date and time when this task must be completed.
    * Updates like this require you to invoke {@link TaskService#saveTask(Task)} afterwards. */
-  void setDueDate(Date dueDate);
+  void setDuedate(Date duedate);
 
   /** the priority of this task.  This is only a data item for user purposes.  
    * The engine doesn't do anything different for different priorities. */

Modified: jbpm4/branches/jbpm-4.0/modules/devguide/src/main/docbook/en/images/jbpm.erd.png
===================================================================
(Binary files differ)

Modified: jbpm4/branches/jbpm-4.0/modules/distro/src/main/files/readme.html
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/distro/src/main/files/readme.html	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/distro/src/main/files/readme.html	2009-07-07 20:01:12 UTC (rev 5256)
@@ -76,6 +76,8 @@
 </li>
 <li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2389'>JBPM-2389</a>] -         Reassignment is not reflected in task history
 </li>
+<li>[<a href='https://jira.jboss.org/jira/browse/JBPM-2390'>JBPM-2390</a>] -         add tasks and task comments the history
+</li>
 </ul>
         
 <h2>        Feature Request

Modified: jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/InsertCommentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -25,7 +25,7 @@
 
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
 /**
@@ -48,7 +48,7 @@
   }
 
   public Void execute(Environment environment) throws Exception {
-    CommentImpl comment = new CommentImpl();
+    HistoryCommentImpl comment = new HistoryCommentImpl();
     comment.setMessage(message);
     environment.get(DbSession.class).save(comment);
     if (fail)

Modified: jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/RemoveCommentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -28,7 +28,7 @@
 
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 
 /**
  * @author Alejandro Guizar
@@ -45,13 +45,13 @@
 
   public Boolean execute(Environment environment) throws Exception {
     Session session = environment.get(Session.class);
-    List<?> comments = session.createCriteria(CommentImpl.class)
+    List<?> comments = session.createCriteria(HistoryCommentImpl.class)
         .add(Restrictions.eq("message", message))
         .setMaxResults(1)
         .list();
     if (comments.isEmpty())
       return false;
-    CommentImpl phrase = (CommentImpl) comments.get(0);
+    HistoryCommentImpl phrase = (HistoryCommentImpl) comments.get(0);
     session.delete(phrase);
     return true;
   }

Modified: jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -67,9 +67,9 @@
   protected void tearDown() throws Exception {
     repositoryService.deleteDeploymentCascade(deploymentId);
     
-    taskService.deleteTask(taskLaundryId);
-    taskService.deleteTask(taskDishesId);
-    taskService.deleteTask(taskIronId);
+    taskService.deleteTaskCascade(taskLaundryId);
+    taskService.deleteTaskCascade(taskDishesId);
+    taskService.deleteTaskCascade(taskIronId);
     
     super.tearDown();
   }

Modified: jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/examples/src/test/java/org/jbpm/examples/sql/SqlTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -67,9 +67,9 @@
   protected void tearDown() throws Exception {
     repositoryService.deleteDeploymentCascade(deploymentId);
     
-    taskService.deleteTask(taskLaundryId);
-    taskService.deleteTask(taskDishesId);
-    taskService.deleteTask(taskIronId);
+    taskService.deleteTaskCascade(taskLaundryId);
+    taskService.deleteTaskCascade(taskDishesId);
+    taskService.deleteTaskCascade(taskIronId);
     
     super.tearDown();
   }

Modified: jbpm4/branches/jbpm-4.0/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -158,8 +158,8 @@
 
     // prio and duedate
     task.setPriority(t0.getPriority());
-    task.setDueDate(t0.getDueDate());
-    task.setCreateDate(t0.getCreate());
+    task.setDueDate(t0.getDuedate());
+    task.setCreateDate(t0.getCreateTime());
     
     // task formResourceName url
     String url = t0.getFormResourceName()!=null ? t0.getFormResourceName() : "";

Modified: jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -81,6 +81,8 @@
       inParameter.produce(executionImpl, subProcessInstance);
     }
 
+    executionImpl.historyActivityStart();
+    
     subProcessInstance.start();
     execution.waitForSignal();
   }
@@ -143,6 +145,8 @@
         environment.setContext(originalExecutionContext);
       }
     }
+    
+    executionImpl.historyActivityEnd();
 
     if (transitionName!=null) {
       execution.take(transitionName);

Modified: jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -28,12 +28,16 @@
 import org.jbpm.api.task.Task;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.events.TaskActivityStart;
 import org.jbpm.pvm.internal.model.Activity;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.model.Transition;
 import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
+import org.jbpm.pvm.internal.task.SwimlaneImpl;
 import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
-import org.jbpm.pvm.internal.task.TaskHandler;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
 
@@ -49,8 +53,47 @@
   protected TaskDefinitionImpl taskDefinition;
   
   public void execute(ActivityExecution execution) {
-    ExecutionImpl executionImpl = (ExecutionImpl) execution;
-    TaskImpl task = executionImpl.createTask(taskDefinition);
+    execute((ExecutionImpl)execution);
+  }
+
+  public void execute(ExecutionImpl execution) {
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class);
+    TaskImpl task = (TaskImpl) dbSession.createTask();
+    task.setTaskDefinition(taskDefinition);
+    task.setExecution(execution);
+    task.setProcessInstance(execution.getProcessInstance());
+    task.setSignalling(true);
+    
+    // initialize the name
+    if (taskDefinition.getName()!=null) {
+      task.setName(taskDefinition.getName());
+    } else {
+      task.setName(execution.getActivityName());
+    }
+
+    task.setDescription(taskDefinition.getDescription());
+    task.setPriority(taskDefinition.getPriority());
+    task.setFormResourceName(taskDefinition.getFormResourceName());
+    
+    // save task so that TaskDbSession.findTaskByExecution works for assign event listeners
+    dbSession.save(task);
+
+    SwimlaneDefinitionImpl swimlaneDefinition = taskDefinition.getSwimlaneDefinition();
+    if (swimlaneDefinition!=null) {
+      SwimlaneImpl swimlane = execution.getInitializedSwimlane(swimlaneDefinition);
+      task.setSwimlane(swimlane);
+      
+      // copy the swimlane assignments to the task
+      task.setAssignee(swimlane.getAssignee());
+      for (ParticipationImpl participant: swimlane.getParticipations()) {
+        task.addParticipation(participant.getUserId(), participant.getGroupId(), participant.getType());
+      }
+    }
+
+    execution.initializeAssignments(taskDefinition, task);
+    
+    HistoryEvent.fire(new TaskActivityStart(task), execution);
+
     execution.waitForSignal();
   }
   
@@ -70,8 +113,7 @@
     DbSession taskDbSession = Environment
         .getFromCurrent(DbSession.class);
     TaskImpl task = (TaskImpl) taskDbSession.findTaskByExecution(execution);
-    TaskHandler taskHandler = task.getTaskHandler();
-    taskHandler.executionSignal(task);
+    task.setSignalling(false);
     
     Transition transition = null;
     List<Transition> outgoingTransitions = activity.getOutgoingTransitions();

Modified: jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -61,7 +61,6 @@
 import org.jbpm.pvm.internal.task.AssignableDefinitionImpl;
 import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
 import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
-import org.jbpm.pvm.internal.task.TaskHandler;
 import org.jbpm.pvm.internal.util.ReflectUtil;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.wire.Descriptor;
@@ -490,13 +489,6 @@
       }
     }
     
-    Element taskHandlerElement = XmlUtil.element(element, "task-handler");
-    if (taskHandlerElement!=null) {
-      ObjectDescriptor objectDescriptor = parseObjectDescriptor(taskHandlerElement, parse);
-      TaskHandler taskHandler = (TaskHandler) WireContext.create(objectDescriptor);
-      taskDefinition.setTaskHandler(taskHandler);
-    }
-  
     JpdlParser.parseAssignmentAttributes(element, taskDefinition, parse);
     
     // parse notification mail producer

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -22,16 +22,16 @@
 package org.jbpm.pvm.internal.cmd;
 
 import org.jbpm.api.JbpmException;
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
 
 /**
  * @author Tom Baeyens
  */
-public class AddReplyCommentCmd extends AbstractCommand<Comment> {
+public class AddReplyCommentCmd extends AbstractCommand<HistoryComment> {
 
   private static final long serialVersionUID = 1L;
   
@@ -46,13 +46,13 @@
     this.message = message;
   }
 
-  public Comment execute(Environment environment) throws Exception {
+  public HistoryComment execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
-    CommentImpl parentComment = dbSession.get(CommentImpl.class, Long.parseLong(commentId));
+    HistoryCommentImpl parentComment = dbSession.get(HistoryCommentImpl.class, Long.parseLong(commentId));
     if (parentComment==null) {
       throw new JbpmException("parent comment doesn't exist: "+commentId);
     }
-    Comment replyComment = parentComment.createComment(message);
+    HistoryComment replyComment = parentComment.createComment(message);
     return replyComment;
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,16 +21,18 @@
  */
 package org.jbpm.pvm.internal.cmd;
 
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.TaskImpl;
 
 
 /**
  * @author Tom Baeyens
  */
-public class AddTaskCommentCmd extends AbstractCommand<Comment> {
+public class AddTaskCommentCmd extends AbstractCommand<HistoryComment> {
 
   private static final long serialVersionUID = 1L;
   
@@ -42,10 +44,13 @@
     this.message = message;
   }
 
-  public Comment execute(Environment environment) throws Exception {
+  public HistoryComment execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
-    TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
-    Comment comment = task.createComment(message);
+    HistoryTaskImpl historyTask = dbSession.get(HistoryTaskImpl.class, taskDbid);
+    if (historyTask==null) {
+      throw new JbpmException("task "+taskDbid+" doesn't exist");
+    }
+    HistoryCommentImpl comment = historyTask.createComment(message);
     return comment;
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AssignTaskCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AssignTaskCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AssignTaskCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -23,6 +23,8 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.events.TaskAssign;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
@@ -60,6 +62,9 @@
     } else {
       task.setAssignee(userId, true);
     }
+    
+    HistoryEvent.fire(new TaskAssign(task, userId));
+
     return null;
   }
 }

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryTaskQueryCmd.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryTaskQueryCmd.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryTaskQueryCmd.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryTaskQueryCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,39 @@
+/*
+ * 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.pvm.internal.cmd;
+
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.query.HistoryTaskQueryImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateHistoryTaskQueryCmd implements Command<HistoryTaskQueryImpl> {
+
+  private static final long serialVersionUID = 1L;
+
+  public HistoryTaskQueryImpl execute(Environment environment) throws Exception {
+    return new HistoryTaskQueryImpl();
+  }
+
+}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -23,7 +23,7 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 
 
@@ -45,7 +45,7 @@
 
   public Object execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
-    CommentImpl comment = (CommentImpl) dbSession.get(CommentImpl.class, Long.parseLong(commentId));
+    HistoryCommentImpl comment = (HistoryCommentImpl) dbSession.get(HistoryCommentImpl.class, Long.parseLong(commentId));
     if (comment!=null) {
       dbSession.delete(comment);
       

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -29,7 +29,7 @@
 import org.jbpm.api.ProcessInstance;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.repository.DeploymentImpl;
 import org.jbpm.pvm.internal.repository.RepositoryCache;
 import org.jbpm.pvm.internal.session.DbSession;
@@ -67,20 +67,18 @@
 
     for (ProcessDefinition processDefinition: processDefinitions) {
       String processDefinitionId = processDefinition.getId();
-      List<ProcessInstance> processInstances = dbSession.createProcessInstanceQuery()
-        .processDefinitionId(processDefinitionId)
-        .list();
+      List<String> processInstanceIds = dbSession.findProcessInstanceIds(processDefinitionId);
       
       if (cascade) {
-        for (ProcessInstance processInstance: processInstances) {
-          dbSession.deleteProcessInstance(processInstance.getId(), true);
+        for (String processInstanceId: processInstanceIds) {
+          dbSession.deleteProcessInstance(processInstanceId, true);
         }
 
         dbSession.deleteProcessDefinitionHistory(processDefinitionId);
         
       } else {
-        if (!processInstances.isEmpty()) {
-          throw new JbpmException("cannot delete deployment "+deploymentId+": still executions for "+processDefinition+": "+processInstances);
+        if (!processInstanceIds.isEmpty()) {
+          throw new JbpmException("cannot delete deployment "+deploymentId+": still executions for "+processDefinition+": "+processInstanceIds);
         }
       }
     }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessInstance.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -33,14 +33,20 @@
   private static final long serialVersionUID = 1L;
 
   String processInstanceId;
+  boolean cascade = false;
   
   public DeleteProcessInstance(String processInstanceId) {
     this.processInstanceId = processInstanceId;
   }
 
+  public DeleteProcessInstance(String processInstanceId, boolean cascade) {
+    this.processInstanceId = processInstanceId;
+    this.cascade = cascade;
+  }
+
   public Void execute(Environment environment) throws Exception {
     DbSession dbSession = Environment.getFromCurrent(DbSession.class);
-    dbSession.deleteProcessInstance(processInstanceId);
+    dbSession.deleteProcessInstance(processInstanceId, cascade);
     return null;
   }
 

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -23,36 +23,50 @@
 
 import org.jbpm.api.JbpmException;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
 /**
+ * @author Tom Baeyens
  * @author Alejandro Guizar
  */
 public class DeleteTaskCmd extends AbstractCommand<Void> {
 
   private static final long serialVersionUID = 1L;
 
-  protected String taskId;
+  protected long taskDbid;
   protected String reason;
+  protected boolean deleteHistory = false;
 
   public DeleteTaskCmd(String taskId) {
-    this.taskId = taskId;
+    this.taskDbid = Long.parseLong(taskId);
   }
 
   public DeleteTaskCmd(String taskId, String reason) {
-    this.taskId = taskId;
+    this.taskDbid = Long.parseLong(taskId);
     this.reason = reason;
   }
 
+  public DeleteTaskCmd(String taskId, boolean deleteHistory) {
+    this.taskDbid = Long.parseLong(taskId);
+    this.deleteHistory = deleteHistory;
+  }
+
   public Void execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
-    TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, Long.parseLong(taskId));
+    TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, taskDbid);
     if (task!=null) {
       task.delete(reason);
       dbSession.delete(task);
+      if (deleteHistory) {
+        HistoryTaskImpl historyTask = (HistoryTaskImpl) dbSession.get(HistoryTaskImpl.class, taskDbid);
+        if (historyTask!=null) {
+          dbSession.delete(historyTask);
+        }
+      }
     } else {
-      throw new JbpmException("task "+taskId+" doesn't exist");
+      throw new JbpmException("task "+taskDbid+" doesn't exist");
     }
     return null;
   }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -25,16 +25,17 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.TaskImpl;
 
 
 /**
  * @author Tom Baeyens
  */
-public class GetTaskCommentsCmd extends AbstractCommand<List<Comment>> {
+public class GetTaskCommentsCmd extends AbstractCommand<List<HistoryComment>> {
 
   private static final long serialVersionUID = 1L;
   
@@ -44,12 +45,12 @@
     this.taskId = taskId;
   }
 
-  public List<Comment> execute(Environment environment) throws Exception {
+  public List<HistoryComment> execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
-    TaskImpl task = dbSession.get(TaskImpl.class, Long.parseLong(taskId));
+    HistoryTaskImpl historyTask = dbSession.get(HistoryTaskImpl.class, Long.parseLong(taskId));
     
-    if (task != null) {
-      List<Comment> comments = task.getComments();
+    if (historyTask != null) {
+      List<HistoryComment> comments = historyTask.getComments();
       forceInitializationAndClean(comments);
       return comments;
     } else {
@@ -57,12 +58,12 @@
     }    
   }
 
-  protected void forceInitializationAndClean(List<Comment> comments) {
+  protected void forceInitializationAndClean(List<HistoryComment> comments) {
     if (comments!=null) {
       comments.size();
-      List<Comment> copy = new ArrayList<Comment>(comments);
+      List<HistoryComment> copy = new ArrayList<HistoryComment>(comments);
       for (int i=0; i<copy.size(); i++) {
-        Comment comment = copy.get(i);
+        HistoryComment comment = copy.get(i);
         
         // when comments get deleted, it's possible that we 
         // get null values in the list as the indexes of the 

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SaveTaskCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -22,10 +22,15 @@
 package org.jbpm.pvm.internal.cmd;
 
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.HistorySession;
+import org.jbpm.pvm.internal.history.events.TaskCreated;
+import org.jbpm.pvm.internal.history.events.TaskUpdated;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
 /**
+ * @author Tom Baeyens
  * @author Alejandro Guizar
  */
 public class SaveTaskCmd extends AbstractCommand<String> {
@@ -40,9 +45,24 @@
 
   public String execute(Environment environment) throws Exception {
     DbSession dbSession = environment.get(DbSession.class);
-    
-    dbSession.saveTask(task);
-    
+
+    if (task.isNew()) {
+      if (task.getSuperTaskDbid()!=null) {
+        TaskImpl parentTask = (TaskImpl) dbSession.get(TaskImpl.class, task.getSuperTaskDbid());
+        parentTask.addSubTask(task);
+        task.setSuperTaskDbid(null);
+      }
+      
+      dbSession.save(task);
+      
+      HistoryEvent.fire(new TaskCreated(task));
+
+    } else {
+      dbSession.update(task);
+
+      HistoryEvent.fire(new TaskUpdated(task));
+    }
+
     return task.getId();
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -37,8 +37,9 @@
 import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.client.ClientProcessDefinition;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.HistorySession;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
@@ -84,6 +85,10 @@
     session.save(entity);
   }
 
+  public void update(Object entity) {
+    session.update(entity);
+  }
+
   public void merge(Object entity) {
     session.merge(entity);
   }
@@ -144,7 +149,7 @@
     
     if (deleteProcessInstances) {
       for (String processInstanceId : processInstanceIds) {
-        deleteProcessInstance(processInstanceId);
+        deleteProcessInstance(processInstanceId, deleteHistory);
       }
     } else {
       if (processInstanceIds.size()>0) {
@@ -167,11 +172,6 @@
           .list();
     
     for (HistoryProcessInstanceImpl hpi: historyProcessInstances) {
-      session.createQuery(
-        "delete "+HistoryActivityInstanceImpl.class.getName()+" hai " +
-        "where hai.historyProcessInstance = :historyProcessInstance ")
-          .setEntity("historyProcessInstance", hpi)
-          .executeUpdate();
       session.delete(hpi);
     }
   }
@@ -219,7 +219,7 @@
     query.setString("processDefinitionId", processDefinitionId);
     return query.list();
   }
-
+  
   public void deleteProcessInstance(String processInstanceId) {
     deleteProcessInstance(processInstanceId, true);
   }
@@ -234,8 +234,7 @@
          && (isHistoryEnabled())
        ) {
       // try to get the history 
-      HistoryProcessInstanceImpl historyProcessInstance = (HistoryProcessInstanceImpl) 
-          session.get(HistoryProcessInstanceImpl.class, processInstanceId);
+      HistoryProcessInstanceImpl historyProcessInstance = findHistoryProcessInstanceById(processInstanceId);
   
       // if there is a history process instance in the db
       if (historyProcessInstance!=null) {
@@ -271,6 +270,15 @@
     }
   }
 
+  public HistoryProcessInstanceImpl findHistoryProcessInstanceById(String processInstanceId) {
+    return (HistoryProcessInstanceImpl) session
+      .createQuery(
+        "select hpi " +
+        "from "+HistoryProcessInstance.class.getName()+" as hpi " +
+        "where hpi.processInstanceId = '"+processInstanceId+"'"
+      ).uniqueResult();
+  }
+
   List<TaskImpl> findTasks(String processInstanceId) {
     Query query = session.createQuery(
       "select task " +
@@ -349,12 +357,14 @@
 
   public Task createTask() {
     TaskImpl task = newTask();
-    task.setCreate(Clock.getCurrentTime());
+    task.setCreateTime(Clock.getCurrentTime());
     return task;
   }
 
   protected TaskImpl newTask() {
-    return new TaskImpl();
+    TaskImpl task = new TaskImpl();
+    task.setNew(true);
+    return task;
   }
 
   public TaskImpl findTaskByDbid(long taskDbid) {
@@ -372,18 +382,6 @@
     return (Task) query.uniqueResult();
   }
   
-  public void saveTask(Task task) {
-    TaskImpl taskImpl = (TaskImpl) task;
-    
-    if (taskImpl.getSuperTaskDbid()!=null) {
-      TaskImpl parentTask = (TaskImpl) session.load(TaskImpl.class, taskImpl.getSuperTaskDbid());
-      parentTask.addSubTask(taskImpl);
-      taskImpl.setSuperTaskDbid(null);
-    }
-    
-    session.saveOrUpdate(task);
-  }
-  
   public JobImpl<?> findFirstAcquirableJob() {
     Query query = session.getNamedQuery("findFirstAcquirableJob");
     query.setTimestamp("now", Clock.getCurrentTime());

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -23,6 +23,7 @@
 
 import java.io.Serializable;
 
+import org.jbpm.pvm.internal.env.Environment;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 
 /** base class for process logs.  Process logs are dispatched to the 
@@ -46,4 +47,19 @@
   }
 
   public abstract void process();
+  
+  public static void fire(HistoryEvent historyEvent) {
+    fire(historyEvent, null);
+  }
+  
+  public static void fire(HistoryEvent historyEvent, ExecutionImpl execution) {
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      HistorySession historySession = environment.get(HistorySession.class);
+      if (historySession!=null) {
+        historyEvent.setExecution(execution);
+        historySession.process(historyEvent);
+      }
+    }
+  }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -28,8 +28,6 @@
 public class HistorySessionImpl implements HistorySession {
 
   public void process(HistoryEvent historyEvent) {
-    if (historyEvent.execution.getId()!=null) {
-      historyEvent.process();
-    }
+    historyEvent.process();
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,12 +21,12 @@
  */
 package org.jbpm.pvm.internal.history.events;
 
-import org.hibernate.Session;
 import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.pvm.internal.env.Environment;
 import org.jbpm.pvm.internal.history.HistoryEvent;
 import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
 
 
 /**
@@ -37,22 +37,22 @@
   private static final long serialVersionUID = 1L;
 
   public void process() {
-    Session session = Environment.getFromCurrent(Session.class);
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class);
 
-    String processInstanceId = execution.getProcessInstance().getId();
+    long processInstanceDbid = execution.getProcessInstance().getDbid();
 
     HistoryProcessInstance historyProcessInstanceImpl = (HistoryProcessInstance) 
-        session.load(HistoryProcessInstanceImpl.class, processInstanceId);
+        dbSession.get(HistoryProcessInstanceImpl.class, processInstanceDbid);
     
-    HistoryActivityInstanceImpl historyActivityInstanceImpl = 
+    HistoryActivityInstanceImpl historyActivityInstance = 
         createHistoryActivityInstance(historyProcessInstanceImpl);
     
     String activityType = execution.getActivity().getType();
-    historyActivityInstanceImpl.setType(activityType);
+    historyActivityInstance.setType(activityType);
     
-    session.save(historyActivityInstanceImpl);
+    dbSession.save(historyActivityInstance);
     
-    execution.setHistoryActivityInstanceDbid(historyActivityInstanceImpl.getDbid());
+    execution.setHistoryActivityInstanceDbid(historyActivityInstance.getDbid());
   }
 
   protected HistoryActivityInstanceImpl createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -37,7 +37,7 @@
   public void process() {
     Session session = Environment.getFromCurrent(Session.class);
     HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl) 
-        session.load(HistoryProcessInstanceImpl.class, execution.getId());
+        session.load(HistoryProcessInstanceImpl.class, execution.getDbid());
     historyProcessInstanceImpl.setEndTime(Clock.getCurrentTime());
     historyProcessInstanceImpl.setState(execution.getState());
     historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskActivityStart.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskActivityStart.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskActivityStart.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskActivityStart.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,72 @@
+/*
+ * 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.pvm.internal.history.events;
+
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.TaskImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskActivityStart extends HistoryEvent {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected TaskImpl task;
+  
+  public TaskActivityStart(TaskImpl task) {
+    this.task = task;
+  }
+  
+  public void process() {
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class);
+
+    ExecutionImpl processInstance = execution.getProcessInstance();
+    long processInstanceDbid = processInstance.getDbid();
+
+    HistoryProcessInstance historyProcessInstance = 
+        dbSession.get(HistoryProcessInstanceImpl.class, processInstanceDbid);
+    
+    HistoryTaskImpl historyTask = new HistoryTaskImpl(task);
+    historyTask.setExecutionId(execution.getId());
+    
+    HistoryActivityInstanceImpl historyActivityInstance = 
+        new HistoryTaskInstanceImpl(historyProcessInstance, execution, historyTask);
+    
+    String activityType = execution.getActivity().getType();
+    historyActivityInstance.setType(activityType);
+    
+    dbSession.save(historyActivityInstance);
+    
+    execution.setHistoryActivityInstanceDbid(historyActivityInstance.getDbid());
+  }
+
+}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -23,7 +23,7 @@
 
 import org.jbpm.pvm.internal.env.Environment;
 import org.jbpm.pvm.internal.history.HistoryEvent;
-import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.task.TaskImpl;
 
@@ -34,18 +34,18 @@
 
   private static final long serialVersionUID = 1L;
 
-  protected TaskImpl taskImpl;
+  protected TaskImpl task;
   protected String assignee;
 
-  public TaskAssign(TaskImpl taskImpl, String assignee) {
+  public TaskAssign(TaskImpl task, String assignee) {
+    this.task = task;
     this.assignee = assignee;
   }
 
   public void process() {
     DbSession dbSession = Environment.getFromCurrent(DbSession.class);
-    Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
-    HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) 
-        dbSession.get(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
+    HistoryTaskImpl historyTaskInstance = (HistoryTaskImpl) 
+        dbSession.get(HistoryTaskImpl.class, task.getDbid());
     historyTaskInstance.setAssignee(assignee);
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,18 +21,42 @@
  */
 package org.jbpm.pvm.internal.history.events;
 
+import org.hibernate.Session;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+import org.jbpm.pvm.internal.util.Clock;
 
 
+
 /**
  * @author Tom Baeyens
  */
-public class TaskComplete extends ActivityEnd {
+public class TaskComplete extends HistoryEvent {
 
   private static final long serialVersionUID = 1L;
   
   protected String outcome;
 
   public TaskComplete(String outcome) {
-    this.transitionName = outcome;
+    this.outcome = outcome;
   }
+
+  public void process() {
+    Session session = Environment.getFromCurrent(Session.class);
+    Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
+    HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) 
+        session.load(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId); 
+    historyTaskInstance.setEndTime(Clock.getCurrentTime());
+    historyTaskInstance.setTransitionName(outcome);
+
+    HistoryTaskImpl historyTask = historyTaskInstance.getHistoryTask();
+    historyTask.setOutcome(outcome);
+    historyTask.setEndTime(Clock.getCurrentTime());
+    historyTask.setState(HistoryTask.STATE_COMPLETED);
+
+    session.update(historyTaskInstance);
+  }
 }

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskCreated.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskCreated.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskCreated.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskCreated.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,54 @@
+/*
+ * 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.pvm.internal.history.events;
+
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.TaskImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskCreated extends HistoryEvent {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected TaskImpl task;
+
+  public TaskCreated(TaskImpl task) {
+    this.task = task;
+  }
+
+  public void process() {
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class); 
+    HistoryTaskImpl historyTask = new HistoryTaskImpl(task);
+    dbSession.save(historyTask);
+    
+    if (task.getSuperTask()!=null) {
+      HistoryTaskImpl superHistoryTask = dbSession.get(HistoryTaskImpl.class, task.getSuperTask().getDbid());
+      superHistoryTask.addSubTask(historyTask);
+    }
+  }
+}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,8 +21,14 @@
  */
 package org.jbpm.pvm.internal.history.events;
 
+import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.env.Environment;
 import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
 import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.Clock;
 
 
 /**
@@ -32,17 +38,25 @@
 
   private static final long serialVersionUID = 1L;
 
+  protected TaskImpl task;
   protected String reason;
   
-  public TaskDelete(String reason) {
+  public TaskDelete(TaskImpl task, String reason) {
+    if (task.getExecution()!=null) {
+      throw new JbpmException("tasks related to an execution must be completed. they cannot just be deleted");
+    }
+      
+    this.task = task;
     this.reason = reason;
   }
 
   protected void updateHistoryActivityInstance(HistoryActivityInstanceImpl historyActivityInstance) {
     super.updateHistoryActivityInstance(historyActivityInstance);
 
-    HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) historyActivityInstance;
-    historyTaskInstance.setState(reason);
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class);
+    HistoryTaskImpl historyTask = (HistoryTaskImpl) dbSession.get(HistoryTaskImpl.class, task.getDbid());
+    historyTask.setState(reason);
+    historyTask.setEndTime(Clock.getCurrentTime());
   }
 
   protected Class<? extends HistoryActivityInstanceImpl> getHistoryActivityInstanceClass() {

Deleted: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -1,46 +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.pvm.internal.history.events;
-
-import org.jbpm.api.history.HistoryProcessInstance;
-import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
-import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TaskStart extends ActivityStart {
-
-  private static final long serialVersionUID = 1L;
-  
-  protected String assignee;
-  
-  public TaskStart(Task task) {
-    this.assignee = task.getAssignee();
-  }
- 
-  protected HistoryActivityInstanceImpl createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
-    return new HistoryTaskInstanceImpl(historyProcessInstanceImpl, execution, assignee);
-  }
-}

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskUpdated.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskUpdated.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskUpdated.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskUpdated.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,50 @@
+/*
+ * 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.pvm.internal.history.events;
+
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.TaskImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskUpdated extends HistoryEvent {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected TaskImpl task;
+
+  public TaskUpdated(TaskImpl task) {
+    this.task = task;
+  }
+
+  public void process() {
+    DbSession dbSession = Environment.getFromCurrent(DbSession.class); 
+    HistoryTaskImpl historyTask = dbSession.get(HistoryTaskImpl.class, task.getDbid());
+    
+    historyTask.updated(task);
+  }
+}

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryCommentImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,124 @@
+/*
+ * 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.pvm.internal.history.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.history.HistoryComment;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+
+public class HistoryCommentImpl implements Serializable, HistoryComment {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String userId = null;
+  protected Date time = null;
+  protected String message = null;
+  protected List<HistoryCommentImpl> comments = new ArrayList<HistoryCommentImpl>();
+
+  public HistoryCommentImpl() {
+  }
+
+  public HistoryCommentImpl(String message) {
+    this.message = message;
+    this.time = Clock.getCurrentTime();
+    
+    Environment environment = Environment.getCurrent();
+    if (environment!=null) {
+      this.userId = environment.getUserId();
+    }
+  }
+  
+  // replies //////////////////////////////////////////////////////////////////
+  
+  public HistoryComment createComment(String message) {
+    if (message==null) {
+      throw new JbpmException("message is null");
+    }
+    HistoryCommentImpl reply = new HistoryCommentImpl(message);
+    comments.add(reply);
+    return reply;
+  }
+
+  public void removeComment(HistoryComment comment) {
+    if (comment==null) {
+      throw new JbpmException("reply is null");
+    }
+    if (comments.contains(comment)) {
+      comments.remove(comment);
+    }
+  }
+  
+  public List<HistoryComment> getComments() {
+    return (List)comments;
+  }
+  
+  
+  public void setComments(List<HistoryCommentImpl> replies) {
+    this.comments = replies;
+  }
+
+  // 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);
+  }
+
+  // cusomtized getters and setters ////////////////////////////////////////////
+
+  public String getId() {
+    return Long.toString(dbid);
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public long getDbid() {
+    return dbid;
+  }
+  public String getUserId() {
+    return userId;
+  }
+  public String getMessage() {
+    return message;
+  }
+  public Date getTime() {
+    return time;
+  }
+  public void setUserId(String userId) {
+    this.userId = userId;
+  }
+  public void setTime(Date time) {
+    this.time = time;
+  }
+  public void setMessage(String message) {
+    this.message = message;
+  }
+}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -58,9 +58,9 @@
   }
 
   public HistoryProcessInstanceImpl(ExecutionImpl processInstance) {
+    this.dbid = processInstance.getDbid();
     this.processDefinition = processInstance.getProcessDefinition();
     this.processDefinitionId = processDefinition.getId();
-    this.dbid = processInstance.getDbid();
     this.processInstanceId = processInstance.getId();
     this.key = processInstance.getKey();
     this.state = "active";

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,163 @@
+/*
+ * 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.pvm.internal.history.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.history.HistoryComment;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.internal.util.EqualsUtil;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryTaskImpl implements Serializable, HistoryTask {
+
+  private static final long serialVersionUID = 1L;
+
+  protected long dbid;
+  protected int dbversion;
+  protected String executionId;
+  protected String assignee;
+  protected String state;
+  protected String outcome;
+  protected Integer priority;
+  protected Date duedate;
+  protected Date createTime;
+  protected Date endTime;
+  protected long duration;
+  protected Set<HistoryTaskImpl> subTasks = new HashSet<HistoryTaskImpl>();
+  protected List<HistoryCommentImpl> comments = new ArrayList<HistoryCommentImpl>();
+  
+  public HistoryTaskImpl() {
+  }
+
+  public HistoryTaskImpl(TaskImpl task) {
+    this.dbid = task.getDbid();
+    this.assignee = task.getAssignee();
+    this.priority = task.getPriority();
+    this.duedate = task.getDuedate();
+    this.createTime = Clock.getCurrentTime();
+  }
+
+  public void updated(TaskImpl task) {
+    this.assignee = task.getAssignee();
+    this.priority = task.getPriority();
+    this.duedate = task.getDuedate();
+  }
+
+  // comments /////////////////////////////////////////////////////////////////
+  public List<HistoryComment> getComments() {
+    return (List)comments;
+  }
+
+  public HistoryCommentImpl createComment(String commentText) {
+    HistoryCommentImpl comment = new HistoryCommentImpl(commentText);
+    comments.add(comment);
+    return comment;
+  }
+
+  public void removeComment(HistoryCommentImpl comment) {
+    if (comment == null) {
+      throw new JbpmException("comment is null");
+    }
+    if (comments.contains(comment)) {
+      comments.remove(comment);
+    }
+  }
+
+  // subtasks /////////////////////////////////////////////////////////////////
+  
+  public Set<HistoryTask> getSubTasks() {
+    return (Set)subTasks;
+  }
+
+  public void addSubTask(HistoryTaskImpl historyTask) {
+    subTasks.add(historyTask);
+  }
+
+  // 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);
+  }
+  
+  // customized getters and setters ///////////////////////////////////////////
+  
+  public String getId() {
+    return Long.toString(dbid);
+  }
+
+  public void setEndTime(Date endTime) {
+    this.endTime = endTime;
+    this.duration = endTime.getTime() - createTime.getTime();
+  }
+
+  // getters and setters //////////////////////////////////////////////////////
+
+  public String getState() {
+    return state;
+  }
+  public String getAssignee() {
+    return assignee;
+  }
+  public String getOutcome() {
+    return outcome;
+  }
+  public void setOutcome(String outcome) {
+    this.outcome = outcome;
+  }
+  public void setAssignee(String assignee) {
+    this.assignee = assignee;
+  }
+  public Date getCreateTime() {
+    return createTime;
+  }
+  public Date getEndTime() {
+    return endTime;
+  }
+  public long getDuration() {
+    return duration;
+  }
+  public void setDuration(long duration) {
+    this.duration = duration;
+  }
+  public String getExecutionId() {
+    return executionId;
+  }
+  public void setState(String state) {
+    this.state = state;
+  }
+  public void setExecutionId(String executionId) {
+    this.executionId = executionId;
+  }
+}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -31,29 +31,18 @@
 public class HistoryTaskInstanceImpl extends HistoryActivityInstanceImpl {
 
   private static final long serialVersionUID = 1L;
-
-  protected String assignee;
-  protected String state;
   
+  HistoryTaskImpl historyTask;
+
   public HistoryTaskInstanceImpl() {
-    this.state = "active";
   }
 
-  public HistoryTaskInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution, String assignee) {
+  public HistoryTaskInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution, HistoryTaskImpl historyTask) {
     super(historyProcessInstanceImpl, execution);
-    this.assignee = assignee;
+    this.historyTask = historyTask;
   }
-  
-  public String getAssignee() {
-    return assignee;
+
+  public HistoryTaskImpl getHistoryTask() {
+    return historyTask;
   }
-  public void setAssignee(String assignee) {
-    this.assignee = assignee;
-  }
-  public String getState() {
-    return state;
-  }
-  public void setState(String state) {
-    this.state = state;
-  }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/JobImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -28,7 +28,7 @@
   protected int dbversion;
 
   /** date until which the command should not be executed
-   * for async messages, this dueDate should be set to null. */
+   * for async messages, this duedate should be set to null. */
   protected Date dueDate = null;
   
   /** job state. */

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -84,7 +84,7 @@
        ) {
       Environment environment = Environment.getCurrent();
       if (environment==null) {
-        throw new JbpmException("no environment to get business calendar for calculating dueDate "+dueDateDescription);
+        throw new JbpmException("no environment to get business calendar for calculating duedate "+dueDateDescription);
       }
       BusinessCalendar businessCalendar = environment.get(BusinessCalendar.class);
       dueDate = businessCalendar.add(now, duration);
@@ -132,7 +132,7 @@
     } else { // there is a repeat on this timer
       deleteThisJob = false;
       // suppose that it took the timer runner thread a very long time to execute the timers
-      // then the repeat action dueDate could already have passed
+      // then the repeat action duedate could already have passed
       do {
         setDueDateDescription(repeat);
       } while (dueDate.getTime() <= Clock.getCurrentTime().getTime());

Deleted: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -1,124 +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.pvm.internal.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.jbpm.api.JbpmException;
-import org.jbpm.api.model.Comment;
-import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.util.Clock;
-import org.jbpm.pvm.internal.util.EqualsUtil;
-
-public class CommentImpl implements Serializable, Comment {
-
-  private static final long serialVersionUID = 1L;
-
-  protected long dbid;
-  protected int dbversion;
-  protected String userId = null;
-  protected Date time = null;
-  protected String message = null;
-  protected List<CommentImpl> comments = new ArrayList<CommentImpl>();
-
-  public CommentImpl() {
-  }
-
-  public CommentImpl(String message) {
-    this.message = message;
-    this.time = Clock.getCurrentTime();
-    
-    Environment environment = Environment.getCurrent();
-    if (environment!=null) {
-      this.userId = environment.getUserId();
-    }
-  }
-  
-  // replies //////////////////////////////////////////////////////////////////
-  
-  public Comment createComment(String message) {
-    if (message==null) {
-      throw new JbpmException("message is null");
-    }
-    CommentImpl reply = new CommentImpl(message);
-    comments.add(reply);
-    return reply;
-  }
-
-  public void removeComment(Comment comment) {
-    if (comment==null) {
-      throw new JbpmException("reply is null");
-    }
-    if (comments.contains(comment)) {
-      comments.remove(comment);
-    }
-  }
-  
-  public List<Comment> getComments() {
-    return (List)comments;
-  }
-  
-  
-  public void setComments(List<CommentImpl> replies) {
-    this.comments = replies;
-  }
-
-  // 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);
-  }
-
-  // cusomtized getters and setters ////////////////////////////////////////////
-
-  public String getId() {
-    return Long.toString(dbid);
-  }
-
-  // getters and setters //////////////////////////////////////////////////////
-
-  public long getDbid() {
-    return dbid;
-  }
-  public String getUserId() {
-    return userId;
-  }
-  public String getMessage() {
-    return message;
-  }
-  public Date getTime() {
-    return time;
-  }
-  public void setUserId(String userId) {
-    this.userId = userId;
-  }
-  public void setTime(Date time) {
-    this.time = time;
-  }
-  public void setMessage(String message) {
-    this.message = message;
-  }
-}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -27,7 +27,6 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -41,7 +40,6 @@
 import org.jbpm.api.job.Job;
 import org.jbpm.api.job.Timer;
 import org.jbpm.api.listener.EventListenerExecution;
-import org.jbpm.api.model.Comment;
 import org.jbpm.api.model.Event;
 import org.jbpm.api.model.OpenExecution;
 import org.jbpm.api.task.Assignable;
@@ -60,6 +58,7 @@
 import org.jbpm.pvm.internal.history.events.DecisionEnd;
 import org.jbpm.pvm.internal.history.events.ProcessInstanceEnd;
 import org.jbpm.pvm.internal.history.events.ProcessInstanceStart;
+import org.jbpm.pvm.internal.history.events.TaskActivityStart;
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.model.op.AtomicOperation;
@@ -75,13 +74,10 @@
 import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
 import org.jbpm.pvm.internal.task.SwimlaneImpl;
 import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
-import org.jbpm.pvm.internal.task.TaskHandler;
 import org.jbpm.pvm.internal.task.TaskImpl;
 import org.jbpm.pvm.internal.type.Variable;
 import org.jbpm.pvm.internal.util.EqualsUtil;
 import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
  * @author Tom Baeyens
@@ -125,9 +121,6 @@
   /** swimlanes */
   protected Map<String, SwimlaneImpl> swimlanes = new HashMap<String, SwimlaneImpl>();
 
-  /** the free text comments users make on this execution */
-  protected Set<CommentImpl> comments = new LinkedHashSet<CommentImpl>();
-  
   /** reference to the current activity instance history record */
   protected Long historyActivityInstanceDbid;
   
@@ -206,7 +199,7 @@
     this.state = STATE_ACTIVE_ROOT;
     ExecutionImpl scopedExecution = initializeScopes();
     
-    fireHistoryEvent(new ProcessInstanceStart());
+    HistoryEvent.fire(new ProcessInstanceStart(), this);
     fire(Event.START, getProcessDefinition());
     if (getActivity()!=null) {
       scopedExecution.performAtomicOperation(AtomicOperation.EXECUTE_ACTIVITY);
@@ -361,7 +354,7 @@
       parent.removeExecution(this);
       
     } else { // this is a process instance
-      fireHistoryEvent(new ProcessInstanceEnd());
+      HistoryEvent.fire(new ProcessInstanceEnd(), this);
       fire(Event.END, getProcessDefinition());
 
       if (superProcessExecution!=null) {
@@ -708,49 +701,7 @@
   
   
   // tasks ////////////////////////////////////////////////////////////////////
-  
-  public TaskImpl createTask(TaskDefinitionImpl taskDefinition) {
-    DbSession dbSession = Environment.getFromCurrent(DbSession.class);
-    TaskImpl task = (TaskImpl) dbSession.createTask();
-    task.setTaskDefinition(taskDefinition);
-    task.setExecution(this);
-    task.setProcessInstance(processInstance);
-    task.setSignalling(true);
-    
-    // initialize the name
-    if (taskDefinition.getName()!=null) {
-      task.setName(taskDefinition.getName());
-    } else {
-      task.setName(getActivityName());
-    }
 
-    task.setDescription(taskDefinition.getDescription());
-    task.setPriority(taskDefinition.getPriority());
-    task.setFormResourceName(taskDefinition.getFormResourceName());
-    
-    // save task so that TaskDbSession.findTaskByExecution works for assign event listeners
-    dbSession.saveTask(task);
-
-    TaskHandler taskHandler = task.getTaskHandler();
-    boolean wait = taskHandler.executionCreateTask(task);
-    
-    SwimlaneDefinitionImpl swimlaneDefinition = taskDefinition.getSwimlaneDefinition();
-    if (swimlaneDefinition!=null) {
-      SwimlaneImpl swimlane = getInitializedSwimlane(swimlaneDefinition);
-      task.setSwimlane(swimlane);
-      
-      // copy the swimlane assignments to the task
-      task.setAssignee(swimlane.getAssignee());
-      for (ParticipationImpl participant: swimlane.getParticipations()) {
-        task.addParticipation(participant.getUserId(), participant.getGroupId(), participant.getType());
-      }
-    }
-
-    initializeAssignments(taskDefinition, task);
-    
-    return task;
-  }
-
   /** tasks and swimlane assignment.
    * SwimlaneDefinitionImpl is base class for TaskDefinitionImpl.
    * Both Task and Swimlane implement Assignable. */
@@ -844,28 +795,6 @@
     return swimlane;
   }
   
-  // comments /////////////////////////////////////////////////////////////////
-  
-  public Comment createComment(String message) {
-    if (message==null) {
-      throw new JbpmException("message is null");
-    }
-    CommentImpl comment = new CommentImpl(message);
-    addComment(comment);
-    return comment;
-  }
-  
-  public void removeComment(Comment comment) {
-    throw new UnsupportedOperationException("please implement me");
-  }
-
-  public void addComment(CommentImpl comment) {
-    if (comment==null) {
-      throw new JbpmException("comment is null");
-    }
-    comments.add(comment);
-  }
-
   // child executions /////////////////////////////////////////////////////////
 
   public ExecutionImpl createExecution() {
@@ -1105,17 +1034,6 @@
 
   ////////////////////////////////////////////////////////////////////////////////
 
-  public void fireHistoryEvent(HistoryEvent historyEvent) {
-    Environment environment = Environment.getCurrent();
-    if (environment!=null) {
-      HistorySession historySession = environment.get(HistorySession.class);
-      if (historySession!=null) {
-        historyEvent.setExecution(this);
-        historySession.process(historyEvent);
-      }
-    }
-  }
-
   // overriding the ScopeInstanceImpl methods /////////////////////////////////
   
   public ScopeInstanceImpl getParentVariableScope() {
@@ -1143,23 +1061,23 @@
   // history //////////////////////////////////////////////////////////////////
 
   public void historyAutomatic() {
-    fireHistoryEvent(new AutomaticEnd());
+    HistoryEvent.fire(new AutomaticEnd(), this);
   }
 
   public void historyDecision(String transitionName) {
-    fireHistoryEvent(new DecisionEnd(transitionName));
+    HistoryEvent.fire(new DecisionEnd(transitionName), this);
   }
   
   public void historyActivityStart() {
-    fireHistoryEvent(new ActivityStart());
+    HistoryEvent.fire(new ActivityStart(), this);
   }
 
   public void historyActivityEnd() {
-    fireHistoryEvent(new ActivityEnd());
+    HistoryEvent.fire(new ActivityEnd(), this);
   }
 
   public void historyActivityEnd(String transitionName) {
-    fireHistoryEvent(new ActivityEnd(transitionName));
+    HistoryEvent.fire(new ActivityEnd(transitionName), this);
   }
 
   // equals ///////////////////////////////////////////////////////////////////
@@ -1233,10 +1151,6 @@
     return false;
   }
 
-  public List<Comment> getComments() {
-    return new ArrayList<Comment>(comments);
-  }
-
   public boolean isProcessInstance() {
     return parent==null;
   }
@@ -1282,9 +1196,6 @@
   public void setProcessInstance(ExecutionImpl processInstance) {
     this.processInstance = processInstance;
   }
-  public void setComments(Set<CommentImpl> comments) {
-    this.comments = comments;
-  }
   public String getKey() {
     return key;
   }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -86,7 +86,7 @@
     variables.put(variable.getKey(), variable);
     hasVariables = true;
 
-    // TODO add create-variable-log
+    // TODO add createTime-variable-log
   }
 
   protected Variable createVariableObject(String key, Object value, String typeName) {

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -26,7 +26,6 @@
 import org.hibernate.Query;
 import org.jbpm.api.history.HistoryProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstanceQuery;
-import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
 
 /**
@@ -48,7 +47,7 @@
     hql.append(" as hpi ");
     
     if (processInstanceId!=null) {
-      appendWhereClause(" hpi.id = '"+processInstanceId+"' ", hql);
+      appendWhereClause(" hpi.processInstanceId = '"+processInstanceId+"' ", hql);
     }
     
     if (processDefinitionId!=null) {

Copied: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java (from rev 5254, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java)
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -0,0 +1,179 @@
+/*
+ * 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.pvm.internal.query;
+
+import java.util.Date;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.api.history.HistoryTaskQuery;
+import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryTaskQueryImpl extends AbstractQuery implements HistoryTaskQuery {
+
+  protected String taskId;
+  protected String executionId;
+  protected String assignee;
+  protected String state;
+  protected String outcome;
+  protected Long tookLessThen;
+  protected Long tookLongerThen;
+  protected Date startedBefore;
+  protected Date startedAfter;
+
+  public String hql() {
+    StringBuilder hql = new StringBuilder();
+    hql.append("select ht ");
+    hql.append("from ");
+    hql.append(HistoryTaskImpl.class.getName());
+    hql.append(" as ht ");
+    
+    if (taskId!=null) {
+      appendWhereClause(" ht.dbid = "+taskId+" ", hql);
+    }
+    
+    if (executionId!=null) {
+      appendWhereClause(" ht.executionId = '"+executionId+"' ", hql);
+    }
+    
+    if (assignee!=null) {
+      appendWhereClause(" ht.assignee = '"+assignee+"' ", hql);
+    }
+
+    if (state!=null) {
+      appendWhereClause(" ht.state = '"+state+"' ", hql);
+    }
+
+    if (outcome!=null) {
+      appendWhereClause(" ht.outcome = '"+outcome+"' ", hql);
+    }
+
+    if (tookLessThen!=null) {
+      appendWhereClause(" ht.duration < :tookLessThen ", hql);
+    }
+    
+    if (tookLongerThen!=null) {
+      appendWhereClause(" ht.duration > :tookLongerThen ", hql);
+    }
+    
+    if (startedBefore!=null) {
+      appendWhereClause(" ht.startTime < :startedBefore ", hql);
+    }
+    
+    if (startedAfter!=null) {
+      appendWhereClause(" ht.startTime > :startedAfter ", hql);
+    }
+    
+    return hql.toString();
+  }
+
+  protected void applyParameters(Query query) {
+    if (tookLessThen!=null) {
+      query.setLong("tookLessThen", tookLessThen);
+    }
+    
+    if (tookLongerThen!=null) {
+      query.setLong("tookLongerThen", tookLongerThen);
+    }
+    
+    if (startedBefore!=null) {
+      query.setTime("startedBefore", startedBefore);
+    }
+    
+    if (startedAfter!=null) {
+      query.setTime("startedAfter", startedAfter);
+    }
+  }
+
+  public List<HistoryTask> list() {
+    return (List) untypedList();
+  }
+  
+  public HistoryTask uniqueResult() {
+    return (HistoryTask) untypedUniqueResult();
+  }
+
+  public HistoryTaskQuery taskId(String taskId) {
+    this.taskId = taskId;
+    return this;
+  }
+
+  public HistoryTaskQuery executionId(String executionId) {
+    this.executionId = executionId;
+    return this;
+  }
+
+  public HistoryTaskQuery assignee(String assignee) {
+    this.assignee = assignee;
+    return this;
+  }
+
+  public HistoryTaskQuery state(String state) {
+    this.state = state;
+    return this;
+  }
+
+  public HistoryTaskQuery outcome(String outcome) {
+    this.outcome = outcome;
+    return this;
+  }
+
+  public HistoryTaskQuery orderAsc(String property) {
+    addOrderByClause("ht."+property+" asc");
+    return this;
+  }
+
+  public HistoryTaskQuery orderDesc(String property) {
+    addOrderByClause("ht."+property+" desc");
+    return this;
+  }
+
+  public HistoryTaskQuery page(int firstResult, int maxResults) {
+    this.page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public HistoryTaskQuery startedAfter(Date time) {
+    this.startedAfter = time;
+    return this;
+  }
+
+  public HistoryTaskQuery startedBefore(Date time) {
+    this.startedBefore = time;
+    return this;
+  }
+
+  public HistoryTaskQuery tookLessThen(long durationInMillis) {
+    this.tookLessThen = durationInMillis;
+    return this;
+  }
+
+  public HistoryTaskQuery tookLongerThen(long durationInMillis) {
+    this.tookLongerThen = durationInMillis;
+    return this;
+  }
+}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -27,6 +27,7 @@
 import org.jbpm.api.task.Task;
 import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
 import org.jbpm.pvm.internal.job.JobImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
@@ -43,6 +44,8 @@
 public interface DbSession {
 
   void save(Object entity);
+  void update(Object entity);
+  
   <T> T get(Class<T> entityClass, Object primaryKey);
   void delete(Object entity);
   void flush();
@@ -90,12 +93,8 @@
   /** the process instance uniquely identified by the given executionKey. */ 
   ClientExecution findProcessInstanceById(String processInstanceId);
   
-  /* find ids for all process instances for a given process definition. */
   List<String> findProcessInstanceIds(String processDefinitionId);
-
-  /** delete the process instance including the history. */
-  void deleteProcessInstance(String processInstanceId);
-
+  
   /** deletes the history information for all process instances for 
    * the given process definition */
   void deleteProcessDefinitionHistory(String processDefinitionId);
@@ -111,8 +110,6 @@
   
   Task createTask();
 
-  void saveTask(Task task);
-
   Task findTaskByExecution(Execution execution);
 
   // job methods //////////////////////////////////////////////////////////////

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/TimerSession.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/TimerSession.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/TimerSession.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -36,9 +36,9 @@
    * @param timerImpl
    *          the timer to be executed.
    * @throws IllegalArgumentException
-   *           if the timer is null or if its activity is null or if its dueDate
-   *           is null or if its dueDate is negative or if its dueDate is past
-   *           or if its dueDate is equals to Long.MAX_VALUE
+   *           if the timer is null or if its activity is null or if its duedate
+   *           is null or if its duedate is negative or if its duedate is past
+   *           or if its duedate is equals to Long.MAX_VALUE
    */
   void schedule(Timer timer);
 

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -119,6 +119,10 @@
   public void deleteProcessInstance(String processInstanceId) {
     commandService.execute(new DeleteProcessInstance(processInstanceId));
   }
+  
+  public void deleteProcessInstanceCascade(String processInstanceId) {
+    commandService.execute(new DeleteProcessInstance(processInstanceId, true));
+  }
 
   public Object getVariable(String executionId, String variableName) {
     Set<String> variableNames = new HashSet<String>();

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -26,12 +26,15 @@
 import org.jbpm.api.HistoryService;
 import org.jbpm.api.history.HistoryActivityInstanceQuery;
 import org.jbpm.api.history.HistoryProcessInstanceQuery;
+import org.jbpm.api.history.HistoryTaskQuery;
 import org.jbpm.pvm.internal.cmd.CreateHistoryActivityInstanceQueryCmd;
 import org.jbpm.pvm.internal.cmd.CreateHistoryProcessInstanceQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateHistoryTaskQueryCmd;
 import org.jbpm.pvm.internal.query.AvgDurationPerActivityQueryCmd;
 import org.jbpm.pvm.internal.query.ChoiceDistributionQueryCmd;
 import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
 import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryTaskQueryImpl;
 
 
 /**
@@ -58,4 +61,10 @@
     query.setCommandService(commandService);
     return query;
   }
+
+  public HistoryTaskQuery createHistoryTaskQuery() {
+    HistoryTaskQueryImpl query = commandService.execute(new CreateHistoryTaskQueryCmd());
+    query.setCommandService(commandService);
+    return query;
+  }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -28,7 +28,7 @@
 
 import org.jbpm.api.TaskQuery;
 import org.jbpm.api.TaskService;
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.api.task.Participation;
 import org.jbpm.api.task.Task;
 import org.jbpm.pvm.internal.cmd.AddParticipationCmd;
@@ -78,6 +78,10 @@
   public void deleteTask(String taskId, String reason) {
     commandService.execute(new DeleteTaskCmd(taskId, reason));
   }
+  
+  public void deleteTaskCascade(String taskId) {
+    commandService.execute(new DeleteTaskCmd(taskId, true));
+  }
 
   public void completeTask(String taskId) {
     completeTask(taskId, null);
@@ -136,11 +140,11 @@
     return commandService.execute(new NewTaskCmd(parentTaskId));
   }
 
-  public Comment addTaskComment(String taskId, String message) {
+  public HistoryComment addTaskComment(String taskId, String message) {
     return commandService.execute(new AddTaskCommentCmd(taskId, message));
   }
 
-  public List<Comment> getTaskComments(String taskId) {
+  public List<HistoryComment> getTaskComments(String taskId) {
     return commandService.execute(new GetTaskCommentsCmd(taskId));
   }
 
@@ -148,7 +152,7 @@
     commandService.execute(new DeleteCommentCmd(commentId));
   }
 
-  public Comment addReplyComment(String commentId, String message) {
+  public HistoryComment addReplyComment(String commentId, String message) {
     return commandService.execute(new AddReplyCommentCmd(commentId, message));
   }
 

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -39,7 +39,6 @@
   protected List<TaskDefinitionImpl> subTaskDefinitions = new ArrayList<TaskDefinitionImpl>();
   protected int priority = Priority.NORMAL;
   protected SwimlaneDefinitionImpl swimlaneDefinition;
-  protected TaskHandler taskHandler;
 
   public int getPriority() {
     return priority;
@@ -71,10 +70,4 @@
   public void setFormResourceName(String form) {
     this.formResourceName = form;
   }
-  public TaskHandler getTaskHandler() {
-    return taskHandler;
-  }
-  public void setTaskHandler(TaskHandler taskHandler) {
-    this.taskHandler = taskHandler;
-  }
 }

Deleted: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskHandler.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskHandler.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskHandler.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -1,91 +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.pvm.internal.task;
-
-import java.io.Serializable;
-
-import org.jbpm.pvm.internal.client.ClientExecution;
-
-/** for advanced task customization.
- * 
- * The default implementation can be found in {@link DefaultTaskHandler}.
- * 
- * @author Tom Baeyens
- */
-public class TaskHandler implements Serializable {
-
-  private static final long serialVersionUID = 1L;
-
-  /** called after the task is created according 
-   * to the task definition.  This method allows to 
-   * create subtasks.
-   * @return indicates if the process execution should wait. */
-  public boolean executionCreateTask(TaskImpl task) {
-    task.historyTaskStart();
-    return true;
-  }
-  
-  /** called when the related execution gets a 
-   * signal.  this method must either 
-   * {@link OpenTask#setSignalling(boolean) remove signalling} from this task
-   * or {@link OpenTask#delete(String) cancel} it. */
-  public void executionSignal(TaskImpl task) {
-    task.setSignalling(false);
-  }
-  
-  /** called when the given task is assigned to an actor. */
-  public void taskAssign(TaskImpl task, String assignee) {
-    task.historyTaskAssign(assignee);
-  }
-
-  /** called when the given task is cancelled. */ 
-  public void taskDelete(TaskImpl task, String reason) {
-    task.historyTaskDelete(reason);
-//    TODO if task is deleted, the related execution should be 
-//         suspended.  But in the API and console, there is no
-//         way yet to resume individual instances.
-//    if (task.getExecution()!=null) {
-//      task.getExecution().suspend();
-//    }
-  }
-  
-  /** called when the given task completes.  The default behaviour 
-   * will send a signal to the execution if this task is still signalling. */
-  public void taskComplete(TaskImpl task, String outcome) {
-    task.historyTaskComplete(outcome);
-    
-    if (task.isSignalling()) {
-      ClientExecution execution = (ClientExecution) task.getExecution();
-      execution.signal(outcome);
-    }
-  }
-
-  /** is called when a subtask completes.  this can be used to 
-   * prematurely signal the execution. e.g. for "5 out of 7" scenarios.*/
-  public void taskSubTaskComplete(TaskImpl task, OpenTask subTask, String outcome) {
-  }
-  
-  /** is called when a variable is updated.  This can be used to 
-   * propagate the execution based on availability of variables. */
-  public void taskVariableUpdate(TaskImpl task, String key, Object value) {
-  }
-}

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -22,27 +22,23 @@
 package org.jbpm.pvm.internal.task;
 
 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.Set;
 
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
-import org.jbpm.api.model.Comment;
 import org.jbpm.api.model.Event;
 import org.jbpm.api.task.Assignable;
 import org.jbpm.api.task.Participation;
 import org.jbpm.api.task.Swimlane;
 import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.client.ClientExecution;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.history.events.TaskAssign;
-import org.jbpm.pvm.internal.history.events.TaskDelete;
+import org.jbpm.pvm.internal.history.HistoryEvent;
 import org.jbpm.pvm.internal.history.events.TaskComplete;
-import org.jbpm.pvm.internal.history.events.TaskStart;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.events.TaskDelete;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
@@ -60,8 +56,7 @@
 
   // private static Log log = Log.getLog(TaskImpl.class.getName());
 
-  private static final TaskHandler DEFAULT_TASK_HANDLER = new TaskHandler();
-
+  protected boolean isNew;
   protected String name;
   protected String description;
 
@@ -69,14 +64,11 @@
   protected Set<ParticipationImpl> participations = new HashSet<ParticipationImpl>();
 
   protected String formResourceName;
-  protected Date create;
-  protected Date dueDate;
+  protected Date createTime;
+  protected Date duedate;
   protected Integer progress;
   protected boolean isSignalling;
 
-  // protected VariableMap variableMap;
-  protected List<CommentImpl> comments = new ArrayList<CommentImpl>();
-
   protected int priority = Priority.NORMAL;
 
   protected String state = Task.STATE_OPEN;
@@ -130,7 +122,6 @@
     }
     if (execution != null) {
       execution.fire(Event.ASSIGN, execution.getActivity());
-      getTaskHandler().taskAssign(this, assignee);
     }
   }
 
@@ -192,18 +183,23 @@
   }
 
   public void complete(String outcome) {
-    getTaskHandler().taskComplete(this, outcome);
+    historyTaskComplete(outcome);
+    
+    if (isSignalling()) {
+      ClientExecution execution = (ClientExecution) getExecution();
+      execution.signal(outcome);
+    }
+    
     if (superTask != null) {
       superTask.subTaskComplete(this, outcome);
     }
   }
 
   protected void subTaskComplete(TaskImpl subTask, String outcome) {
-    getTaskHandler().taskSubTaskComplete(this, subTask, outcome);
   }
 
   public void delete(String reason) {
-    getTaskHandler().taskDelete(this, reason);
+    historyTaskDelete(reason);
   }
 
   // state ////////////////////////////////////////////////////////////////////
@@ -218,34 +214,6 @@
     return true;
   }
 
-  // variables ////////////////////////////////////////////////////////////////
-
-  public void setVariable(String key, Object value) {
-    super.setVariable(key, value);
-    getTaskHandler().taskVariableUpdate(this, key, value);
-  }
-
-  // comments /////////////////////////////////////////////////////////////////
-
-  public List<Comment> getComments() {
-    return (List) comments;
-  }
-
-  public Comment createComment(String commentText) {
-    CommentImpl comment = new CommentImpl(commentText);
-    comments.add(comment);
-    return comment;
-  }
-
-  public void removeComment(Comment comment) {
-    if (comment == null) {
-      throw new JbpmException("comment is null");
-    }
-    if (comments.contains(comment)) {
-      comments.remove(comment);
-    }
-  }
-
   // subtasks /////////////////////////////////////////////////////////////////
 
   public Set<Task> getSubTasks() {
@@ -322,27 +290,15 @@
     }
   }
 
-  public void historyTaskStart() {
-    if (execution != null) {
-      execution.fireHistoryEvent(new TaskStart(this));
-    }
-  }
-
-  public void historyTaskAssign(String assignee) {
-    if (execution != null) {
-      execution.fireHistoryEvent(new TaskAssign(this, assignee));
-    }
-  }
-
   public void historyTaskDelete(String reason) {
     if (execution != null) {
-      execution.fireHistoryEvent(new TaskDelete(reason));
+      HistoryEvent.fire(new TaskDelete(this, reason), execution);
     }
   }
 
   public void historyTaskComplete(String outcome) {
     if (execution != null) {
-      execution.fireHistoryEvent(new TaskComplete(outcome));
+      HistoryEvent.fire(new TaskComplete(outcome), execution);
     }
   }
 
@@ -352,15 +308,6 @@
     }
   }
 
-  public TaskHandler getTaskHandler() {
-    if ((getTaskDefinition() == null) || (taskDefinition.getTaskHandler() == null)) {
-      return DEFAULT_TASK_HANDLER;
-    }
-
-    TaskHandler taskHandler = taskDefinition.getTaskHandler();
-    return taskHandler;
-  }
-
   // special getters and setters //////////////////////////////////////////////
 
   public TaskDefinitionImpl getTaskDefinition() {
@@ -415,26 +362,22 @@
     this.priority = priority;
   }
 
-  public void setComments(List<CommentImpl> comments) {
-    this.comments = comments;
+  public Date getCreateTime() {
+    return createTime;
   }
 
-  public Date getCreate() {
-    return create;
+  public void setCreateTime(Date create) {
+    this.createTime = create;
   }
 
-  public void setCreate(Date create) {
-    this.create = create;
+  public Date getDuedate() {
+    return duedate;
   }
 
-  public Date getDueDate() {
-    return dueDate;
+  public void setDuedate(Date duedate) {
+    this.duedate = duedate;
   }
 
-  public void setDueDate(Date dueDate) {
-    this.dueDate = dueDate;
-  }
-
   public ExecutionImpl getExecution() {
     return execution;
   }
@@ -534,6 +477,10 @@
   public void setFormResourceName(String form) {
     this.formResourceName = form;
   }
-
-  
+  public boolean isNew() {
+    return isNew;
+  }
+  public void setNew(boolean isNew) {
+    this.isNew = isNew;
+  }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JobTestHelper.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -35,7 +35,7 @@
 
 /** helper class for testing that executes messages and timers
  * in the test runner thread.  This way, the test can simulate 
- * timers and messages being executed.  The dueDate is ignored.
+ * timers and messages being executed.  The duedate is ignored.
  * 
  * @author Tom Baeyens
  */

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -239,9 +239,9 @@
 
   /**
    * allows for postponing the creation of this wire context.
-   * @param delayCreate specifies if creation should be postponed till {@link #create()} is called explicitly.
+   * @param delayCreate specifies if creation should be postponed till {@link #createTime()} is called explicitly.
    *   If delayCreate is set to false, creation is done as part of the constructor.  If delayCreate is
-   *   set to true, the {@link #create()} method needs to be called explicitly by the client after
+   *   set to true, the {@link #createTime()} method needs to be called explicitly by the client after
    *   construction is complete.  The use case is creation of environment where the transactionName needs to be
    *   set and the scope needs to be added to the environment before the creation of this wire scope is done.
    * @see JbpmConfiguration#openEnvironment()

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -26,7 +26,7 @@
  * <p>This {@link Descriptor} creates and initializes an object.
  * Objects can be instantiated from a constructor or from a method invocation.</p>
  *
- * <p>The way to create an object is specified one of these methods (see <a href='#create'>creating objects</a>):
+ * <p>The way to create an object is specified one of these methods (see <a href='#createTime'>creating objects</a>):
  * <ul>
  * <li>className ({@link #setClassName(String)})</li>
  * <li>factoryObjectName ({@link #setFactoryObjectName(String)})</li>
@@ -35,7 +35,7 @@
  * Only one of these methods can be used.
  * </p>
  *
- * <h3 id='create'>Creating objects</h3>
+ * <h3 id='createTime'>Creating objects</h3>
  * <h4>Creating object from a constructor</h4>
  *
  * <p>This method is used when <code>{@link #getClassName()}!=null && {@link #getMethodName()}==null</code>.</p>

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2009-07-07 20:01:12 UTC (rev 5256)
@@ -103,27 +103,6 @@
                  
   </class>
 
-  <!-- ### COMMENTS ####################################################### -->
-  <class name="CommentImpl" table="JBPM4_COMMENT">
-    <id name="dbid" column="DBID_">
-      <generator class="native" />
-    </id>
-    <discriminator column="CLASS_" />
-    <version name="dbversion" column="DBVERSION_" />
-
-    <property name="userId" column="USERID_" />
-    <property name="time" column="TIME_" />
-    <property name="message" column="MESSAGE_" type="text" />
-
-    <list name="comments" 
-          cascade="all-delete-orphan"
-          inverse="false">
-      <key column="PARENT_" foreign-key="none" />
-      <list-index column="PARENT_IDX_" />
-      <one-to-many class="CommentImpl" />
-    </list>
-  </class>
-  
   <!-- ### VARIABLE ####################################################### -->
   <class name="org.jbpm.pvm.internal.type.Variable" abstract="true" discriminator-value=" " table="JBPM4_VARIABLE">
     <!-- discriminator values:

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.history.hbm.xml
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.history.hbm.xml	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.history.hbm.xml	2009-07-07 20:01:12 UTC (rev 5256)
@@ -5,11 +5,12 @@
 
   <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
   <class name="HistoryProcessInstanceImpl" table="JBPM4_HIST_PROCINST">
-    <id name="processInstanceId" column="ID_">
+    <id name="dbid" column="DBID_">
       <generator class="assigned" />
     </id>
     <version name="dbversion" column="DBVERSION_" />
 
+    <property name="processInstanceId" column="ID_" />
     <property name="processDefinitionId" column="PROCDEFID_" />
     <property name="key" column="KEY_" />
     <property name="startTime" column="START_" type="timestamp" />
@@ -34,8 +35,8 @@
                  
   </class>
 
-  <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
-  <class name="HistoryActivityInstanceImpl" table="JBPM4_HIST_ACTINST" discriminator-value="ACT">
+  <!-- ### HISTORY ACTIVITY INSTANCE ####################################### -->
+  <class name="HistoryActivityInstanceImpl" table="JBPM4_HIST_ACTINST" discriminator-value="act">
     <id name="dbid" column="DBID_">
       <generator class="native" />
     </id>
@@ -62,14 +63,73 @@
     <property name="duration" column="DURATION_" />
     <property name="transitionName" column="TRANSITION_" />
 
-    <subclass name="HistoryAutomaticInstanceImpl" discriminator-value="AUT">
-      <subclass name="HistoryDecisionInstanceImpl" discriminator-value="EXCL" />
+    <subclass name="HistoryAutomaticInstanceImpl" discriminator-value="aut">
+      <subclass name="HistoryDecisionInstanceImpl" discriminator-value="excl" />
     </subclass>
     
-    <subclass name="HistoryTaskInstanceImpl" discriminator-value="TASK">
-      <property name="assignee" column="ASSIGNEE_" />
-      <property name="state" column="STATE_" />
+    <subclass name="HistoryTaskInstanceImpl" discriminator-value="task">
+	    <many-to-one name="historyTask" 
+	                 class="HistoryTaskImpl" 
+	                 column="HTASK_"
+	                 cascade="all"
+	                 foreign-key="FK_HTI_HTASK"
+	                 index="IDX_HTI_HTASK" />
     </subclass>
   </class>
+  
+  <!-- ### HISTORY TASK ################################################# -->
+  <class name="HistoryTaskImpl" table="JBPM4_HIST_TASK">
+    <id name="dbid" column="DBID_">
+      <generator class="assigned" />
+    </id>
+    <version name="dbversion" column="DBVERSION_" />
 
+    <!-- many-to-one name="historyTaskInstance" 
+                 class="HistoryTaskInstanceImpl" 
+                 column="HTI_"
+                 foreign-key="none"
+                 index="IDX_HTASK_HTI" / -->
+
+    <property name="executionId" column="EXECUTION_" />
+    <property name="outcome" column="OUTCOME_" />
+    <property name="assignee" column="ASSIGNEE_" />
+    <property name="state" column="STATE_" />
+    <property name="createTime" column="CREATE_" type="timestamp" />
+    <property name="endTime" column="END_" type="timestamp" />
+    <property name="duration" column="DURATION_" />
+    
+    <list name="comments" cascade="all-delete-orphan">
+      <key column="HTASK_" />
+      <list-index column="HTASK_IDX_" />
+      <one-to-many class="HistoryCommentImpl" />
+    </list>
+    
+    <set name="subTasks" cascade="all-delete-orphan">
+      <key column="SUPERTASK_" />
+      <one-to-many class="HistoryTaskImpl" />
+    </set>
+    
+  </class>
+  
+  <!-- ### HISTORY COMMENTS ################################################# -->
+  <class name="HistoryCommentImpl" table="JBPM4_HIST_COMMENT">
+    <id name="dbid" column="DBID_">
+      <generator class="native" />
+    </id>
+    <discriminator column="CLASS_" />
+    <version name="dbversion" column="DBVERSION_" />
+
+    <property name="userId" column="USERID_" />
+    <property name="time" column="TIME_" />
+    <property name="message" column="MESSAGE_" type="text" />
+
+    <list name="comments" 
+          cascade="all-delete-orphan"
+          inverse="false">
+      <key column="PARENT_" foreign-key="none" />
+      <list-index column="PARENT_IDX_" />
+      <one-to-many class="HistoryCommentImpl" />
+    </list>
+  </class>
+  
 </hibernate-mapping>
\ No newline at end of file

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.task.hbm.xml	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/main/resources/jbpm.task.hbm.xml	2009-07-07 20:01:12 UTC (rev 5256)
@@ -27,8 +27,8 @@
     </set>
     
     <property name="priority" column="PRIORITY_"/>
-    <property name="create" column="CREATE_"/>
-    <property name="dueDate" column="DUEDATE_"/>
+    <property name="createTime" column="CREATE_"/>
+    <property name="duedate" column="DUEDATE_"/>
     <property name="progress" column="PROGRESS_"/>
     <property name="isSignalling" column="SIGNALLING_"/>
     
@@ -68,12 +68,6 @@
 
     <property name="taskDefinitionName" column="TASKDEFNAME_"/>
 
-		<list name="comments" cascade="all-delete-orphan">
-			<key column="TASK_" />
-			<list-index column="TASK_IDX_" />
-			<one-to-many class="org.jbpm.pvm.internal.model.CommentImpl" />
-		</list>
-
     <set name="subTasks" cascade="all-delete-orphan">
       <key column="SUPERTASK_" />
       <one-to-many class="TaskImpl" />

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/AutoWireTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -38,7 +38,7 @@
 
   public static class PieceOfCake {
 
-    // auto-wire means that when an object like this is create,
+    // auto-wire means that when an object like this is createTime,
     // that the WireScope will try to look for objects with
     // the same name as the fields in the class.  If it finds
     // an object with that name, and if it is assignable to the

Modified: jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -31,7 +31,7 @@
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.env.Environment;
 import org.jbpm.pvm.internal.env.Transaction;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.type.variable.StringVariable;
 import org.jbpm.test.JbpmTestCase;
 
@@ -51,7 +51,7 @@
     commandService.execute(new Command<Object>() {
       public Object execute(Environment environment) {
         Session session = environment.get(Session.class);
-        session.save(new CommentImpl("if i only had the time to write code"));
+        session.save(new HistoryCommentImpl("if i only had the time to write code"));
         return null;
       }
     });
@@ -59,7 +59,7 @@
     commandService.execute(new Command<Object>() {
       public Object execute(Environment environment) {
         Session session = environment.get(Session.class);
-        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
         assertEquals("if i only had the time to write code", comments.get(0).getMessage());
         session.delete(comments.get(0));
         return null;
@@ -76,7 +76,7 @@
 
         public Object execute(Environment environment) {
           Session session = environment.get(Session.class);
-          session.save(new CommentImpl("if i only had the time to write code"));
+          session.save(new HistoryCommentImpl("if i only had the time to write code"));
           throw new MyOwnRuntimeException();
         }
       });
@@ -89,7 +89,7 @@
 
       public Object execute(Environment environment) {
         Session session = environment.get(Session.class);
-        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
         assertEquals(0, comments.size());
         return null;
       }
@@ -105,7 +105,7 @@
 
         public Object execute(Environment environment) throws Exception {
           Session session = environment.get(Session.class);
-          session.save(new CommentImpl("if i only had the time to write code"));
+          session.save(new HistoryCommentImpl("if i only had the time to write code"));
           throw new MyOwnCheckedException();
         }
       });
@@ -119,7 +119,7 @@
 
       public Object execute(Environment environment) {
         Session session = environment.get(Session.class);
-        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
         assertEquals(0, comments.size());
         return null;
       }
@@ -144,7 +144,7 @@
     commandService.execute(new Command<Object>() {
       public Object execute(Environment environment) throws Exception {
         Session session = environment.get(Session.class);
-        session.save(new CommentImpl("if i only had the time to write code"));
+        session.save(new HistoryCommentImpl("if i only had the time to write code"));
         Transaction transaction = environment.get(Transaction.class);
         SuccessfulSynchronization successfulSynchronization = new SuccessfulSynchronization();
         transaction.registerSynchronization(successfulSynchronization);
@@ -155,7 +155,7 @@
     commandService.execute(new Command<Object>() {
       public Object execute(Environment environment) {
         Session session = environment.get(Session.class);
-        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
         assertEquals("if i only had the time to write code", comments.get(0).getMessage());
         session.delete(comments.get(0));
         List<StringVariable> stringVariables = session.createQuery("from " + StringVariable.class.getName()).list();
@@ -187,7 +187,7 @@
 
         public Object execute(Environment environment) throws Exception {
           Session session = environment.get(Session.class);
-          session.save(new CommentImpl("if i only had the time to write code"));
+          session.save(new HistoryCommentImpl("if i only had the time to write code"));
           Transaction transaction = environment.get(Transaction.class);
           UnsuccessfulSynchronization unsuccessfulSynchronization = new UnsuccessfulSynchronization();
           transaction.registerSynchronization(unsuccessfulSynchronization);
@@ -207,7 +207,7 @@
 
       public Object execute(Environment environment) {
         Session session = environment.get(Session.class);
-        List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
         assertEquals(0, comments.size());
         List<StringVariable> stringVariables = session.createQuery("from " + StringVariable.class.getName()).list();
         assertEquals(0, stringVariables.size());

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/eventlistener/HqlEventListenerTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/eventlistener/HqlEventListenerTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/eventlistener/HqlEventListenerTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -35,9 +35,9 @@
   }
 
   protected void tearDown() throws Exception {
-    taskService.deleteTask(taskLaundryId);
-    taskService.deleteTask(taskDishesId);
-    taskService.deleteTask(taskIronId);
+    taskService.deleteTaskCascade(taskLaundryId);
+    taskService.deleteTaskCascade(taskDishesId);
+    taskService.deleteTaskCascade(taskIronId);
     
     super.tearDown();
   }

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/SubTaskTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/SubTaskTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/SubTaskTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -34,7 +34,7 @@
  */
 public class SubTaskTest extends JbpmTestCase {
 
-  public void testTaskParticipants() {
+  public void testSubTasks() {
     
     // create top level task
     // * clean da house
@@ -116,7 +116,7 @@
     assertEquals(expectedTaskNames, subTaskNames);
     
     // delete task dishes
-    taskService.deleteTask(dishesTaskId);
+    taskService.deleteTaskCascade(dishesTaskId);
 
     // verify all the sub tasks of 'clean da house' and 'sweep floor'
     
@@ -139,8 +139,8 @@
 
     // delete laundry and delete sweep floor
     // NOTE: deleting sweep floor should recursively delete the subtasks
-    taskService.deleteTask(laundryTaskId);
-    taskService.deleteTask(sweepFloorTaskId);
+    taskService.deleteTaskCascade(laundryTaskId);
+    taskService.deleteTaskCascade(sweepFloorTaskId);
 
     subTaskNames = getTaskNames(taskService.getSubTasks(taskId));
 
@@ -152,7 +152,7 @@
     expectedTaskNames = new HashSet<String>();
     assertEquals(expectedTaskNames, subTaskNames);
     
-    taskService.deleteTask(taskId);
+    taskService.deleteTaskCascade(taskId);
   }
 
   private Set<String> getTaskNames(List<Task> tasks) {

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCommentsTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -23,7 +23,7 @@
 
 import java.util.List;
 
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.api.task.Task;
 import org.jbpm.test.JbpmTestCase;
 
@@ -42,7 +42,7 @@
     //   - what! you had a party while i was out ?!
     //      - euh yes.  it was a great party :-)
     // i'll clean up the mess
-    Comment comment = taskService.addTaskComment(taskId, "what a party yesterday");
+    HistoryComment comment = taskService.addTaskComment(taskId, "what a party yesterday");
     String whatAPartyId = comment.getId();
     comment = taskService.addReplyComment(whatAPartyId, "what! you had a party while i was out ?!");
     String youHadAPartyId = comment.getId();
@@ -50,7 +50,7 @@
 
     taskService.addTaskComment(taskId, "i'll clean up the mess");
     
-    List<Comment> taskComments = taskService.getTaskComments(taskId);
+    List<HistoryComment> taskComments = taskService.getTaskComments(taskId);
     assertEquals("what a party yesterday", taskComments.get(0).getMessage());
     assertEquals("i'll clean up the mess", taskComments.get(1).getMessage());
     
@@ -65,13 +65,12 @@
     taskComments = taskService.getTaskComments(taskId);
     assertEquals("i'll clean up the mess", taskComments.get(0).getMessage());
     
-    // the following should delete the remaining comment.  if not, this 
-    // will show up as a fixme.
-    taskService.deleteTask(taskId);
+    // the following should delete the remaining comment.  if not, this will show up as a fixme.
+    taskService.deleteTaskCascade(taskId);
   }
-  
+
   public void testGetTaskCommentsWithUnexistingTaskId() {
-    List<Comment> comments = taskService.getTaskComments("-1234");
+    List<HistoryComment> comments = taskService.getTaskComments("-1234");
     assertTrue(comments.isEmpty());
   }
   

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -47,16 +47,16 @@
     assertNotNull("expected non-null task", task);
     // make some change
     Date dueDate = new Date();
-    task.setDueDate(dueDate);
+    task.setDuedate(dueDate);
     taskService.saveTask(task);
     // verify change is applied
     task = taskService.getTask(taskId);
     
     // task.getDueDate() return an java.sql.Timestamp
     DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
-    assertEquals(df.format(dueDate), df.format(task.getDueDate()));
+    assertEquals(df.format(dueDate), df.format(task.getDuedate()));
     
-    taskService.deleteTask(taskId);
+    taskService.deleteTaskCascade(taskId);
   }
 
   public void testDeleteTask() {
@@ -66,7 +66,7 @@
     // task was made persistent
     assertNotNull("expected non-null task", taskService.getTask(taskId));
     // delete task and verify it does not exist
-    taskService.deleteTask(taskId);
+    taskService.deleteTaskCascade(taskId);
     task = taskService.getTask(taskId);
     assertNull("expected null, but was " + task, task);
   }

Deleted: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskHandlerTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskHandlerTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskHandlerTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -1,151 +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.test.task;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.task.OpenTask;
-import org.jbpm.pvm.internal.task.TaskHandler;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TaskHandlerTest extends JbpmTestCase {
-
-  public static class ReviewHandler extends TaskHandler {
-    private static final long serialVersionUID = 1L;
-    public boolean executionCreateTask(TaskImpl task) {
-      task.getExecution().setVariable("isExecutionCreateTaskCalled", "true");
-      return super.executionCreateTask(task);
-    }
-
-    public void executionSignal(TaskImpl task) {
-      task.getExecution().setVariable("isExecutionSignalledCalled", "true");
-      super.executionSignal(task);
-    }
-
-    public void taskDelete(TaskImpl task, String reason) {
-      task.getExecution().setVariable("isTaskCancelCalled", "true");
-      super.taskDelete(task, reason);
-    }
-
-    public void taskComplete(TaskImpl task, String outcome) {
-      task.getExecution().setVariable("isTaskCompleteCalled", "true");
-      super.taskComplete(task, outcome);
-    }
-
-    public void taskSubTaskComplete(TaskImpl task, OpenTask subTask, String outcome) {
-      task.getExecution().setVariable("isSubTaskCompleteCalled", "true");
-      super.taskSubTaskComplete(task, subTask, outcome);
-    }
-
-    public void taskVariableUpdate(TaskImpl task, String key, Object value) {
-      task.getExecution().setVariable("isTaskVariableUpdateCalled", "true");
-      super.taskVariableUpdate(task, key, value);
-    }
-  }
-
-  public void testTaskHandlerBasicScenario() {
-    deployJpdlXmlString(
-      "<process name='TaskHandler'>" +
-      "  <start>" +
-      "    <transition to='review' />" +
-      "  </start>" +
-      "  <task name='review'>" +
-      "    <task-handler class='"+ReviewHandler.class.getName()+"' />" +
-      "    <transition to='wait' />" +
-      "  </task>" +
-      "  <state name='wait'/>" +
-      "</process>"
-    );
-    
-    String processInstanceId = executionService.startProcessInstanceByKey("TaskHandler").getId();
-    
-    assertEquals("true", executionService.getVariable(processInstanceId, "isExecutionCreateTaskCalled"));
-    
-    Task task = taskService.createTaskQuery().list().get(0);
-    
-    String taskId = task.getId();
-    taskService.setVariable(taskId, "checked", "true");
-    
-    assertEquals("true", executionService.getVariable(processInstanceId, "isExecutionCreateTaskCalled"));
-    
-    Task subTask = taskService.newTask(taskId);
-    String subTaskId = taskService.saveTask(subTask);
-    taskService.completeTask(subTaskId);
-    
-    assertEquals("true", executionService.getVariable(processInstanceId, "isSubTaskCompleteCalled"));
-
-    taskService.completeTask(taskId);
-
-    assertEquals("true", executionService.getVariable(processInstanceId, "isTaskCompleteCalled"));
-  }
-
-  public void testTaskHandlerCancelScenario() {
-    deployJpdlXmlString(
-      "<process name='TaskHandler'>" +
-      "  <start>" +
-      "    <transition to='review' />" +
-      "  </start>" +
-      "  <task name='review'>" +
-      "    <task-handler class='"+ReviewHandler.class.getName()+"' />" +
-      "    <transition to='wait' />" +
-      "  </task>" +
-      "  <state name='wait'/>" +
-      "</process>"
-    );
-    
-    String processInstanceId = executionService.startProcessInstanceByKey("TaskHandler").getId();
-    
-    Task task = taskService.createTaskQuery().list().get(0);
-    String taskId = task.getId();
-
-    taskService.deleteTask(taskId);
-    
-    assertEquals("true", executionService.getVariable(processInstanceId, "isTaskCancelCalled"));
-  }
-
-  public void testTaskHandlerExecutionSignalScenario() {
-    deployJpdlXmlString(
-      "<process name='TaskHandler'>" +
-      "  <start>" +
-      "    <transition to='review' />" +
-      "  </start>" +
-      "  <task name='review'>" +
-      "    <task-handler class='"+ReviewHandler.class.getName()+"' />" +
-      "    <transition to='wait' />" +
-      "  </task>" +
-      "  <state name='wait'/>" +
-      "</process>"
-    );
-    
-    Execution execution = executionService.startProcessInstanceByKey("TaskHandler");
-    String executionId = execution.getId();
-    
-    executionService.signalExecutionById(executionId);
-    
-    assertEquals("true", executionService.getVariable(executionId, "isExecutionSignalledCalled"));
-  }
-}

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskListTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskListTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskListTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -68,10 +68,10 @@
 
     assertEquals(3, taskList.size());
     
-    taskService.deleteTask(startBusinessTaskId);
-    taskService.deleteTask(capitalTaskId);
-    taskService.deleteTask(ideaTaskId);
-    taskService.deleteTask(laundryTaskId);
+    taskService.deleteTaskCascade(startBusinessTaskId);
+    taskService.deleteTaskCascade(capitalTaskId);
+    taskService.deleteTaskCascade(ideaTaskId);
+    taskService.deleteTaskCascade(laundryTaskId);
   }
 
   public void testPersonalTaskListDefaultSortOrder() {
@@ -117,10 +117,10 @@
 
     assertEquals(5, taskList.size());
 
-    taskService.deleteTask(profitTaskId);
-    taskService.deleteTask(dayOffTaskId);
-    taskService.deleteTask(startBusinessTaskId);
-    taskService.deleteTask(capitalTaskId);
-    taskService.deleteTask(ideaTaskId);
+    taskService.deleteTaskCascade(profitTaskId);
+    taskService.deleteTaskCascade(dayOffTaskId);
+    taskService.deleteTaskCascade(startBusinessTaskId);
+    taskService.deleteTaskCascade(capitalTaskId);
+    taskService.deleteTaskCascade(ideaTaskId);
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -93,7 +93,7 @@
 
     assertEquals(expectedIds, candidateGroupIds);
     
-    taskService.deleteTask(taskId);
+    taskService.deleteTaskCascade(taskId);
   }
 
   public Set<String> extractParticipatingUserIds(List<Participation> taskParticipations, String participationType) {

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryCandidatesTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryCandidatesTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryCandidatesTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -90,9 +90,9 @@
     groupTasks = taskService.findGroupTasks("jackblack");
     assertEquals(0, groupTasks.size());
     
-    taskService.deleteTask(taskId);
-    taskService.deleteTask(johnsOtherTaskId);
-    taskService.deleteTask(joesOtherTaskId);
+    taskService.deleteTaskCascade(taskId);
+    taskService.deleteTaskCascade(johnsOtherTaskId);
+    taskService.deleteTaskCascade(joesOtherTaskId);
   }
 
   public void testGroupCandidate() {
@@ -123,8 +123,8 @@
     groupTasks = taskService.findGroupTasks("jackblack");
     assertEquals(0, groupTasks.size());
     
-    taskService.deleteTask(taskId);
-    taskService.deleteTask(johnsOtherTaskId);
-    taskService.deleteTask(joesOtherTaskId);
+    taskService.deleteTaskCascade(taskId);
+    taskService.deleteTaskCascade(johnsOtherTaskId);
+    taskService.deleteTaskCascade(joesOtherTaskId);
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -69,10 +69,10 @@
 
     assertEquals(4, taskList.size());
     
-    taskService.deleteTask(capitalTaskId);
-    taskService.deleteTask(startBusinessTaskId);
-    taskService.deleteTask(dyperTaskId);
-    taskService.deleteTask(laudryTaskId);
+    taskService.deleteTaskCascade(capitalTaskId);
+    taskService.deleteTaskCascade(startBusinessTaskId);
+    taskService.deleteTaskCascade(dyperTaskId);
+    taskService.deleteTaskCascade(laudryTaskId);
   }
 
   public void testSimplestTaskQuerySortBy() {
@@ -112,9 +112,9 @@
 
     assertEquals(4, taskList.size());
 
-    taskService.deleteTask(capitalTaskId);
-    taskService.deleteTask(startBusinessTaskId);
-    taskService.deleteTask(dyperTaskId);
-    taskService.deleteTask(laudryTaskId);
+    taskService.deleteTaskCascade(capitalTaskId);
+    taskService.deleteTaskCascade(startBusinessTaskId);
+    taskService.deleteTaskCascade(dyperTaskId);
+    taskService.deleteTaskCascade(laudryTaskId);
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -41,6 +41,6 @@
     assertEquals("hello", taskService.getVariable(taskId, "text"));
     assertEquals(new Integer(5), taskService.getVariable(taskId, "number"));
     
-    taskService.deleteTask(taskId);
+    taskService.deleteTaskCascade(taskId);
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskReassignTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskReassignTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskReassignTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -24,10 +24,9 @@
 import java.util.List;
 
 import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.history.HistoryActivityInstance;
+import org.jbpm.api.history.HistoryTask;
 import org.jbpm.api.task.Task;
 import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
 import org.jbpm.test.JbpmTestCase;
 
 /**
@@ -66,12 +65,12 @@
     assertEquals("johndoe", taskService.getTask(taskId).getAssignee());
 
     taskService.completeTask(taskId);
-    List<HistoryActivityInstance> aiHistory = historyService
-      .createHistoryActivityInstanceQuery()
-      .executionId(pi.getId())
-      .list();
-    HistoryTaskInstanceImpl hai = (HistoryTaskInstanceImpl) aiHistory.get(0);
+    
+    HistoryTask historyTask = historyService
+      .createHistoryTaskQuery()
+      .taskId(taskId)
+      .uniqueResult();
 
-    assertEquals("John Doe completed the Task, but someone else got the credit", "johndoe", hai.getAssignee());
+    assertEquals("John Doe completed the Task, but someone else got the credit", "johndoe", historyTask.getAssignee());
   }
 }

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceMessageTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -26,12 +26,12 @@
 import java.util.List;
 
 import org.hibernate.Session;
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.session.MessageSession;
 
 
@@ -70,9 +70,9 @@
 
       public Object execute(Environment environment) throws Exception {
         Session session = environment.get(Session.class);
-        List<Comment> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+        List<HistoryComment> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
         
-        for (Comment comment : comments) {
+        for (HistoryComment comment : comments) {
           log.debug("retrieved message: "+comment.getMessage());
           Integer messageId = new Integer(comment.getMessage());
           assertTrue("message " + messageId + " committed twice", failOnceMessageIds.remove(messageId));

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailOnceTestCommand.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,13 +21,13 @@
  */
 package org.jbpm.test.load.async;
 
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
 import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
@@ -58,7 +58,7 @@
     DbSession dbSession = environment.get(DbSession.class);
 
     // this message execution should be rolled back
-    Comment comment = new CommentImpl(Integer.toString(messageId));
+    HistoryComment comment = new HistoryCommentImpl(Integer.toString(messageId));
     dbSession.save(comment);
 
     if (!FailOnceMessageTest.failOnceMessageIds.contains(messageId)) {

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingMessageTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -28,8 +28,8 @@
 import org.jbpm.api.job.Job;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.session.MessageSession;
 
 
@@ -65,7 +65,7 @@
         throw new JbpmException("todo get the jobs with exception");
 
 //        Session session = environment.get(Session.class);
-//        List commands = session.createQuery("from " + CommentImpl.class.getName()).list();
+//        List commands = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
 //        assertTrue("command insertion should have been rolled back", commands.isEmpty());
 //        return null;
       }

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/FailingTestCommand.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -21,11 +21,11 @@
  */
 package org.jbpm.test.load.async;
 
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
 
@@ -41,7 +41,7 @@
     DbSession dbSession = environment.get(DbSession.class);
     
     // this message execution should be rolled back
-    Comment comment = new CommentImpl("failing update");
+    HistoryComment comment = new HistoryCommentImpl("failing update");
     dbSession.save(comment);
     
     throw new RuntimeException("ooops"); 

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageCommand.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -26,8 +26,8 @@
 import org.hibernate.Session;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
 
@@ -57,7 +57,7 @@
   }
 
   public Void execute(Environment environment) throws Exception {
-    CommentImpl comment = new CommentImpl(Integer.toString(messageId));
+    HistoryCommentImpl comment = new HistoryCommentImpl(Integer.toString(messageId));
     Session session = environment.get(Session.class);
     session.save(comment);
     return null;

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/async/NormalMessageTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -25,12 +25,12 @@
 import java.util.List;
 
 import org.hibernate.Session;
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
 import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.session.MessageSession;
 import org.jbpm.test.Db;
 
@@ -67,8 +67,8 @@
       public List<Integer> execute(Environment environment) {
         List<Integer> processedMessageNumbers = new ArrayList<Integer>();
         Session session = environment.get(Session.class);
-        List<Comment> comments = session.createCriteria(CommentImpl.class).list();
-        for (Comment comment: comments) {
+        List<HistoryComment> comments = session.createCriteria(HistoryCommentImpl.class).list();
+        for (HistoryComment comment: comments) {
           int processedMessageNumber = Integer.parseInt(comment.getMessage());
           processedMessageNumbers.add(processedMessageNumber);
           // make sure the db stays clean

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/AddCommentCmd.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -24,7 +24,7 @@
 import org.hibernate.Session;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 
 /**
  * @author Tom Baeyens
@@ -36,7 +36,7 @@
   protected String message;
 
   public Void execute(Environment environment) throws Exception {
-    CommentImpl comment = new CommentImpl(message);
+    HistoryCommentImpl comment = new HistoryCommentImpl(message);
     Session session = environment.get(Session.class);
     session.save(comment);
     MessageProcessingTest.commentAdded();

Modified: jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java
===================================================================
--- jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/modules/test-load/src/test/java/org/jbpm/test/load/messages/MessageProcessingTest.java	2009-07-07 20:01:12 UTC (rev 5256)
@@ -25,15 +25,15 @@
 import java.util.List;
 
 import org.hibernate.Session;
-import org.jbpm.api.model.Comment;
+import org.jbpm.api.history.HistoryComment;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cmd.Command;
 import org.jbpm.pvm.internal.cmd.CompositeCmd;
 import org.jbpm.pvm.internal.cmd.SendMessageCmd;
 import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
 import org.jbpm.pvm.internal.job.CommandMessage;
 import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
-import org.jbpm.pvm.internal.model.CommentImpl;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
 import org.jbpm.test.load.LoadTestCase;
@@ -119,8 +119,8 @@
       public List<Integer> execute(Environment environment) {
         List<Integer> processedMessageNumbers = new ArrayList<Integer>();
         Session session = environment.get(Session.class);
-        List<Comment> comments = session.createCriteria(CommentImpl.class).list();
-        for (Comment comment: comments) {
+        List<HistoryComment> comments = session.createCriteria(HistoryCommentImpl.class).list();
+        for (HistoryComment comment: comments) {
           int processedMessageNumber = Integer.parseInt(comment.getMessage());
           processedMessageNumbers.add(processedMessageNumber);
           // make sure the db stays clean

Modified: jbpm4/branches/jbpm-4.0/qa/hudson-jbpm4-jboss.bat
===================================================================
--- jbpm4/branches/jbpm-4.0/qa/hudson-jbpm4-jboss.bat	2009-07-07 19:48:16 UTC (rev 5255)
+++ jbpm4/branches/jbpm-4.0/qa/hudson-jbpm4-jboss.bat	2009-07-07 20:01:12 UTC (rev 5256)
@@ -7,7 +7,7 @@
 
 cmd /C ant -f qa/build.xml -Djbpm.debug=true integration.testrun.setup
 
-cmd /C mvn -U -Djboss.bind.address=localhost test
+cmd /C mvn -U -Djboss.bind.address=localhost -Ddatabase=hsqldb test
 
 cmd /C ant -f qa/build.xml integration.testrun.teardown
 




More information about the jbpm-commits mailing list