[jbpm-commits] JBoss JBPM SVN: r3907 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/session and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Feb 17 12:21:03 EST 2009
Author: tom.baeyens at jboss.com
Date: 2009-02-17 12:21:02 -0500 (Tue, 17 Feb 2009)
New Revision: 3907
Added:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java
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
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
Removed:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/processlog/
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.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/GetTaskCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.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.task.hbm.xml
jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
Log:
JBPM-1861 and JBPM-1998 adding task participants
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-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -23,7 +23,8 @@
import java.util.List;
-import org.jbpm.task.Role;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
import org.jbpm.task.Task;
/**
@@ -43,18 +44,41 @@
/** Retrieves the task with the given identifier from persistent storage.
* If no task with the given identifier exists,
* the call returns <code>null</code>. */
- Task getTask(String taskId);
+ Task getTask(long taskDbid);
/** Marks the task with the given identifier as completed.
* This operation may result in a process instance being resumed. */
- void submitTask(String taskId);
+ void submitTask(long taskDbid);
/** Removes the task with the given identifier from persistent storage. */
- void deleteTask(String taskId);
+ void deleteTask(long taskDbid);
+
+
- List<String> getCandidates(String taskId);
- List<Role> getRoles(String taskId);
+ /** add a role to a given task.
+ * @param identityRef wither a new User(String) or a new Group(String)
+ * @param participation specifies the kind of involvement of the participant
+ * in this task. see {@link Participant} for default constants. */
+ void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+
+
+ /** get roles related to a given task. */
+ List<Participant> getTaskParticipants(long taskDbid);
+ /** removes a role to a given task. Nothing happens (no exception) if
+ * the role does not exist.
+ * @param identityRef wither a new User(String) or a new Group(String)
+ * @param participation specifies the kind of involvement of the participant
+ * in this task. see {@link Participant} for default constants. */
+ void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+
+ /*
+ void addSwimlaneRole(long taskDbid, String refId, RoleType roleType, String role);
+ List<UserRole> getSwimlaneRoles(long taskDbid, RoleType roleType, String role);
+ void removeSwimlaneRole(long taskDbid, String refId, RoleType roleType, String userRoleType);
+ */
+
+
TaskQuery createTaskQuery();
/** retrieves the personal task of the given user, which might be different
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -29,7 +29,7 @@
*/
public interface TaskDbSession extends DbSession {
- Task findTaskById(String taskId);
+ Task findTaskByDbid(long taskDbid);
void saveTask(Task task);
}
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GroupRef extends IdentityRef {
+
+ private static final long serialVersionUID = 1L;
+
+ public GroupRef(String groupId) {
+ super(groupId);
+ }
+
+ public String toString() {
+ return "GroupRef("+id+")";
+ }
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class IdentityRef implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String id;
+
+ public IdentityRef(String id) {
+ if (id==null) {
+ throw new JbpmException("id is null");
+ }
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IdentityRef other = (IdentityRef) obj;
+ if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java (from rev 3880, jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java)
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+
+/** a link to a participant (user or group) and the type of
+ * involvement of that participant.
+ *
+ * @author Tom Baeyens
+ */
+public interface Participant {
+
+ /** alternative owner, but as long as this person is not the owner.
+ * This person is allowed to make comments, but nothing else. */
+ String CANDIDATE = "candidate";
+
+ /** the person with ultimate responsibility over a task. */
+ String OWNER = "owner";
+
+ /** person that will be using the result of this task. This person is
+ * allowed to make comments, but nothing else. */
+ String CLIENT = "client";
+
+ /** person that is allowed to watch-but-not-touch this task */
+ String VIEWER = "viewer";
+
+ /** a person that was assigned to a task, but got replaced because of
+ * absence or another reason. This way, a trace can be left in case
+ * this person returns and wants to take back his tasks that got
+ * reassigned. */
+ String REPLACED_ASSIGNEE = "replaced-assignee";
+
+ long getDbid();
+
+ IdentityRef getIdentityRef();
+
+ /** see contants for default particpations */
+ String getParticipation();
+}
Deleted: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.task;
-
-
-/** a role that a person fullfills for a task.
- *
- * @author Tom Baeyens
- */
-public interface Role {
-
- long getDbid();
-
- String getIdentityId();
- void setIdentityId(String identityId);
-
- /*
- User getUser();
- Group getGroup();
- */
-
- String getRoleType();
- void setRoleType(String roleType);
-
- String getDescription();
- void setDescription(String description);
-
- Task getTask();
-}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -22,7 +22,6 @@
package org.jbpm.task;
import java.io.Serializable;
-import java.util.Collection;
/** a runtime process role that can store an assignment so that
* multiple related tasks are assigned to the same actor.
@@ -37,8 +36,4 @@
String getAssignee();
void setAssignee(String assignee);
-
- Collection<Role> getCandidates();
- Role createCandidate(String identityId);
- void removeCandidate(Role candidate);
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -30,28 +30,8 @@
*/
public interface Task extends Serializable {
- /** can do anything with the task */
- String ROLETYPE_OWNER = "owner";
-
- /** alternative owner, but as long as this person is not the owner.
- * This person is allowed to make comments, but nothing else. */
- String ROLETYPE_CANDIDATE = "candidate";
-
- /** person that will be using the result of this task. This person is
- * allowed to make comments, but nothing else. */
- String ROLETYPE_CLIENT = "client";
-
- /** person that is allowed to watch-but-not-touch this task */
- String ROLETYPE_VIEWER = "viewer";
-
- /** a person that was assigned to a task, but got replaced because of
- * absence or another reason. This way, a trace can be left in case
- * This person returns and wants to take back his tasks that got
- * reassigned. */
- String ROLETYPE_REPLACED_ASSIGNEE = "replaced-assignee";
+ long getDbid();
- String getId();
-
String getName();
void setName(String name);
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.task;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserRef extends IdentityRef {
+
+ private static final long serialVersionUID = 1L;
+
+ public UserRef(String userId) {
+ super(userId);
+ }
+
+ public String toString() {
+ return "UserRef("+id+")";
+ }
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -46,7 +46,7 @@
assertEquals("johndoe", task.getAssignee());
// submit the task
- taskService.submitTask(task.getId());
+ taskService.submitTask(task.getDbid());
// verify that the task list is now empty
taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -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 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.addRole(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/AddParticipant.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-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -33,15 +33,15 @@
private static final long serialVersionUID = 1L;
- protected String taskId;
+ protected long taskDbid;
- public DeleteTaskCmd(String taskId) {
- this.taskId = taskId;
+ public DeleteTaskCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
public Void execute(Environment environment) throws Exception {
TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
- Task task = taskDbSession.findTaskById(taskId);
+ Task task = taskDbSession.findTaskByDbid(taskDbid);
taskDbSession.delete(task);
return null;
}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -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 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;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -33,14 +33,14 @@
private static final long serialVersionUID = 1L;
- protected String taskId;
+ protected long taskDbid;
- public GetTaskCmd(String taskId) {
- this.taskId = taskId;
+ public GetTaskCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
public Task execute(Environment environment) throws Exception {
TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
- return taskDbSession.findTaskById(taskId);
+ return taskDbSession.findTaskByDbid(taskDbid);
}
}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,51 @@
+/*
+ * 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.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 {
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -34,15 +34,15 @@
private static final long serialVersionUID = 1L;
- protected String taskId;
+ protected long taskDbid;
protected TaskImpl task;
public SubmitTaskCmd(TaskImpl task) {
this.task = task;
}
- public SubmitTaskCmd(String taskId) {
- this.taskId = taskId;
+ public SubmitTaskCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
public Void execute(Environment environment) throws Exception {
@@ -50,7 +50,7 @@
if (task!=null) {
taskDbession.merge(task);
} else {
- task = (TaskImpl) taskDbession.findTaskById(taskId);
+ task = (TaskImpl) taskDbession.findTaskByDbid(taskDbid);
}
task.submit();
taskDbession.delete(task);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -23,7 +23,6 @@
import java.io.Serializable;
-import org.hibernate.criterion.Restrictions;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.session.TaskDbSession;
import org.jbpm.task.Task;
@@ -33,12 +32,10 @@
*/
public class HibernateTaskDbSession extends HibernateDbSession implements TaskDbSession {
- public TaskImpl findTaskById(String taskId) {
+ public TaskImpl findTaskByDbid(long taskDbid) {
// TODO maybe we should move these criteria queries to hql queries in the
// hbm file so that users can easily customize.
- return (TaskImpl) session.createCriteria(TaskImpl.class)
- .add(Restrictions.eq("id", taskId))
- .uniqueResult();
+ return (TaskImpl) session.get(TaskImpl.class, taskDbid);
}
public void saveTask(Task task) {
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java (from rev 3881, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,107 @@
+/*
+ * 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.JbpmException;
+import org.jbpm.task.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.UserRef;
+
+
+/** the relation between a task and a person.
+ * @author Tom Baeyens
+ */
+public class ParticipantImpl implements Serializable, Participant {
+
+ private static final long serialVersionUID = 1L;
+
+ protected long dbid;
+ protected int dbversion;
+
+ protected String identityType;
+ protected String identityId;
+ protected String participation;
+ protected TaskImpl task;
+ protected SwimlaneImpl swimlane;
+
+ public ParticipantImpl() {
+ }
+
+ public ParticipantImpl(IdentityRef identityRef, String participation) {
+ setIdentityRef(identityRef);
+ this.participation = participation;
+ }
+
+ public IdentityRef getIdentityRef() {
+ if ("U".equals(identityType)) {
+ return new UserRef(identityId);
+ }
+ return new GroupRef(identityId);
+ }
+
+ public void setIdentityRef(IdentityRef identityRef) {
+ if (identityRef==null) {
+ throw new JbpmException("identityRef is null");
+ }
+
+ if (identityRef instanceof UserRef) {
+ identityType = "U";
+ } else if (identityRef instanceof GroupRef) {
+ identityType = "G";
+ } else {
+ throw new JbpmException("invalid identity type: "+identityRef.getClass().getName());
+ }
+
+ identityId = identityRef.getId();
+ }
+
+ public TaskImpl getTask() {
+ return task;
+ }
+ public void setTask(TaskImpl task) {
+ this.task = task;
+ }
+ public long getDbid() {
+ return dbid;
+ }
+ public SwimlaneImpl getSwimlane() {
+ return swimlane;
+ }
+ public void setSwimlane(SwimlaneImpl swimlane) {
+ this.swimlane = swimlane;
+ }
+ public String getParticipation() {
+ return participation;
+ }
+ public void setParticipation(String participation) {
+ this.participation = participation;
+ }
+ public String getIdentityId() {
+ return identityId;
+ }
+ public void setIdentityId(String identityId) {
+ this.identityId = identityId;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -1,81 +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.task.Role;
-
-
-/** the relation between a task and a person.
- * @author Tom Baeyens
- */
-public class RoleImpl implements Serializable, Role {
-
- private static final long serialVersionUID = 1L;
-
- protected long dbid;
- protected int dbversion;
- protected String identityId;
- protected String roleType;
- protected String description;
- protected TaskImpl task;
- protected SwimlaneImpl swimlane;
-
- public String toString() {
- return roleType.toString()+"("+identityId+")";
- }
-
- public TaskImpl getTask() {
- return task;
- }
- public void setTask(TaskImpl task) {
- this.task = task;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public long getDbid() {
- return dbid;
- }
- public SwimlaneImpl getSwimlane() {
- return swimlane;
- }
- public void setSwimlane(SwimlaneImpl swimlane) {
- this.swimlane = swimlane;
- }
- public String getIdentityId() {
- return identityId;
- }
- public void setIdentityId(String identityId) {
- this.identityId = identityId;
- }
- public String getRoleType() {
- return roleType;
- }
- public void setRoleType(String roleType) {
- this.roleType = roleType;
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -24,14 +24,11 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
-import org.jbpm.JbpmException;
import org.jbpm.pvm.internal.util.EqualsUtil;
-import org.jbpm.task.Role;
+import org.jbpm.task.Participant;
import org.jbpm.task.Swimlane;
-import org.jbpm.task.Task;
/**
* runtime process role for a specific process instance.
@@ -44,7 +41,7 @@
protected int dbversion;
protected String name = null;
protected String assignee = null;
- protected Set<RoleImpl> candidates = null;
+ protected Set<ParticipantImpl> participants = null;
protected SwimlaneDefinitionImpl swimlaneDefinition = null;
// assignment methods ///////////////////////////////////////////////////////
@@ -59,39 +56,13 @@
// candidates ///////////////////////////////////////////////////////////////
- public Collection<Role> getCandidates() {
- if (candidates==null) {
+ public Collection<Participant> getParticipants() {
+ if (participants==null) {
return Collections.EMPTY_LIST;
}
- return (Collection)candidates;
+ return (Collection)participants;
}
- public Role createCandidate(String identityId) {
- if (identityId==null) {
- throw new JbpmException("identityId is null");
- }
- RoleImpl role = new RoleImpl();
- role.setIdentityId(identityId);
- role.setRoleType(Task.ROLETYPE_CANDIDATE);
- role.setSwimlane(this);
- if (candidates==null) {
- candidates = new HashSet<RoleImpl>();
- }
- candidates.add(role);
- return role;
- }
-
- public void removeCandidate(Role candidate) {
- if (candidate==null) {
- throw new JbpmException("candidate is null");
- }
- if ( (candidates!=null)
- && (candidates.remove(candidate))
- ) {
- ((RoleImpl)candidate).setTask(null);
- }
- }
-
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
// since this always falls back to ==, we don't need to overwrite the hashcode
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-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -39,7 +39,8 @@
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.task.Role;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
import org.jbpm.task.Swimlane;
import org.jbpm.task.Task;
@@ -58,7 +59,7 @@
protected String description;
protected String assignee;
- protected Set<RoleImpl> roles;
+ protected Set<ParticipantImpl> participants;
protected Date create;
protected Date dueDate;
@@ -139,52 +140,47 @@
// roles ////////////////////////////////////////////////////////////////////
- public Set<RoleImpl> getRoles() {
- if (roles==null) {
+ public Set<ParticipantImpl> getParticipants() {
+ if (participants==null) {
return Collections.emptySet();
}
- return roles;
+ return participants;
}
-
- public Set<RoleImpl> getAllRoles() {
- Set<RoleImpl> allRoles = null;
- if (roles!=null) {
- allRoles = new HashSet<RoleImpl>(roles);
+
+ public Set<ParticipantImpl> getAllRoles() {
+ Set<ParticipantImpl> allRoles = null;
+ if (participants!=null) {
+ allRoles = new HashSet<ParticipantImpl>(participants);
} else {
- allRoles = new HashSet<RoleImpl>();
+ allRoles = new HashSet<ParticipantImpl>();
}
if (swimlane!=null) {
- allRoles.addAll((Set)swimlane.getCandidates());
+ allRoles.addAll((Set)swimlane.getParticipants());
}
return allRoles;
}
-
- public Role addRole(String identityId, String roleType) {
- if (identityId==null) {
- throw new JbpmException("userId is null");
+
+ public Participant addRole(IdentityRef identityRef, String participation) {
+ if (identityRef==null) {
+ throw new JbpmException("identity is null");
}
- if (roleType==null) {
- throw new JbpmException("roleType is null");
- }
- RoleImpl role = new RoleImpl();
- role.setIdentityId(identityId);
+ ParticipantImpl role = new ParticipantImpl(identityRef, participation);
role.setTask(this);
- role.setRoleType(roleType);
- if (roles==null) {
- roles = new HashSet<RoleImpl>();
+ if (participants==null) {
+ participants = new HashSet<ParticipantImpl>();
}
- roles.add(role);
+ participants.add(role);
return role;
}
-
- public void removeRole(Role role) {
+
+ public void removeRole(ParticipantImpl role) {
if (role==null) {
throw new JbpmException("role is null");
}
- if ( (roles!=null)
- && (roles.remove(role))
+ if ( (participants!=null)
+ && (participants.remove(role))
) {
- ((RoleImpl)role).setTask(null);
+ ((ParticipantImpl)role).setTask(null);
}
}
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-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -26,12 +26,15 @@
import org.jbpm.TaskQuery;
import org.jbpm.TaskService;
import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.cmd.AddParticipant;
import org.jbpm.pvm.internal.cmd.DeleteTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetParticipants;
import org.jbpm.pvm.internal.cmd.GetTaskCmd;
import org.jbpm.pvm.internal.cmd.NewTaskCmd;
import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
-import org.jbpm.task.Role;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
import org.jbpm.task.Task;
/**
@@ -60,34 +63,39 @@
return commandService.execute(new NewTaskCmd());
}
- public Task getTask(String taskId) {
- return commandService.execute(new GetTaskCmd(taskId));
+ public Task getTask(long taskDbid) {
+ return commandService.execute(new GetTaskCmd(taskDbid));
}
public void saveTask(Task task) {
commandService.execute(new SaveTaskCmd((TaskImpl) task));
}
- public void deleteTask(String taskId) {
- commandService.execute(new DeleteTaskCmd(taskId));
+ public void deleteTask(long taskDbid) {
+ commandService.execute(new DeleteTaskCmd(taskDbid));
}
- public void submitTask(String taskId) {
- commandService.execute(new SubmitTaskCmd(taskId));
+ public void submitTask(long taskDbid) {
+ commandService.execute(new SubmitTaskCmd(taskDbid));
}
public void submitTask(Task task) {
commandService.execute(new SubmitTaskCmd((TaskImpl)task));
}
- public List<String> getCandidates(String taskId) {
- return null;
+ public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+ commandService.execute(new AddParticipant(taskDbid, null, identityRef, participation));
}
- public List<Role> getRoles(String taskId) {
- return null;
+ public List<Participant> getTaskParticipants(long taskDbid) {
+ return commandService.execute(new GetParticipants(taskDbid, null));
}
+ public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+ throw new UnsupportedOperationException();
+ // commandService.execute(new RemoveRole(taskDbid, identityType, identityId, roleName));
+ }
+
public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
return createTaskQuery()
.assignee(assignee)
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-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml 2009-02-17 17:21:02 UTC (rev 3907)
@@ -57,9 +57,9 @@
<property name="description" column="DESCR_"/>
<property name="assignee" column="ASSIGNEE_"/>
- <set name="roles" cascade="all-delete-orphan">
- <key column="TASK_" foreign-key="FK_ROLE_TASK" />
- <one-to-many class="RoleImpl" />
+ <set name="participants" cascade="all-delete-orphan">
+ <key column="TASK_" />
+ <one-to-many class="ParticipantImpl" />
</set>
<property name="priority" column="PRIORITY_"/>
@@ -98,24 +98,28 @@
</class>
- <!-- ### ROLE ########################################################### -->
- <class name="RoleImpl"
- discriminator-value="R">
+ <!-- ### PARTICIPANT #################################################### -->
+ <class name="ParticipantImpl">
<id name="dbid" column="DBID_">
<generator class="native" />
</id>
- <discriminator type="char" column="CLASS_"/>
<version name="dbversion" column="DBVERSION_" />
+ <property name="identityType" column="IDENTITYTYPE_"/>
<property name="identityId" column="IDENTITYID_"/>
- <property name="roleType" column="ROLETYPE_" />
- <property name="description" column="DESCR_"/>
+ <property name="participation" column="PARTICIPATION_" />
<many-to-one name="task"
class="TaskImpl"
column="TASK_"
- foreign-key="FK_ROLE_TASK" />
+ index="IDX_PART_TASK"
+ foreign-key="FK_PART_TASK" />
+ <many-to-one name="swimlane"
+ class="SwimlaneImpl"
+ column="SWIMLANE_"
+ foreign-key="FK_PART_SWIMLANE" />
+
</class>
<!-- ### SWIMLANE DEFINITION ############################################ -->
@@ -144,11 +148,11 @@
column="SWIMLANEDEF_"
foreign-key="FK_SWIMLANE_DEF" />
- <set name="candidates" cascade="all-delete-orphan">
- <key column="SWIMLANE_" foreign-key="FK_ROLE_SWIMLANE" />
- <one-to-many class="RoleImpl" />
+ <set name="participants" cascade="all-delete-orphan">
+ <key column="SWIMLANE_" />
+ <one-to-many class="ParticipantImpl" />
</set>
-
+
</class>
Modified: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -26,12 +26,12 @@
import java.util.Map;
import java.util.Set;
-import org.jbpm.pvm.internal.task.RoleImpl;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
import org.jbpm.pvm.internal.task.SwimlaneImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.task.Task;
+import org.jbpm.task.Participant;
import org.jbpm.test.BaseJbpmTestCase;
/**
@@ -76,37 +76,38 @@
assertEquals("joesmoe", task.getAssignee());
}
+ /*
public void testTaskRoles() {
TaskImpl task = TaskImpl.create();
assertNotNull(task.getRoles());
assertEquals(0, task.getRoles().size());
- task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
- task.addRole("joe smoe", Task.ROLETYPE_OWNER).setDescription("does what he wants");
- task.addRole("jack black", Task.ROLETYPE_CANDIDATE).setDescription("can take this task");
- task.addRole("jim slim", Task.ROLETYPE_VIEWER).setDescription("is allowed to see");
- task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
+ task.addRole("john doe", Role.ROLETYPE_CLIENT).setDescription("uses the result");
+ task.addRole("joe smoe", Role.ROLETYPE_OWNER).setDescription("does what he wants");
+ task.addRole("jack black", Role.ROLETYPE_CANDIDATE).setDescription("can take this task");
+ task.addRole("jim slim", Role.ROLETYPE_VIEWER).setDescription("is allowed to see");
+ task.addRole("jeff nef", Role.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
Set<RoleImpl> roles = task.getRoles();
Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
for (RoleImpl role: roles) {
- roleMap.put(role.getIdentityId(), role);
+ roleMap.put(role.getUserId(), role);
}
- assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
+ assertEquals(Role.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
assertEquals("uses the result", roleMap.get("john doe").getDescription());
- assertEquals(Task.ROLETYPE_OWNER, roleMap.get("joe smoe").getRoleType());
+ assertEquals(Role.ROLETYPE_OWNER, roleMap.get("joe smoe").getRoleType());
assertEquals("does what he wants", roleMap.get("joe smoe").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
assertEquals("can take this task", roleMap.get("jack black").getDescription());
- assertEquals(Task.ROLETYPE_VIEWER, roleMap.get("jim slim").getRoleType());
+ assertEquals(Role.ROLETYPE_VIEWER, roleMap.get("jim slim").getRoleType());
assertEquals("is allowed to see", roleMap.get("jim slim").getDescription());
- assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
+ assertEquals(Role.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
assertEquals("is sick", roleMap.get("jeff nef").getDescription());
assertEquals(5, roles.size());
@@ -129,53 +130,52 @@
assertNotNull(task.getAllRoles());
assertEquals(0, task.getAllRoles().size());
- task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
+ task.addRole("john doe", Role.ROLETYPE_CLIENT).setDescription("uses the result");
SwimlaneImpl manager = new SwimlaneImpl();
task.setSwimlane(manager);
- manager.createCandidate("joe smoe").setDescription("tostesteron ambition");
- manager.createCandidate("jack black").setDescription("the pigeon");
- manager.createCandidate("jim slim").setDescription("lame duck");
+ manager.addCandidateUser("joe smoe").setDescription("tostesteron ambition");
+ manager.addCandidateUser("jack black").setDescription("the pigeon");
+ manager.addCandidateUser("jim slim").setDescription("lame duck");
- task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
+ task.addRole("jeff nef", Role.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
Set<RoleImpl> roles = task.getAllRoles();
Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
for (RoleImpl role: roles) {
- roleMap.put(role.getIdentityId(), role);
+ roleMap.put(role.getUserId(), role);
}
- assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
+ assertEquals(Role.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
assertEquals("uses the result", roleMap.get("john doe").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("joe smoe").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("joe smoe").getRoleType());
assertEquals("tostesteron ambition", roleMap.get("joe smoe").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
assertEquals("the pigeon", roleMap.get("jack black").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jim slim").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("jim slim").getRoleType());
assertEquals("lame duck", roleMap.get("jim slim").getDescription());
- assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
+ assertEquals(Role.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
assertEquals("is sick", roleMap.get("jeff nef").getDescription());
assertEquals(5, roles.size());
task.removeRole(roleMap.get("john doe"));
assertEquals(4, task.getAllRoles().size());
- manager.removeCandidate(roleMap.get("joe smoe"));
+ manager.removeCandidateUser(roleMap.get("joe smoe"));
assertEquals(3, task.getAllRoles().size());
- manager.removeCandidate(roleMap.get("jack black"));
+ manager.removeCandidateUser(roleMap.get("jack black"));
assertEquals(2, task.getAllRoles().size());
- manager.removeCandidate(roleMap.get("jim slim"));
+ manager.removeCandidateUser(roleMap.get("jim slim"));
assertEquals(1, task.getAllRoles().size());
task.removeRole(roleMap.get("jeff nef"));
assertEquals(0, task.getAllRoles().size());
}
- /*
public void testTaskComment() {
EnvironmentFactory environmentFactory = EnvironmentFactory.parseXmlString("<environment/>");
TaskImpl task = TaskImpl.create();
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -80,7 +80,7 @@
protected List<ProcessDefinition> registeredProcessDefinitions;
/** registered tasks will be deleted automatically in the tearDown.
* This is a convenience function as each test is expected to clean up the DB. */
- protected List<String> registeredTaskIds;
+ protected List<Long> registeredTaskIds;
protected void setUp() throws Exception {
super.setUp();
@@ -117,8 +117,8 @@
}
if (registeredTaskIds != null) {
- for (String taskId : registeredTaskIds) {
- taskService.deleteTask(taskId);
+ for (Long taskDbid : registeredTaskIds) {
+ taskService.deleteTask(taskDbid);
}
}
@@ -175,9 +175,9 @@
taskService.saveTask(task);
if (registeredTaskIds == null) {
- registeredTaskIds = new ArrayList<String>();
+ registeredTaskIds = new ArrayList<Long>();
}
- registeredTaskIds.add(task.getId());
+ registeredTaskIds.add(task.getDbid());
}
public HashSet<String> getActivityNames(String processInstanceId) {
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -34,45 +34,36 @@
public void testNewTask() {
// creation of a new non-persisted task
Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
+ task = taskService.getTask(task.getDbid());
assertNull(task);
}
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveAndRegisterTask(task);
- assertNotNull(task.getId());
- }
-
public void testSaveTask() {
Task task = taskService.newTask();
saveAndRegisterTask(task);
- String taskId = task.getId();
+ long taskDbid = task.getDbid();
// task was made persistent
- task = taskService.getTask(taskId);
+ task = taskService.getTask(taskDbid);
assertNotNull("expected non-null task", task);
// make some change
Date dueDate = new Date();
task.setDueDate(dueDate);
taskService.saveTask(task);
// verify change is applied
- task = taskService.getTask(taskId);
+ task = taskService.getTask(taskDbid);
assertEquals(dueDate, task.getDueDate());
}
public void testDeleteTask() {
Task task = taskService.newTask();
taskService.saveTask(task);
- String taskId = task.getId();
+ long taskDbid = task.getDbid();
// task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
+ assertNotNull("expected non-null task", taskService.getTask(taskDbid));
// delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
+ taskService.deleteTask(taskDbid);
+ task = taskService.getTask(taskDbid);
assertNull("expected null, but was " + task, task);
}
}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,83 @@
+/*
+ * 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.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Task;
+import org.jbpm.task.UserRef;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskParticipationsTest extends JbpmTestCase {
+
+ public void testTaskParticipants() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ saveAndRegisterTask(task);
+
+ long taskDbid = task.getDbid();
+
+ taskService.addTaskParticipant(taskDbid, new UserRef("johndoe"), Participant.CANDIDATE);
+ taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.CANDIDATE);
+ taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.OWNER);
+ taskService.addTaskParticipant(taskDbid, new GroupRef("losers"), Participant.CANDIDATE);
+ taskService.addTaskParticipant(taskDbid, new GroupRef("dummies"), Participant.CANDIDATE);
+
+ List<Participant> taskParticipants = taskService.getTaskParticipants(taskDbid);
+
+ Set<IdentityRef> candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.CANDIDATE);
+
+ Set<IdentityRef> expectedIdentityRefs = new HashSet<IdentityRef>();
+ expectedIdentityRefs.add(new UserRef("johndoe"));
+ expectedIdentityRefs.add(new UserRef("joesmoe"));
+ expectedIdentityRefs.add(new GroupRef("losers"));
+ expectedIdentityRefs.add(new GroupRef("dummies"));
+
+ assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+
+ candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.OWNER);
+
+ expectedIdentityRefs = new HashSet<IdentityRef>();
+ expectedIdentityRefs.add(new UserRef("joesmoe"));
+
+ assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+ }
+
+ public Set<IdentityRef> getIdentityRefs(List<Participant> taskParticipants, String participation) {
+ Set<IdentityRef> identityRefs = new HashSet<IdentityRef>();
+ for (Participant participant: taskParticipants) {
+ if (participation.equals(participant.getParticipation())) {
+ identityRefs.add(participant.getIdentityRef());
+ }
+ }
+ return identityRefs;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbpm-commits
mailing list