[jbpm-commits] JBoss JBPM SVN: r4367 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/task and 11 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Mar 31 10:52:44 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-03-31 10:52:44 -0400 (Tue, 31 Mar 2009)
New Revision: 4367
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/FindGroupIds.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/IdentityService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participation.java
jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml
jbpm4/trunk/modules/examples/src/test/resources/jbpm.task.hbm.xml
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.task.hbm.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.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/TaskQueryImpl.java
jbpm4/trunk/modules/pvm/src/test/resources/jbpm.task.hbm.xml
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.task.hbm.xml
Log:
fixed task and participation api
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/IdentityService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/IdentityService.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/IdentityService.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -68,10 +68,14 @@
* Returns an empty list if no such groups exist. */
List<Group> findGroupsByUserAndGroupType(String userId, String groupType);
- /** all groups for which this user is a member.
+ /** all group ids (String) for which this user is a member.
* Returns an empty list if no such groups exist. */
List<Group> findGroupsByUser(String userId);
+ /** all group ids (String) for which this user is a member.
+ * Returns an empty list if no such groups exist. */
+ List<String> findGroupIdsByUser(String userId);
+
/** deletes the given group.
* No effect (no exception) if the group does not exist. */
void deleteGroup(String groupId);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -98,36 +98,30 @@
void cancelTask(long taskDbid, String reason);
/** add a role to a given task.
- * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
* @param participation specifies the kind of involvement of the participatingUser
* in this task. see {@link Participation} for default constants. */
- void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+ void addTaskParticipatingUser(long taskDbid, String userId, String participationType);
+ /** add a role to a given task.
+ * @param participation specifies the kind of involvement of the participatingUser
+ * in this task. see {@link Participation} for default constants. */
+ void addTaskParticipatingGroup(long taskDbid, String groupId, String participationType);
+
/** get roles related to a given task. */
- List<Participation> getTaskParticipants(long taskDbid);
+ List<Participation> getTaskParticipations(long taskDbid);
/** removes a role to a given task. Nothing happens (no exception) if
* the role does not exist.
- * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
* @param participation specifies the kind of involvement of the participatingUser
* in this task. see {@link Participation} for default constants. */
- void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+ void removeTaskParticipatingUser(long taskDbid, String userId, String participationType);
- /** add a role from a given swimlane.
- * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
+ /** removes a role to a given task. Nothing happens (no exception) if
+ * the role does not exist.
* @param participation specifies the kind of involvement of the participatingUser
- * in this swimlane. see {@link Participation} for default constants. */
- void addSwimlaneParticipant(long swimlaneDbid, IdentityRef identityRef, String participation);
+ * in this task. see {@link Participation} for default constants. */
+ void removeTaskParticipatingGroup(long taskDbid, String groupId, String participationType);
- /** get roles related to a given swimlane. */
- List<Participation> getSwimlaneParticipants(long swimlaneDbid);
-
- /** remove a role from a given swimlane.
- * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
- * @param participation specifies the kind of involvement of the participatingUser
- * in this swimlane. see {@link Participation} for default constants. */
- void removeSwimlaneParticipant(long swimlaneDbid, IdentityRef identityRef, String participation);
-
/** create a new query for tasks */
TaskQuery createTaskQuery();
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participation.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participation.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participation.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -28,8 +28,7 @@
* @author Tom Baeyens
* @author Heiko Braun <heiko.braun at jboss.com>
*/
-public interface Participation
-{
+public interface Participation {
/** alternative owner, but as long as this person is not the owner.
* This person is allowed to make comments, but nothing else. */
@@ -53,8 +52,14 @@
long getDbid();
- IdentityRef getIdentityRef();
-
+ /** userId for this participation.
+ * null in case this is a {@link #getGroupId() group participation}. */
+ String getUserId();
+
+ /** groupId for this participation.
+ * null in case this is a {@link #getUserId() user participation}. */
+ String getGroupId();
+
/** see constants for default participations */
String getType();
}
Modified: jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml 2009-03-31 14:52:44 UTC (rev 4367)
@@ -142,7 +142,7 @@
<property name="groupId" column="GROUPID_"/>
<property name="userId" column="USERID_"/>
- <property name="participation" column="PARTICIPATION_" />
+ <property name="type" column="TYPE_" />
<many-to-one name="task"
class="TaskImpl"
Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.task.hbm.xml 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.task.hbm.xml 2009-03-31 14:52:44 UTC (rev 4367)
@@ -142,7 +142,7 @@
<property name="groupId" column="GROUPID_"/>
<property name="userId" column="USERID_"/>
- <property name="participation" column="PARTICIPATION_" />
+ <property name="type" column="TYPE_" />
<many-to-one name="task"
class="TaskImpl"
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -36,11 +36,8 @@
import org.jbpm.model.Transition;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.task.GroupRef;
-import org.jbpm.task.IdentityRef;
import org.jbpm.task.Participation;
import org.jbpm.task.Task;
-import org.jbpm.task.UserRef;
/**
* @author Heiko.Braun <heiko.braun at jboss.com>
@@ -127,21 +124,20 @@
{
if(p0.getType().equals(Participation.CANDIDATE))
{
- IdentityRef idRef = p0.getIdentityRef();
- ParticipantRef participant = new ParticipantRef("candidate", idRef.getId());
-
- if(idRef instanceof GroupRef)
+ if(p0.getGroupId()!=null)
{
+ ParticipantRef participant = new ParticipantRef("candidate", p0.getGroupId());
task.getParticipantGroups().add(participant);
}
- else if(idRef instanceof UserRef)
+ else if(p0.getUserId()!=null)
{
+ ParticipantRef participant = new ParticipantRef("candidate", p0.getUserId());
participant.setGroup(true);
task.getParticipantUsers().add(participant);
}
else
{
- throw new IllegalArgumentException("Unknown IdentityRef: " + idRef);
+ throw new IllegalArgumentException("Participation doesn't have user or group: " + p0);
}
}
else
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/TaskManagementImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -79,12 +79,12 @@
private GroupRef[] getGroupIdsForIdentityRef(String idRef)
{
IdentityService idService = this.processEngine.get(IdentityService.class);
- List<Group> groups = idService.findGroupsByUser(idRef);
- GroupRef[] groupRefs = new GroupRef[groups.size()];
+ List<String> groupIds = idService.findGroupIdsByUser(idRef);
+ GroupRef[] groupRefs = new GroupRef[groupIds.size()];
int i = 0;
- for(Group g : groups)
+ for(String groupId : groupIds)
{
- groupRefs[i] = new GroupRef(g.getId());
+ groupRefs[i] = new GroupRef(groupId);
i++;
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -94,7 +94,7 @@
// copy the swimlane assignments to the task
task.setAssignee(swimlane.getAssignee());
for (ParticipationImpl participant: swimlane.getParticipations()) {
- task.addParticipant(participant.getIdentityRef(), participant.getType());
+ task.addParticipation(participant.getUserId(), participant.getGroupId(), participant.getType());
}
}
Modified: jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.task.hbm.xml 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.task.hbm.xml 2009-03-31 14:52:44 UTC (rev 4367)
@@ -142,7 +142,7 @@
<property name="groupId" column="GROUPID_"/>
<property name="userId" column="USERID_"/>
- <property name="participation" column="PARTICIPATION_" />
+ <property name="type" column="TYPE_" />
<many-to-one name="task"
class="TaskImpl"
Deleted: 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/AddParticipantCmd.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipantCmd.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -1,74 +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.env.Environment;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.task.IdentityRef;
-
-/**
- * @author Tom Baeyens
- */
-public class AddParticipantCmd extends AbstractCommand<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;
- }
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java (from rev 4358, 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/AddParticipationCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -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 org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.IdentityRef;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddParticipationCmd extends AbstractCommand<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Long taskDbid;
+ protected Long swimlaneDbid;
+ protected String userId;
+ protected String groupId;
+ protected String type;
+
+ public AddParticipationCmd(Long taskDbid, Long swimlaneDbid, String userId, String groupId, String type) {
+ this.taskDbid = taskDbid;
+ this.swimlaneDbid = swimlaneDbid;
+ this.userId = userId;
+ this.groupId = groupId;
+ this.type = type;
+ }
+
+ 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.addParticipation(userId, groupId, type);
+ }
+
+ /*
+ 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/AddParticipationCmd.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/cmd/RemoveParticipantCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -29,7 +29,6 @@
import org.jbpm.env.Environment;
import org.jbpm.pvm.internal.task.ParticipationImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.task.IdentityRef;
/**
@@ -41,36 +40,39 @@
protected Long taskDbid;
protected Long swimlaneDbid;
- protected IdentityRef identityRef;
+ protected String userId;
+ protected String groupId;
protected String participationType;
- public RemoveParticipantCmd(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participationType) {
+ public RemoveParticipantCmd(Long taskDbid, Long swimlaneDbid, String userId, String groupId, String participationType) {
this.swimlaneDbid = swimlaneDbid;
this.taskDbid = taskDbid;
- this.identityRef = identityRef;
+ this.userId = userId;
+ this.groupId = groupId;
this.participationType = participationType;
}
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<ParticipationImpl> participants = new HashSet<ParticipationImpl>(task.getParticipations());
- for (ParticipationImpl participant : participants) {
- if ( participant.getIdentityRef().equals(identityRef)
- && participant.getType().equals(participationType)
+ Set<ParticipationImpl> participations = new HashSet<ParticipationImpl>(task.getParticipations());
+ for (ParticipationImpl participation : participations) {
+ boolean userMatch = userId!=null ? userId.equals(participation.getUserId()) : false;
+ boolean groupMatch = groupId!=null ? groupId.equals(participation.getGroupId()) : false;
+ if ( ( userMatch || groupMatch )
+ && participation.getType().equals(participationType)
) {
- task.removeParticipant(participant);
+ task.removeParticipant(participation);
}
}
}
-
+
return null;
}
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/FindGroupIds.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/FindGroupIds.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/FindGroupIds.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -0,0 +1,35 @@
+package org.jbpm.pvm.internal.svc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.identity.Group;
+import org.jbpm.pvm.internal.identity.cmd.FindGroups;
+
+
+public class FindGroupIds implements Command<List<String>> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String userId;
+
+ public FindGroupIds(String userId) {
+ this.userId = userId;
+ }
+
+ public List<String> execute(Environment environment) throws Exception {
+ List<String> groupIds = new ArrayList<String>();
+
+ FindGroups findGroupsCmd = new FindGroups(userId);
+ List<Group> groups = findGroupsCmd.execute(environment);
+ for (Group group: groups) {
+ groupIds.add(group.getId());
+ }
+
+ return groupIds;
+ }
+
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/FindGroupIds.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -78,6 +78,10 @@
return commandService.execute(new FindGroup(groupId));
}
+ public List<String> findGroupIdsByUser(String userId) {
+ return commandService.execute(new FindGroupIds(userId));
+ }
+
public List<Group> findGroupsByUser(String userId) {
return commandService.execute(new FindGroups(userId));
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -75,35 +75,26 @@
commandService.execute(cmd);
}
- public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
- AddParticipantCmd cmd = new AddParticipantCmd(taskDbid, null, identityRef, participation);
- commandService.execute(cmd);
+ public void addTaskParticipatingUser(long taskDbid, String userId, String participation) {
+ commandService.execute(new AddParticipationCmd(taskDbid, null, userId, null, participation));
}
- public List<Participation> getTaskParticipants(long taskDbid) {
- GetParticipantsCmd cmd = new GetParticipantsCmd(taskDbid, null);
- return commandService.execute(cmd);
+ public void addTaskParticipatingGroup(long taskDbid, String groupId, String participation) {
+ commandService.execute(new AddParticipationCmd(taskDbid, null, null, groupId, participation));
}
- public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
- RemoveParticipantCmd cmd = new RemoveParticipantCmd(taskDbid, null, identityRef, participation);
- commandService.execute(cmd);
+ public List<Participation> getTaskParticipations(long taskDbid) {
+ return commandService.execute(new GetParticipantsCmd(taskDbid, null));
}
- public void addSwimlaneParticipant(long swimlaneDbid, IdentityRef identityRef, String participation) {
- AddParticipantCmd cmd = new AddParticipantCmd(null, swimlaneDbid, identityRef, participation);
- commandService.execute(cmd);
+ public void removeTaskParticipatingUser(long taskDbid, String userId, String participation) {
+ commandService.execute(new RemoveParticipantCmd(taskDbid, null, userId, null, participation));
}
- public List<Participation> getSwimlaneParticipants(long swimlaneDbid) {
- GetParticipantsCmd cmd = new GetParticipantsCmd(null, swimlaneDbid);
- return commandService.execute(cmd);
+ public void removeTaskParticipatingGroup(long taskDbid, String groupId, String participation) {
+ commandService.execute(new RemoveParticipantCmd(taskDbid, null, null, groupId, participation));
}
- public void removeSwimlaneParticipant(long swimlaneDbid, IdentityRef identityRef, String participation) {
- RemoveParticipantCmd cmd = new RemoveParticipantCmd(null, swimlaneDbid, identityRef, participation);
- commandService.execute(cmd);
- }
public List<Task> findAssignedTasks(String userId) {
return createTaskQuery()
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -23,11 +23,7 @@
import java.io.Serializable;
-import org.jbpm.JbpmException;
-import org.jbpm.task.GroupRef;
-import org.jbpm.task.IdentityRef;
import org.jbpm.task.Participation;
-import org.jbpm.task.UserRef;
/** the relation between a task and a person.
@@ -43,39 +39,19 @@
protected String userId;
protected String groupId;
- protected String participation;
+ protected String type;
protected TaskImpl task;
protected SwimlaneImpl swimlane;
public ParticipationImpl() {
}
- public ParticipationImpl(IdentityRef identityRef, String participation) {
- setIdentityRef(identityRef);
- this.participation = participation;
+ public ParticipationImpl(String userId, String groupId, String type) {
+ this.userId = userId;
+ this.groupId = groupId;
+ this.type = type;
}
- public IdentityRef getIdentityRef() {
- if (userId!=null) {
- return new UserRef(userId);
- }
- return new GroupRef(groupId);
- }
-
- public void setIdentityRef(IdentityRef identityRef) {
- if (identityRef==null) {
- throw new JbpmException("identityRef is null");
- }
-
- if (identityRef instanceof UserRef) {
- userId = identityRef.getId();
- } else if (identityRef instanceof GroupRef) {
- groupId = identityRef.getId();
- } else {
- throw new JbpmException("invalid identity type: "+identityRef.getClass().getName());
- }
- }
-
public TaskImpl getTask() {
return task;
}
@@ -92,10 +68,10 @@
this.swimlane = swimlane;
}
public String getType() {
- return participation;
+ return type;
}
- public void setParticipation(String participation) {
- this.participation = participation;
+ public void setType(String type) {
+ this.type = type;
}
public String getUserId() {
return userId;
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-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -30,11 +30,8 @@
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.task.Assignable;
-import org.jbpm.task.GroupRef;
-import org.jbpm.task.IdentityRef;
import org.jbpm.task.Participation;
import org.jbpm.task.Swimlane;
-import org.jbpm.task.UserRef;
/**
* runtime process role for a specific process instance.
@@ -70,24 +67,18 @@
return participations;
}
- public Participation addParticipant(IdentityRef identityRef, String participation) {
- if (identityRef==null) {
- throw new JbpmException("identityRef is null");
- }
- if (participation==null) {
- throw new JbpmException("participation is null");
- }
- return addParticipant(new ParticipationImpl(identityRef, participation));
- }
-
public void addCandidateGroup(String groupId) {
- addParticipant(new GroupRef(groupId), Participation.CANDIDATE);
+ addParticipation(null, groupId, Participation.CANDIDATE);
}
public void addCandidateUser(String userId) {
- addParticipant(new UserRef(userId), Participation.CANDIDATE);
+ addParticipation(userId, null, Participation.CANDIDATE);
}
+ public Participation addParticipation(String userId, String groupId, String type) {
+ return addParticipant(new ParticipationImpl(userId, groupId, type));
+ }
+
private Participation addParticipant(ParticipationImpl participant) {
participant.setSwimlane(this);
if (participations ==null) {
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-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -46,14 +46,11 @@
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.session.TaskDbSession;
import org.jbpm.task.Assignable;
-import org.jbpm.task.GroupRef;
-import org.jbpm.task.IdentityRef;
import org.jbpm.task.OpenTask;
import org.jbpm.task.Participation;
import org.jbpm.task.Swimlane;
import org.jbpm.task.Task;
import org.jbpm.task.TaskHandler;
-import org.jbpm.task.UserRef;
/**
* is one task instance that can be assigned to an actor (read: put in
@@ -151,42 +148,36 @@
}
return allRoles;
}
-
- public Participation addParticipant(IdentityRef identityRef, String participation) {
- if (identityRef==null) {
- throw new JbpmException("identityRef is null");
- }
- if (participation==null) {
- throw new JbpmException("participation is null");
- }
- return addParticipant(new ParticipationImpl(identityRef, participation));
- }
public void addCandidateGroup(String groupId) {
- addParticipant(new GroupRef(groupId), Participation.CANDIDATE);
+ addParticipation(null, groupId, Participation.CANDIDATE);
}
public void addCandidateUser(String userId) {
- addParticipant(new UserRef(userId), Participation.CANDIDATE);
+ addParticipation(userId, null, Participation.CANDIDATE);
}
- private Participation addParticipant(ParticipationImpl participant) {
- participant.setTask(this);
+ public Participation addParticipation(String userId, String groupId, String type) {
+ return addParticipant(new ParticipationImpl(userId, groupId, type));
+ }
+
+ private Participation addParticipant(ParticipationImpl participation) {
+ participation.setTask(this);
if (participations ==null) {
participations = new HashSet<ParticipationImpl>();
}
- participations.add(participant);
- return participant;
+ participations.add(participation);
+ return participation;
}
- public void removeParticipant(ParticipationImpl participant) {
- if (participant==null) {
+ public void removeParticipant(ParticipationImpl participation) {
+ if (participation==null) {
throw new JbpmException("participant is null");
}
if ( (participations !=null)
- && (participations.remove(participant))
+ && (participations.remove(participation))
) {
- ((ParticipationImpl)participant).setTask(null);
+ participation.setTask(null);
}
}
@@ -490,6 +481,4 @@
public void setSignalling(boolean isSignalling) {
this.isSignalling = isSignalling;
}
-
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -130,7 +130,7 @@
hql.append(" as participant ");
appendWhereClause("participant.task = task ", hql);
- appendWhereClause("participant.participation = 'candidate' ", hql);
+ appendWhereClause("participant.type = 'candidate' ", hql);
IdentitySession identitySession = Environment.getFromCurrent(IdentitySession.class);
List<Group> groups = identitySession.findGroupsByUser(takableBy);
Modified: jbpm4/trunk/modules/pvm/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/jbpm.task.hbm.xml 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/pvm/src/test/resources/jbpm.task.hbm.xml 2009-03-31 14:52:44 UTC (rev 4367)
@@ -142,7 +142,7 @@
<property name="groupId" column="GROUPID_"/>
<property name="userId" column="USERID_"/>
- <property name="participation" column="PARTICIPATION_" />
+ <property name="type" column="TYPE_" />
<many-to-one name="task"
class="TaskImpl"
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskParticipationsTest.java 2009-03-31 14:52:44 UTC (rev 4367)
@@ -25,11 +25,8 @@
import java.util.List;
import java.util.Set;
-import org.jbpm.task.GroupRef;
-import org.jbpm.task.IdentityRef;
import org.jbpm.task.Participation;
import org.jbpm.task.Task;
-import org.jbpm.task.UserRef;
import org.jbpm.test.JbpmTestCase;
@@ -43,60 +40,81 @@
task.setName("do laundry");
long taskDbid = saveAndRegisterTask(task);
- taskService.addTaskParticipant(taskDbid, new UserRef("johndoe"), Participation.CANDIDATE);
- taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participation.CANDIDATE);
- taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participation.OWNER);
- taskService.addTaskParticipant(taskDbid, new GroupRef("losers"), Participation.CANDIDATE);
- taskService.addTaskParticipant(taskDbid, new GroupRef("dummies"), Participation.CANDIDATE);
+ taskService.addTaskParticipatingUser(taskDbid, "johndoe", Participation.CANDIDATE);
+ taskService.addTaskParticipatingUser(taskDbid, "joesmoe", Participation.CANDIDATE);
+ taskService.addTaskParticipatingUser(taskDbid, "joesmoe", Participation.OWNER);
+ taskService.addTaskParticipatingGroup(taskDbid, "losers", Participation.CANDIDATE);
+ taskService.addTaskParticipatingGroup(taskDbid, "dummies", Participation.CANDIDATE);
- List<Participation> taskParticipations = taskService.getTaskParticipants(taskDbid);
+ List<Participation> taskParticipations = taskService.getTaskParticipations(taskDbid);
- Set<IdentityRef> candidateIdentityRefs = getIdentityRefs(taskParticipations, Participation.CANDIDATE);
+ Set<String> candidateUserIds = extractParticipatingUserIds(taskParticipations, Participation.CANDIDATE);
+ Set<String> ownerUserIds = extractParticipatingUserIds(taskParticipations, Participation.OWNER);
+ Set<String> candidateGroupIds = extractParticipatingGroupIds(taskParticipations, Participation.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"));
+ Set<String> expectedIds = new HashSet<String>();
+ expectedIds.add("johndoe");
+ expectedIds.add("joesmoe");
- assertEquals(expectedIdentityRefs, candidateIdentityRefs);
-
- candidateIdentityRefs = getIdentityRefs(taskParticipations, Participation.OWNER);
+ assertEquals(expectedIds, candidateUserIds);
- expectedIdentityRefs = new HashSet<IdentityRef>();
- expectedIdentityRefs.add(new UserRef("joesmoe"));
+ expectedIds = new HashSet<String>();
+ expectedIds.add("joesmoe");
- assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+ assertEquals(expectedIds, ownerUserIds);
- taskService.removeTaskParticipant(taskDbid, new UserRef("joesmoe"), Participation.OWNER);
- taskService.removeTaskParticipant(taskDbid, new GroupRef("losers"), Participation.CANDIDATE);
+ expectedIds = new HashSet<String>();
+ expectedIds.add("losers");
+ expectedIds.add("dummies");
+ assertEquals(expectedIds, candidateGroupIds);
- taskParticipations = taskService.getTaskParticipants(taskDbid);
+ taskService.removeTaskParticipatingUser(taskDbid, "joesmoe", Participation.OWNER);
+ taskService.removeTaskParticipatingGroup(taskDbid, "losers", Participation.CANDIDATE);
- candidateIdentityRefs = getIdentityRefs(taskParticipations, Participation.CANDIDATE);
+ taskParticipations = taskService.getTaskParticipations(taskDbid);
- expectedIdentityRefs = new HashSet<IdentityRef>();
- expectedIdentityRefs.add(new UserRef("johndoe"));
- expectedIdentityRefs.add(new UserRef("joesmoe"));
- expectedIdentityRefs.add(new GroupRef("dummies"));
+ candidateUserIds = extractParticipatingUserIds(taskParticipations, Participation.CANDIDATE);
+ ownerUserIds = extractParticipatingUserIds(taskParticipations, Participation.OWNER);
+ candidateGroupIds = extractParticipatingGroupIds(taskParticipations, Participation.CANDIDATE);
- assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+ expectedIds = new HashSet<String>();
+ expectedIds.add("johndoe");
+ expectedIds.add("joesmoe");
+
+ assertEquals(expectedIds, candidateUserIds);
+
+ expectedIds = new HashSet<String>();
+
+ assertEquals(expectedIds, ownerUserIds);
- candidateIdentityRefs = getIdentityRefs(taskParticipations, Participation.OWNER);
+ expectedIds = new HashSet<String>();
+ expectedIds.add("dummies");
- expectedIdentityRefs = new HashSet<IdentityRef>();
+ assertEquals(expectedIds, candidateGroupIds);
+ }
- assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+ public Set<String> extractParticipatingUserIds(List<Participation> taskParticipations, String participationType) {
+ Set<String> userIds = new HashSet<String>();
+ for (Participation participation : taskParticipations) {
+ if (participationType.equals(participation.getType())) {
+ if (participation.getUserId()!=null) {
+ userIds.add(participation.getUserId());
+ }
+ }
+ }
+ return userIds;
}
- public Set<IdentityRef> getIdentityRefs(List<Participation> taskParticipations, String participation) {
- Set<IdentityRef> identityRefs = new HashSet<IdentityRef>();
- for (Participation p : taskParticipations) {
- if (participation.equals(p.getType())) {
- identityRefs.add(p.getIdentityRef());
+ public Set<String> extractParticipatingGroupIds(List<Participation> taskParticipations, String participationType) {
+ Set<String> groupIds = new HashSet<String>();
+ for (Participation participation : taskParticipations) {
+ if (participationType.equals(participation.getType())) {
+ if (participation.getGroupId()!=null) {
+ groupIds.add(participation.getGroupId());
+ }
}
}
- return identityRefs;
+ return groupIds;
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.task.hbm.xml 2009-03-31 09:48:59 UTC (rev 4366)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.task.hbm.xml 2009-03-31 14:52:44 UTC (rev 4367)
@@ -142,7 +142,7 @@
<property name="groupId" column="GROUPID_"/>
<property name="userId" column="USERID_"/>
- <property name="participation" column="PARTICIPATION_" />
+ <property name="type" column="TYPE_" />
<many-to-one name="task"
class="TaskImpl"
More information about the jbpm-commits
mailing list