[jbpm-commits] JBoss JBPM SVN: r3917 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/model and 7 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Feb 18 06:19:13 EST 2009


Author: tom.baeyens at jboss.com
Date: 2009-02-18 06:19:13 -0500 (Wed, 18 Feb 2009)
New Revision: 3917

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java
Removed:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Comment.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
   jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
Log:
JBPM-1861 adding task comments

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -23,6 +23,7 @@
 
 import java.util.List;
 
+import org.jbpm.model.Comment;
 import org.jbpm.task.GroupRef;
 import org.jbpm.task.IdentityRef;
 import org.jbpm.task.Participant;
@@ -37,9 +38,18 @@
 
   /** Creates a task.
    * The returned task will be transient.
-   * Use {@link #saveTask(Task)} to persist the task. */
+   * Use {@link #saveTask(Task)} to persist the task. Only 
+   * after the invocation of {@link #saveTask(Task)}, the 
+   * {@link Task#getDbid()} property will be initialized. */
   Task newTask();
 
+  /** Creates a new subtask for the given task.
+   * Make sure that the parent task is saved before the 
+   * {@link Task#getDbid() dbid} is taken.
+   * The returned task will be transient.
+   * Use {@link #saveTask(Task)} to persist the task. */
+  Task newTask(long parentTaskDbid);
+
   /** Saves the given task to persistent storage. */
   void saveTask(Task task);
 
@@ -101,4 +111,22 @@
    * The user id will be resolved to a set of candidate identities
    * by the identity spi. */
   List<Task> getGroupTaskList(String userId, int firstResult, int maxResults);
+
+  /** get the subtasks for this task.  Only goes one level deep at a time. */
+  List<Task> getSubTasks(long taskDbid);
+
+  /** add a comment to a task */
+  Comment addTaskComment(long taskDbid, 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(long taskDbid);
+
+  /** add a reply to another comment */
+  Comment addReplyComment(long commentDbid, String message);
+
+  /** delete a comment.
+   * this will recursively delete all replies to this comment. */
+  void deleteComment(long commentDbid);
 }

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Comment.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Comment.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/model/Comment.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -22,6 +22,7 @@
 package org.jbpm.model;
 
 import java.util.Date;
+import java.util.List;
 
 import org.jbpm.Execution;
 
@@ -49,4 +50,7 @@
 
   /** 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/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -43,7 +43,8 @@
   
   public void execute(ActivityExecution execution) {
     TaskDbSession taskDbSession = Environment.getFromCurrent(TaskDbSession.class);
-    TaskImpl task = TaskImpl.create(execution);
+    TaskImpl task = TaskImpl.create();
+    task.setExecution(execution);
     task.setName(execution.getActivityName());
     task.setAssignee(assignee);
     taskDbSession.saveTask(task);

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -1,75 +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.cmd;
-
-import org.hibernate.Session;
-import org.jbpm.JbpmException;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.task.IdentityRef;
-
-/**
- * @author Tom Baeyens
- */
-public class AddParticipant implements Command<Object> {
-  
-  private static final long serialVersionUID = 1L;
-
-  protected Long taskDbid;
-  protected Long swimlaneDbid;
-  protected IdentityRef identityRef;
-  protected String participation;
-  
-  public AddParticipant(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
-    this.taskDbid = taskDbid;
-    this.swimlaneDbid = swimlaneDbid;
-    this.identityRef = identityRef;
-    this.participation = participation;
-  }
-
-  public Object execute(Environment environment) throws Exception {
-    Session session = Environment.getFromCurrent(Session.class);
-    
-    if (taskDbid!=null) {
-      TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
-      if (task==null) {
-        throw new JbpmException("task "+taskDbid+" was not found");
-      }
-
-      task.addParticipant(identityRef, participation);
-    }
-
-    /*
-    if (swimlaneDbid!=null) {
-      SwimlaneImpl swimlane = (TaskImpl) session.get(SwimlaneImpl.class, swimlaneDbid);
-      if (swimlane==null) {
-        throw new JbpmException("swimlane "+swimlaneDbid+" was not found");
-      }
-
-      swimlane.addRole(identityType, identityId, roleName);
-    }
-    */
-
-    return null;
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java (from rev 3908, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,75 @@
+/*
+ * 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.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.IdentityRef;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddParticipantCmd implements Command<Object> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected Long taskDbid;
+  protected Long swimlaneDbid;
+  protected IdentityRef identityRef;
+  protected String participation;
+  
+  public AddParticipantCmd(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
+    this.taskDbid = taskDbid;
+    this.swimlaneDbid = swimlaneDbid;
+    this.identityRef = identityRef;
+    this.participation = participation;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Session session = Environment.getFromCurrent(Session.class);
+    
+    if (taskDbid!=null) {
+      TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
+      if (task==null) {
+        throw new JbpmException("task "+taskDbid+" was not found");
+      }
+
+      task.addParticipant(identityRef, participation);
+    }
+
+    /*
+    if (swimlaneDbid!=null) {
+      SwimlaneImpl swimlane = (TaskImpl) session.get(SwimlaneImpl.class, swimlaneDbid);
+      if (swimlane==null) {
+        throw new JbpmException("swimlane "+swimlaneDbid+" was not found");
+      }
+
+      swimlane.addRole(identityType, identityId, roleName);
+    }
+    */
+
+    return null;
+  }
+}


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

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddReplyCommentCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,52 @@
+/*
+ * 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.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddReplyCommentCmd implements Command<Comment> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long commentDbid;
+  protected String message;
+  
+  public AddReplyCommentCmd(long commentDbid, String message) {
+    this.commentDbid = commentDbid;
+    this.message = message;
+  }
+
+  public Comment execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    CommentImpl parentComment = dbSession.get(CommentImpl.class, commentDbid);
+    Comment replyComment = parentComment.createComment(message);
+    return replyComment;
+  }
+}


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

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddTaskCommentCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,52 @@
+/*
+ * 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.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddTaskCommentCmd implements Command<Comment> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  protected String message;
+  
+  public AddTaskCommentCmd(long taskDbid, String message) {
+    this.taskDbid = taskDbid;
+    this.message = message;
+  }
+
+  public Comment execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
+    Comment comment = task.createComment(message);
+    return comment;
+  }
+}


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

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteCommentCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -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.pvm.internal.cmd;
+
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteCommentCmd implements Command<Object> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected long commentDbid;
+  
+  public DeleteCommentCmd(long commentDbid) {
+    this.commentDbid = commentDbid;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    CommentImpl comment = (CommentImpl) dbSession.get(CommentImpl.class, commentDbid);
+    if (comment!=null) {
+      dbSession.delete(comment);
+      
+    } else {
+      throw new JbpmException("comment "+commentDbid+" doesn't exist");
+    }
+    return null;
+  }
+}


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

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -21,10 +21,11 @@
  */
 package org.jbpm.pvm.internal.cmd;
 
+import org.jbpm.JbpmException;
 import org.jbpm.cmd.Command;
 import org.jbpm.env.Environment;
-import org.jbpm.session.TaskDbSession;
-import org.jbpm.task.Task;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
 
 /**
  * @author Alejandro Guizar
@@ -40,10 +41,13 @@
   }
 
   public Void execute(Environment environment) throws Exception {
-    TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
-    Task task = taskDbSession.findTaskByDbid(taskDbid);
-    taskDbSession.delete(task);
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, taskDbid);
+    if (task!=null) {
+      dbSession.delete(task);
+    } else {
+      throw new JbpmException("task "+taskDbid+" doesn't exist");
+    }
     return null;
   }
-
 }

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -1,79 +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.cmd;
-
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.jbpm.JbpmException;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.task.ParticipantImpl;
-import org.jbpm.task.Participant;
-
-
-/**
- * @author Tom Baeyens
- */
-public class GetParticipants implements Command<List<Participant>> {
-  
-  private static final long serialVersionUID = 1L;
-
-  protected Long taskDbid;
-  protected Long swimlaneDbid;
-  
-  public GetParticipants(Long taskDbid, Long swimlaneDbid) {
-    this.taskDbid = taskDbid;
-    this.swimlaneDbid = swimlaneDbid;
-  }
-
-  public List<Participant> execute(Environment environment) throws Exception {
-    StringBuffer hql = new StringBuffer();
-    hql.append("select role from ");
-    hql.append(ParticipantImpl.class.getName());
-    hql.append(" as role where ");
-    
-    if (taskDbid!=null) {
-      hql.append(" role.task.dbid = :taskDbid ");
-
-    } else if (swimlaneDbid!=null) {
-      hql.append(" role.swimlane.dbid = :swimlaneDbid ");
-      
-    } else {
-      throw new JbpmException("no task nor swimlane specified");
-    }
-
-    Session session = Environment.getFromCurrent(Session.class);
-    Query query = session.createQuery(hql.toString());
-
-    if (taskDbid!=null) {
-      query.setLong("taskDbid", taskDbid);
-
-    } else if (swimlaneDbid!=null) {
-      query.setLong("swimlaneDbid", swimlaneDbid);
-    } 
-
-    List<Participant> participants = query.list();
-    return participants;
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java (from rev 3907, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,79 @@
+/*
+ * 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 java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
+import org.jbpm.task.Participant;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetParticipantsCmd implements Command<List<Participant>> {
+  
+  private static final long serialVersionUID = 1L;
+
+  protected Long taskDbid;
+  protected Long swimlaneDbid;
+  
+  public GetParticipantsCmd(Long taskDbid, Long swimlaneDbid) {
+    this.taskDbid = taskDbid;
+    this.swimlaneDbid = swimlaneDbid;
+  }
+
+  public List<Participant> execute(Environment environment) throws Exception {
+    StringBuffer hql = new StringBuffer();
+    hql.append("select role from ");
+    hql.append(ParticipantImpl.class.getName());
+    hql.append(" as role where ");
+    
+    if (taskDbid!=null) {
+      hql.append(" role.task.dbid = :taskDbid ");
+
+    } else if (swimlaneDbid!=null) {
+      hql.append(" role.swimlane.dbid = :swimlaneDbid ");
+      
+    } else {
+      throw new JbpmException("no task nor swimlane specified");
+    }
+
+    Session session = Environment.getFromCurrent(Session.class);
+    Query query = session.createQuery(hql.toString());
+
+    if (taskDbid!=null) {
+      query.setLong("taskDbid", taskDbid);
+
+    } else if (swimlaneDbid!=null) {
+      query.setLong("swimlaneDbid", swimlaneDbid);
+    } 
+
+    List<Participant> participants = query.list();
+    return participants;
+  }
+}


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

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,60 @@
+/*
+ * 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 java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetSubTasksCmd implements Command<List<Task>> {
+  
+  private static final long serialVersionUID = 1L;
+
+  long parentTaskDbid;
+  
+  public GetSubTasksCmd(long parentTaskDbid) {
+    this.parentTaskDbid = parentTaskDbid;
+  }
+
+  public List<Task> execute(Environment environment) throws Exception {
+    Session session = environment.get(Session.class);
+    
+    Query query = session.createQuery(
+      "select task " +
+      "from "+TaskImpl.class.getName()+" as task " +
+      "where task.superTask.dbid = :parentTaskDbid"
+    );
+    
+    query.setLong("parentTaskDbid", parentTaskDbid);
+    
+    return query.list();
+  }
+}


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

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCommentsCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,76 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetTaskCommentsCmd implements Command<List<Comment>> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected long taskDbid;
+  
+  public GetTaskCommentsCmd(long taskDbid) {
+    this.taskDbid = taskDbid;
+  }
+
+  public List<Comment> execute(Environment environment) throws Exception {
+    DbSession dbSession = environment.get(DbSession.class);
+    TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
+    List<Comment> comments = task.getComments();
+    forceInitializationAndClean(comments);
+    return comments;
+  }
+
+  protected void forceInitializationAndClean(List<Comment> comments) {
+    if (comments!=null) {
+      comments.size();
+      List<Comment> copy = new ArrayList<Comment>(comments);
+      for (int i=0; i<copy.size(); i++) {
+        Comment comment = copy.get(i);
+        
+        // when comments get deleted, it's possible that we 
+        // get null values in the list as the indexes of the 
+        // other comments are not upated.
+        // So if there is a null value, we can safely delete it
+        // from the persistent list and cause the indexes to 
+        // be updated
+        if (comment==null) {
+          comments.remove(i);
+        } else {
+          forceInitializationAndClean(comment.getComments());
+        }
+      }
+    }
+  }
+}


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

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/NewTaskCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -35,26 +35,31 @@
 
   private static final long serialVersionUID = 1L;
 
+  protected Long parentTaskDbid;
   protected Long executionDbid;
-  
-  public NewTaskCmd() {
-  }
 
-  public NewTaskCmd(long executionDbid) {
+  public NewTaskCmd(Long parentTaskDbid, Long executionDbid) {
+    this.parentTaskDbid = parentTaskDbid;
     this.executionDbid = executionDbid;
   }
 
   public Task execute(Environment environment) throws Exception {
     ExecutionImpl execution = null;
 
-    Session session = environment.get(Session.class);
+    TaskImpl task = TaskImpl.create();
 
     if (executionDbid!=null) {
+      Session session = environment.get(Session.class);
       execution = (ExecutionImpl) session.load(ExecutionImpl.class, executionDbid);
+      task.setExecution(execution);
     }
+
+    if (parentTaskDbid!=null) {
+      Session session = environment.get(Session.class);
+      TaskImpl parentTask = (TaskImpl) session.load(TaskImpl.class, parentTaskDbid);
+      parentTask.addSubTask(task);
+    }
     
-    Task task = TaskImpl.create(execution);
-    
     return task;
   }
 }

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -1,77 +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.cmd;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.hibernate.Session;
-import org.jbpm.JbpmException;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.task.ParticipantImpl;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.task.IdentityRef;
-
-
-/**
- * @author Tom Baeyens
- */
-public class RemoveParticipant implements Command<Object> {
-
-  private static final long serialVersionUID = 1L;
-  
-  protected Long taskDbid;
-  protected Long swimlaneDbid;
-  protected IdentityRef identityRef;
-  protected String participation;
-  
-  public RemoveParticipant(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
-    this.swimlaneDbid = swimlaneDbid;
-    this.taskDbid = taskDbid;
-    this.identityRef = identityRef;
-    this.participation = participation;
-  }
-
-  public Object execute(Environment environment) throws Exception {
-    Session session = Environment.getFromCurrent(Session.class);
-    
-    
-    if (taskDbid!=null) {
-      TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
-      if (task==null) {
-        throw new JbpmException("task "+taskDbid+" was not found");
-      }
-
-      Set<ParticipantImpl> participants = new HashSet<ParticipantImpl>(task.getParticipants());
-      for (ParticipantImpl participant : participants) {
-        if ( participant.getIdentityRef().equals(identityRef)
-             && participant.getParticipation().equals(participation)
-           ) {
-          task.removeParticipant(participant);
-        }
-      }
-    }
-    
-    return null;
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java (from rev 3908, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,77 @@
+/*
+ * 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 java.util.HashSet;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.IdentityRef;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RemoveParticipantCmd implements Command<Object> {
+
+  private static final long serialVersionUID = 1L;
+  
+  protected Long taskDbid;
+  protected Long swimlaneDbid;
+  protected IdentityRef identityRef;
+  protected String participation;
+  
+  public RemoveParticipantCmd(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
+    this.swimlaneDbid = swimlaneDbid;
+    this.taskDbid = taskDbid;
+    this.identityRef = identityRef;
+    this.participation = participation;
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    Session session = Environment.getFromCurrent(Session.class);
+    
+    
+    if (taskDbid!=null) {
+      TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
+      if (task==null) {
+        throw new JbpmException("task "+taskDbid+" was not found");
+      }
+
+      Set<ParticipantImpl> participants = new HashSet<ParticipantImpl>(task.getParticipants());
+      for (ParticipantImpl participant : participants) {
+        if ( participant.getIdentityRef().equals(identityRef)
+             && participant.getParticipation().equals(participation)
+           ) {
+          task.removeParticipant(participant);
+        }
+      }
+    }
+    
+    return null;
+  }
+}


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

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/CommentImpl.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -30,6 +30,7 @@
 import org.jbpm.JbpmException;
 import org.jbpm.env.Environment;
 import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.task.TaskImpl;
 import org.jbpm.pvm.internal.util.Clock;
 import org.jbpm.pvm.internal.util.EqualsUtil;
 
@@ -42,7 +43,6 @@
   protected String userId = null;
   protected Date time = null;
   protected String message = null;
-  protected CommentImpl parent;
   protected List<CommentImpl> comments = null;
 
   public CommentImpl() {
@@ -77,18 +77,10 @@
       throw new JbpmException("reply is null");
     }
     if (comments!=null) {
-      if (comments.remove(comment)) {
-        ((CommentImpl)comment).setParent(null);
-      }
+      comments.remove(comment);
     }
   }
   
-  public Comment getParent() {
-    return parent;
-  }
-  public void setParent(CommentImpl parent) {
-    this.parent = parent;
-  }
   public List<Comment> getComments() {
     if (comments==null) {
       return Collections.EMPTY_LIST;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -87,10 +87,6 @@
   // creating a task
 
   public static TaskImpl create() {
-    return create(null);
-  }
-
-  public static TaskImpl create(Execution execution) {
     TaskImpl task = new TaskImpl();
 
     /*
@@ -110,8 +106,7 @@
     */
 
     task.setCreate(Clock.getCurrentTime());
-    task.setExecution(execution);
-    
+
     // initialise the task state
     task.state = LifeCycle.initialise(task); 
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -26,12 +26,18 @@
 import org.jbpm.TaskQuery;
 import org.jbpm.TaskService;
 import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.AddParticipant;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cmd.AddParticipantCmd;
+import org.jbpm.pvm.internal.cmd.AddReplyCommentCmd;
+import org.jbpm.pvm.internal.cmd.AddTaskCommentCmd;
+import org.jbpm.pvm.internal.cmd.DeleteCommentCmd;
 import org.jbpm.pvm.internal.cmd.DeleteTaskCmd;
-import org.jbpm.pvm.internal.cmd.GetParticipants;
+import org.jbpm.pvm.internal.cmd.GetParticipantsCmd;
+import org.jbpm.pvm.internal.cmd.GetSubTasksCmd;
 import org.jbpm.pvm.internal.cmd.GetTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetTaskCommentsCmd;
 import org.jbpm.pvm.internal.cmd.NewTaskCmd;
-import org.jbpm.pvm.internal.cmd.RemoveParticipant;
+import org.jbpm.pvm.internal.cmd.RemoveParticipantCmd;
 import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
 import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
 import org.jbpm.task.IdentityRef;
@@ -61,7 +67,7 @@
   }
 
   public Task newTask() {
-    return commandService.execute(new NewTaskCmd());
+    return commandService.execute(new NewTaskCmd(null, null));
   }
 
   public Task getTask(long taskDbid) {
@@ -85,27 +91,27 @@
   }
 
   public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
-    commandService.execute(new AddParticipant(taskDbid, null, identityRef, participation));
+    commandService.execute(new AddParticipantCmd(taskDbid, null, identityRef, participation));
   }
 
   public List<Participant> getTaskParticipants(long taskDbid) {
-    return commandService.execute(new GetParticipants(taskDbid, null));
+    return commandService.execute(new GetParticipantsCmd(taskDbid, null));
   }
 
   public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
-    commandService.execute(new RemoveParticipant(taskDbid, null, identityRef, participation));
+    commandService.execute(new RemoveParticipantCmd(taskDbid, null, identityRef, participation));
   }
 
   public void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
-    commandService.execute(new AddParticipant(null, szimlaneDbid, identityRef, participation));
+    commandService.execute(new AddParticipantCmd(null, szimlaneDbid, identityRef, participation));
   }
 
   public List<Participant> getSwimlaneParticipants(long szimlaneDbid) {
-    return commandService.execute(new GetParticipants(null, szimlaneDbid));
+    return commandService.execute(new GetParticipantsCmd(null, szimlaneDbid));
   }
 
   public void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
-    commandService.execute(new RemoveParticipant(null, szimlaneDbid, identityRef, participation));
+    commandService.execute(new RemoveParticipantCmd(null, szimlaneDbid, identityRef, participation));
   }
 
   public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
@@ -123,4 +129,28 @@
   public TaskQuery createTaskQuery() {
     return new TaskQueryImpl(commandService);
   }
+
+  public List<Task> getSubTasks(long taskDbid) {
+    return commandService.execute(new GetSubTasksCmd(taskDbid));
+  }
+
+  public Task newTask(long parentTaskDbid) {
+    return commandService.execute(new NewTaskCmd(parentTaskDbid, null));
+  }
+
+  public Comment addTaskComment(long taskDbid, String message) {
+    return commandService.execute(new AddTaskCommentCmd(taskDbid, message));
+  }
+
+  public List<Comment> getTaskComments(long taskDbid) {
+    return commandService.execute(new GetTaskCommentsCmd(taskDbid));
+  }
+
+  public void deleteComment(long commentDbid) {
+    commandService.execute(new DeleteCommentCmd(commentDbid));
+  }
+
+  public Comment addReplyComment(long commentDbid, String message) {
+    return commandService.execute(new AddReplyCommentCmd(commentDbid, message));
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml	2009-02-18 11:19:13 UTC (rev 3917)
@@ -99,12 +99,6 @@
     <property name="time" column="TIME_" />
     <property name="message" column="MESSAGE_" />
 
-    <many-to-one name="parent"
-                 column="PARENT_"
-                 class="CommentImpl" 
-                 foreign-key="FK_COMMENT_PARENT" 
-                 index="IDX_COMMENT_PARENT" />
-                 
     <list name="comments" 
           cascade="all-delete-orphan"
           inverse="false">

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml	2009-02-18 11:19:13 UTC (rev 3917)
@@ -75,6 +75,12 @@
                  cascade="all" />
     -->
 
+    <many-to-one name="superTask"
+                 class="TaskImpl" 
+                 column="SUPERTASK_" 
+                 foreign-key="FK_TASK_SUPERTASK" 
+                 index="IDX_TASK_SUPERTASK" />
+
     <many-to-one name="execution"
                  class="org.jbpm.pvm.internal.model.ExecutionImpl" 
                  column="EXECUTION_" 
@@ -92,7 +98,7 @@
 		</list>
 
     <set name="subTasks" cascade="all-delete-orphan">
-      <key column="SUPERTASK_" foreign-key="FK_TASK_SUPERTASK" />
+      <key column="SUPERTASK_" />
       <one-to-many class="TaskImpl" />
     </set>
     

Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -85,7 +85,9 @@
       log.error("");
       throw e;
     } catch (Throwable t) {
-      t.printStackTrace();
+      log.error("");
+      log.error("TEST THROWS EXCEPTION: "+t.getMessage(), t);
+      log.error("");
       throw t;
     }
   }

Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/SubTaskTest.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,167 @@
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubTaskTest extends JbpmTestCase {
+
+  public void testTaskParticipants() {
+    
+    // create top level task
+    // * clean da house
+    
+    Task task = taskService.newTask();
+    task.setName("clean da house");
+    saveAndRegisterTask(task);
+    long taskDbid = task.getDbid();
+    
+    // create 3 sub tasks: 
+    // * clean da house
+    //   * dishes
+    //   * laundry
+    //   * sweep floor
+    
+    Task subTask = taskService.newTask(taskDbid);
+    subTask.setName("dishes");
+    taskService.saveTask(subTask);
+    long dishesTaskDbid = subTask.getDbid();
+    
+    subTask = taskService.newTask(taskDbid);
+    subTask.setName("laundry");
+    taskService.saveTask(subTask);
+    long laundryTaskDbid = subTask.getDbid();
+    
+    subTask = taskService.newTask(taskDbid);
+    subTask.setName("sweep floor");
+    taskService.saveTask(subTask);
+    long sweepFloorTaskDbid = subTask.getDbid();
+    
+    // verify 3 sub tasks of clean da house
+    
+    List<Task> subTasks = taskService.getSubTasks(taskDbid);
+    Set<String> subTaskNames = getTaskNames(subTasks);
+    
+    Set<String> expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("dishes");
+    expectedTaskNames.add("laundry");
+    expectedTaskNames.add("sweep floor");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+
+    // add 3 sub tasks for sweep floor: 
+    // * clean da house
+    //   * dishes
+    //   * laundry
+    //   * sweep floor
+    //     * find broom
+    //     * find water
+    //     * scrub
+
+    // now second level subtasks under sweep floor
+    subTask = taskService.newTask(sweepFloorTaskDbid);
+    subTask.setName("find broom");
+    taskService.saveTask(subTask);
+
+    subTask = taskService.newTask(sweepFloorTaskDbid);
+    subTask.setName("find water");
+    taskService.saveTask(subTask);
+
+    subTask = taskService.newTask(sweepFloorTaskDbid);
+    subTask.setName("scrub");
+    taskService.saveTask(subTask);
+
+    // verify all the sub tasks of 'clean da house' and 'sweep floor'
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(taskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("dishes");
+    expectedTaskNames.add("laundry");
+    expectedTaskNames.add("sweep floor");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(sweepFloorTaskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("find broom");
+    expectedTaskNames.add("find water");
+    expectedTaskNames.add("scrub");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    // delete task dishes
+    taskService.deleteTask(dishesTaskDbid);
+
+    // verify all the sub tasks of 'clean da house' and 'sweep floor'
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(taskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("laundry");
+    expectedTaskNames.add("sweep floor");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(sweepFloorTaskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    expectedTaskNames.add("find broom");
+    expectedTaskNames.add("find water");
+    expectedTaskNames.add("scrub");
+    
+    assertEquals(expectedTaskNames, subTaskNames);
+
+    // delete laundry and delete sweep floor
+    // NOTE: deleting sweep floor should recursively delete the subtasks
+    taskService.deleteTask(laundryTaskDbid);
+    taskService.deleteTask(sweepFloorTaskDbid);
+
+    subTaskNames = getTaskNames(taskService.getSubTasks(taskDbid));
+
+    expectedTaskNames = new HashSet<String>();
+    assertEquals(expectedTaskNames, subTaskNames);
+    
+    subTaskNames = getTaskNames(taskService.getSubTasks(sweepFloorTaskDbid));
+    
+    expectedTaskNames = new HashSet<String>();
+    assertEquals(expectedTaskNames, subTaskNames);
+  }
+
+  private Set<String> getTaskNames(List<Task> tasks) {
+    Set<String> taskNames = new HashSet<String>();
+    for (Task task: tasks) {
+      taskNames.add(task.getName());
+    }
+    return taskNames;
+  }
+}


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

Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCommentsTest.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -0,0 +1,73 @@
+/*
+ * 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 java.util.List;
+
+import org.jbpm.model.Comment;
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskCommentsTest extends JbpmTestCase {
+  
+  public void testComments() {
+    Task task = taskService.newTask();
+    task.setName("clean da house");
+    taskService.saveTask(task);
+    long taskDbid = task.getDbid();
+
+    // what a party yesterday
+    //   - 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(taskDbid, "what a party yesterday");
+    long whatAPartyDbid = comment.getDbid();
+    comment = taskService.addReplyComment(whatAPartyDbid, "what! you had a party while i was out ?!");
+    long youHadAPartyDbid = comment.getDbid();
+    taskService.addReplyComment(youHadAPartyDbid, "euh yes.  it was a great party :-)");
+
+    taskService.addTaskComment(taskDbid, "i'll clean up the mess");
+    
+    List<Comment> taskComments = taskService.getTaskComments(taskDbid);
+    assertEquals("what a party yesterday", taskComments.get(0).getMessage());
+    assertEquals("i'll clean up the mess", taskComments.get(1).getMessage());
+    
+    taskComments = taskComments.get(0).getComments();
+    assertEquals("what! you had a party while i was out ?!", taskComments.get(0).getMessage());
+    
+    taskComments = taskComments.get(0).getComments();
+    assertEquals("euh yes.  it was a great party :-)", taskComments.get(0).getMessage());
+    
+    taskService.deleteComment(whatAPartyDbid);
+
+    taskComments = taskService.getTaskComments(taskDbid);
+    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(taskDbid);
+  }
+}


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

Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java	2009-02-18 10:33:14 UTC (rev 3916)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java	2009-02-18 11:19:13 UTC (rev 3917)
@@ -92,11 +92,6 @@
     assertEquals(expectedIdentityRefs, candidateIdentityRefs);
   }
 
-  public void testSwimlaneParticipants() {
-    
-  }
-
-    
   public Set<IdentityRef> getIdentityRefs(List<Participant> taskParticipants, String participation) {
     Set<IdentityRef> identityRefs = new HashSet<IdentityRef>();
     for (Participant participant: taskParticipants) {




More information about the jbpm-commits mailing list