[jbpm-commits] JBoss JBPM SVN: r4302 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/task and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Mar 20 16:39:04 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-03-20 16:39:04 -0400 (Fri, 20 Mar 2009)
New Revision: 4302
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/variables/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/variables/TaskVariablesTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/variables/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/variables/process.jpdl.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AbstractServiceImpl.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
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/IdentityService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ManagementService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.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/wire/binding/IdentityServiceBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java
Log:
JBPM-2118 process variables
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -21,6 +21,7 @@
*/
package org.jbpm;
+import java.sql.Connection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -121,10 +122,10 @@
ExecutionQuery createProcessInstanceQuery();
/** creates or overwrites a variable value on the referenced execution */
- Execution setVariable(String executionId, String name, Object value);
+ void setVariable(String executionId, String name, Object value);
/** creates or overwrites the variable values on the referenced execution */
- Execution setVariables(String executionId, Map<String, Object> variables);
+ void setVariables(String executionId, Map<String, Object> variables);
/** retrieves a variable */
Object getVariable(String executionId, String variableName);
@@ -140,4 +141,13 @@
/** delete a process instance */
void deleteProcessInstance(String processInstanceId);
+
+
+ /** provide a userId that will be used in the next method invocation
+ * on this service by this thread. */
+ void setUserId(String userId);
+
+ /** provide a JDBC connection that will be used in the next method
+ * invocation on this service by this thread. */
+ void setConnection(Connection connection);
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryService.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryService.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -21,6 +21,7 @@
*/
package org.jbpm;
+import java.sql.Connection;
import java.util.Map;
import org.jbpm.history.HistoryActivityInstanceQuery;
@@ -43,4 +44,14 @@
/** returns for each transitionName, the number of times that transition was taken */
Map<String, Integer> choiceDistribution(String processDefinitionId, String activityName);
+
+
+ /** provide a userId that will be used in the next method invocation
+ * on this service by this thread. */
+ void setUserId(String userId);
+
+ /** provide a JDBC connection that will be used in the next method
+ * invocation on this service by this thread. */
+ void setConnection(Connection connection);
+
}
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-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/IdentityService.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -21,6 +21,7 @@
*/
package org.jbpm;
+import java.sql.Connection;
import java.util.List;
import org.jbpm.identity.Group;
@@ -88,4 +89,11 @@
* not throw an exception and have no effect. */
void deleteMembership(String userId, String groupId, String role);
+ /** provide a userId that will be used in the next method invocation
+ * on this service by this thread. */
+ void setUserId(String userId);
+
+ /** provide a JDBC connection that will be used in the next method
+ * invocation on this service by this thread. */
+ void setConnection(Connection connection);
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ManagementService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ManagementService.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ManagementService.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -21,8 +21,10 @@
*/
package org.jbpm;
+import java.sql.Connection;
+
/** operations targeted to system operators that need to keep
* the process engine up and running. This functionality is typically
* exposed through a management web console.
@@ -41,4 +43,11 @@
/** search for jobs */
JobQuery createJobQuery();
+ /** provide a userId that will be used in the next method invocation
+ * on this service by this thread. */
+ void setUserId(String userId);
+
+ /** provide a JDBC connection that will be used in the next method
+ * invocation on this service by this thread. */
+ void setConnection(Connection connection);
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -21,6 +21,7 @@
*/
package org.jbpm;
+import java.sql.Connection;
import java.util.List;
@@ -59,4 +60,13 @@
/** retrieves an attachment of a process definition */
byte[] getAttachment(String processDefinitionId, String name);
+
+
+ /** provide a userId that will be used in the next method invocation
+ * on this service by this thread. */
+ void setUserId(String userId);
+
+ /** provide a JDBC connection that will be used in the next method
+ * invocation on this service by this thread. */
+ void setConnection(Connection connection);
}
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-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -23,6 +23,8 @@
import java.sql.Connection;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.jbpm.model.Comment;
import org.jbpm.task.GroupRef;
@@ -61,8 +63,12 @@
Task getTask(long taskDbid);
/** Marks the task with the given identifier as completed.
- * This operation may result in a process instance being resumed. */
+ * This operation may result in a process instance being triggered. */
void submitTask(long taskDbid);
+
+ /** Marks the task with the given identifier as completed.
+ * This operation may result in a process instance being triggered. */
+ void submit(long taskDbid, Map<String, Object> variables);
/** Removes the task with the given identifier from persistent storage. */
void deleteTask(long taskDbid);
@@ -133,6 +139,22 @@
* this will recursively delete all replies to this comment. */
void deleteComment(long commentDbid);
+ /** creates or overwrites a variable value on the given task */
+ void setVariable(long taskDbid, String name, Object value);
+
+ /** creates or overwrites the variable values on the given task */
+ void setVariables(long taskDbid, Map<String, Object> variables);
+
+ /** retrieves a variable */
+ Object getVariable(long taskDbid, String variableName);
+
+ /** all the variables visible in the given task */
+ Set<String> getVariableNames(long taskDbid);
+
+ /** retrieves a map of variables */
+ Map<String, Object> getVariables(long taskDbid, Set<String> variableNames);
+
+
/** provide a userId that will be used in the next method invocation
* on this service by this thread. */
void setUserId(String userId);
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/variables/TaskVariablesTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/variables/TaskVariablesTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/variables/TaskVariablesTest.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -0,0 +1,65 @@
+/*
+ * 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.examples.task.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskVariablesTest extends JbpmTestCase {
+
+ public void testTaskAssignee() {
+ deployJpdlResource("org/jbpm/examples/task/variables/process.jpdl.xml");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("category", "big");
+ variables.put("dollars", 100000);
+ executionService.startProcessInstanceByKey("TaskVariables", variables);
+
+ List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+ Task task = taskList.get(0);
+ long taskDbid = task.getDbid();
+
+ Set<String> variableNames = taskService.getVariableNames(taskDbid);
+
+ Set<String> expectedVariableNames = new HashSet<String>();
+ expectedVariableNames.add("category");
+ expectedVariableNames.add("dollars");
+
+ assertEquals(expectedVariableNames, variableNames);
+
+ Map<String, Object> expectedVariables = variables;
+
+ variables = taskService.getVariables(taskDbid, variableNames);
+
+ assertEquals(expectedVariables, variables);
+ }
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/variables/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/variables/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/variables/process.jpdl.xml 2009-03-20 20:39:04 UTC (rev 4302)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="TaskVariables">
+
+ <start g="20,20,48,48">
+ <transition to="review" />
+ </start>
+
+ <task name="review"
+ assignee="johndoe"
+ g="96,16,127,52">
+
+ <transition to="wait" />
+ </task>
+
+ <state name="wait" g="255,16,88,52"/>
+
+</process>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -46,10 +46,13 @@
TaskDbSession taskDbSession = Environment.getFromCurrent(TaskDbSession.class);
TaskImpl task = TaskImpl.create();
task.setExecution(execution);
- task.setName(execution.getActivityName());
taskDefinition.initialize(task);
+ if (task.getName()==null) {
+ task.setName(execution.getActivityName());
+ }
+
taskDbSession.saveTask(task);
execution.historyTaskStart(task);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariableNamesCmd.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -25,9 +25,10 @@
import org.jbpm.JbpmException;
import org.jbpm.client.ClientExecution;
-import org.jbpm.cmd.Command;
import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.session.PvmDbSession;
+import org.jbpm.session.TaskDbSession;
/**
@@ -38,6 +39,7 @@
private static final long serialVersionUID = 1L;
String executionId;
+ long taskDbid;
public GetVariableNamesCmd(String executionId) {
if (executionId==null) {
@@ -46,10 +48,21 @@
this.executionId = executionId;
}
+ public GetVariableNamesCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
+ }
+
public Set<String> execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- ClientExecution execution = pvmDbSession.findExecutionById(executionId);
- return execution.getVariableKeys();
+ if (executionId!=null) {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ ClientExecution execution = pvmDbSession.findExecutionById(executionId);
+ return execution.getVariableKeys();
+
+ } else {
+ TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+ TaskImpl task = (TaskImpl) taskDbSession.findTaskByDbid(taskDbid);
+ return task.getVariableKeys();
+ }
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetVariablesCmd.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -27,9 +27,10 @@
import org.jbpm.JbpmException;
import org.jbpm.client.ClientExecution;
-import org.jbpm.cmd.Command;
import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.session.PvmDbSession;
+import org.jbpm.session.TaskDbSession;
/**
* @author Tom Baeyens
@@ -39,6 +40,7 @@
private static final long serialVersionUID = 1L;
protected String executionId;
+ protected long taskDbid;
protected Set<String> variableNames;
public GetVariablesCmd(String executionId, Set<String> variableNames) {
@@ -52,15 +54,29 @@
this.variableNames = variableNames;
}
+ public GetVariablesCmd(long taskDbid, Set<String> variableNames) {
+ this.taskDbid = taskDbid;
+ this.variableNames = variableNames;
+ }
+
public Map<String, Object> execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
-
- ClientExecution execution = pvmDbSession.findExecutionById(executionId);
-
Map<String, Object> variables = new HashMap<String, Object>();
- for (String variableName : variableNames) {
- Object value = execution.getVariable(variableName);
- variables.put(variableName, value);
+
+ if (executionId!=null) {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ ClientExecution execution = pvmDbSession.findExecutionById(executionId);
+ for (String variableName : variableNames) {
+ Object value = execution.getVariable(variableName);
+ variables.put(variableName, value);
+ }
+
+ } else {
+ TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+ TaskImpl task = (TaskImpl) taskDbSession.findTaskByDbid(taskDbid);
+ for (String variableName : variableNames) {
+ Object value = task.getVariable(variableName);
+ variables.put(variableName, value);
+ }
}
return variables;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SetVariablesCmd.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -21,20 +21,24 @@
*/
package org.jbpm.pvm.internal.cmd;
-import org.jbpm.Execution;
+import java.util.Map;
+
import org.jbpm.JbpmException;
import org.jbpm.client.ClientExecution;
import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.session.TaskDbSession;
/**
* @author Tom Baeyens
*/
-public class SetVariablesCmd extends VariablesCmd<Execution> {
+public class SetVariablesCmd extends VariablesCmd<Void> {
private static final long serialVersionUID = 1L;
protected String executionId = null;
+ protected long taskDbid;
public SetVariablesCmd(String executionId) {
if (executionId==null) {
@@ -43,15 +47,22 @@
this.executionId = executionId;
}
- public SetVariablesCmd(String executionId, String key, Object variable) {
- this(executionId);
- addVariable(key, variable);
+ public SetVariablesCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
- public Execution execute(Environment environment) throws Exception {
- ClientExecution execution = getExecution(environment, executionId);
- execution.setVariables(variables);
- return execution;
+ public Void execute(Environment environment) throws Exception {
+ if (executionId!=null) {
+ ClientExecution execution = getExecution(environment, executionId);
+ execution.setVariables(variables);
+
+ } else {
+ TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+ TaskImpl task = (TaskImpl) taskDbSession.findTaskByDbid(taskDbid);
+ task.setVariables(variables);
+ }
+
+ return null;
}
public String getExecutionId() {
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -1,105 +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.identity.impl;
-
-import java.util.List;
-
-import org.jbpm.IdentityService;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.identity.Group;
-import org.jbpm.identity.User;
-import org.jbpm.pvm.internal.identity.cmd.CreateGroup;
-import org.jbpm.pvm.internal.identity.cmd.CreateMembership;
-import org.jbpm.pvm.internal.identity.cmd.CreateUser;
-import org.jbpm.pvm.internal.identity.cmd.DeleteGroup;
-import org.jbpm.pvm.internal.identity.cmd.DeleteMembership;
-import org.jbpm.pvm.internal.identity.cmd.DeleteUser;
-import org.jbpm.pvm.internal.identity.cmd.FindGroup;
-import org.jbpm.pvm.internal.identity.cmd.FindGroups;
-import org.jbpm.pvm.internal.identity.cmd.FindUser;
-import org.jbpm.pvm.internal.identity.cmd.FindUsers;
-
-
-/**
- * @author Tom Baeyens
- */
-public class IdentityServiceImpl implements IdentityService {
-
- protected CommandService commandService;
-
- public void createUser(String userId, String givenName, String familyName) {
- commandService.execute(new CreateUser(userId, givenName, familyName));
- }
-
- public User findUserById(String userId) {
- return commandService.execute(new FindUser(userId));
- }
-
- public List<User> findUsers() {
- return commandService.execute(new FindUsers());
- }
-
- public void deleteUser(String userId) {
- commandService.execute(new DeleteUser(userId));
- }
-
- public String createGroup(String groupName) {
- return commandService.execute(new CreateGroup(groupName, null, null));
- }
-
- public String createGroup(String groupName, String groupType) {
- return commandService.execute(new CreateGroup(groupName, groupType, null));
- }
-
- public String createGroup(String groupName, String groupType, String parentGroupId) {
- return commandService.execute(new CreateGroup(groupName, groupType, parentGroupId));
- }
-
- public Group findGroupById(String groupId) {
- return commandService.execute(new FindGroup(groupId));
- }
-
- public List<Group> findGroupsByUser(String userId) {
- return commandService.execute(new FindGroups(userId));
- }
-
- public List<Group> findGroupsByUserAndGroupType(String userId, String groupType) {
- return commandService.execute(new FindGroups(userId, groupType));
- }
-
- public void deleteGroup(String groupId) {
- commandService.execute(new DeleteGroup(groupId));
- }
-
- public void createMembership(String userId, String groupId) {
- commandService.execute(new CreateMembership(userId, groupId, null));
- }
-
- public void createMembership(String userId, String groupId, String role) {
- commandService.execute(new CreateMembership(userId, groupId, role));
- }
-
-
- public void deleteMembership(String userId, String groupId, String role) {
- commandService.execute(new DeleteMembership(userId, groupId, role));
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AbstractServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AbstractServiceImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AbstractServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -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.svc;
+
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.WireObject;
+import org.jbpm.pvm.internal.cmd.AbstractCommand;
+import org.jbpm.pvm.internal.env.ProvidedAuthentication;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AbstractServiceImpl {
+
+ protected CommandService commandService;
+ protected ThreadLocal<List<WireObject>> contextThreadLocal;
+
+ public CommandService getCommandService() {
+ return commandService;
+ }
+
+ public void setCommandService(CommandService commandService) {
+ this.commandService = commandService;
+ }
+
+ public void setUserId(String userId) {
+ addTxWireObject(new WireObject(new ProvidedAuthentication(userId)));
+ }
+
+ public void setConnection(Connection connection) {
+ addTxWireObject(new WireObject(connection));
+ }
+
+ protected synchronized void addTxWireObject(WireObject wireObject) {
+ if (contextThreadLocal==null) {
+ contextThreadLocal = new ThreadLocal<List<WireObject>>();
+ }
+ List<WireObject> txWireObjects = contextThreadLocal.get();
+ if (txWireObjects==null) {
+ txWireObjects = new ArrayList<WireObject>();
+ contextThreadLocal.set(txWireObjects);
+ }
+ txWireObjects.add(wireObject);
+ }
+
+ protected void addTxWireObjects(AbstractCommand cmd) {
+ if (contextThreadLocal!=null) {
+ cmd.setTxWireObjects(contextThreadLocal.get());
+ contextThreadLocal.set(null);
+ }
+ }
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -30,12 +30,10 @@
import org.jbpm.ExecutionQuery;
import org.jbpm.ExecutionService;
import org.jbpm.cmd.CommandService;
-import org.jbpm.history.HistoryActivityInstanceQuery;
-import org.jbpm.history.HistoryProcessInstanceQuery;
import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
import org.jbpm.pvm.internal.cmd.EndProcessInstance;
-import org.jbpm.pvm.internal.cmd.FindExecutionsCmd;
import org.jbpm.pvm.internal.cmd.FindExecutionCmd;
+import org.jbpm.pvm.internal.cmd.FindExecutionsCmd;
import org.jbpm.pvm.internal.cmd.GetVariableNamesCmd;
import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
import org.jbpm.pvm.internal.cmd.SetVariablesCmd;
@@ -43,17 +41,13 @@
import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
import org.jbpm.pvm.internal.cmd.StartExecutionInLatestCmd;
import org.jbpm.pvm.internal.query.ExecutionQueryImpl;
-import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
-import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
/**
* @author Tom Baeyens
*/
-public class ExecutionServiceImpl implements ExecutionService {
+public class ExecutionServiceImpl extends AbstractServiceImpl implements ExecutionService {
- protected CommandService commandService;
-
public Execution startProcessInstanceById(String processDefinitionId){
return commandService.execute(new StartExecutionCmd(processDefinitionId, null, null));
}
@@ -69,8 +63,6 @@
public Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables, String executionKey){
return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, executionKey));
}
-
-
public Execution startProcessInstanceByKey(String processDefinitionKey) {
return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, null, null));
@@ -168,15 +160,15 @@
return commandService.execute(new GetVariablesCmd(executionId, variableNames));
}
- public Execution setVariable(String executionId, String name, Object value) {
+ public void setVariable(String executionId, String name, Object value) {
SetVariablesCmd cmd = new SetVariablesCmd(executionId);
cmd.addVariable(name, value);
- return commandService.execute(cmd);
+ commandService.execute(cmd);
}
- public Execution setVariables(String executionId, Map<String, Object> variables) {
+ public void setVariables(String executionId, Map<String, Object> variables) {
SetVariablesCmd cmd = new SetVariablesCmd(executionId);
cmd.setVariables(variables);
- return commandService.execute(cmd);
+ commandService.execute(cmd);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -24,7 +24,6 @@
import java.util.Map;
import org.jbpm.HistoryService;
-import org.jbpm.cmd.CommandService;
import org.jbpm.history.HistoryActivityInstanceQuery;
import org.jbpm.history.HistoryProcessInstanceQuery;
import org.jbpm.pvm.internal.query.AvgDurationPerActivityQueryCmd;
@@ -36,10 +35,8 @@
/**
* @author Tom Baeyens
*/
-public class HistoryServiceImpl implements HistoryService {
+public class HistoryServiceImpl extends AbstractServiceImpl implements HistoryService {
- protected CommandService commandService;
-
public Map<String, Long> avgDurationPerActivity(String processDefinitionId) {
return (Map) commandService.execute(new AvgDurationPerActivityQueryCmd(processDefinitionId));
}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java (from rev 4301, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentityServiceImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -0,0 +1,105 @@
+/*
+ * 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.svc;
+
+import java.util.List;
+
+import org.jbpm.IdentityService;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.pvm.internal.identity.cmd.CreateGroup;
+import org.jbpm.pvm.internal.identity.cmd.CreateMembership;
+import org.jbpm.pvm.internal.identity.cmd.CreateUser;
+import org.jbpm.pvm.internal.identity.cmd.DeleteGroup;
+import org.jbpm.pvm.internal.identity.cmd.DeleteMembership;
+import org.jbpm.pvm.internal.identity.cmd.DeleteUser;
+import org.jbpm.pvm.internal.identity.cmd.FindGroup;
+import org.jbpm.pvm.internal.identity.cmd.FindGroups;
+import org.jbpm.pvm.internal.identity.cmd.FindUser;
+import org.jbpm.pvm.internal.identity.cmd.FindUsers;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdentityServiceImpl extends AbstractServiceImpl implements IdentityService {
+
+ protected CommandService commandService;
+
+ public void createUser(String userId, String givenName, String familyName) {
+ commandService.execute(new CreateUser(userId, givenName, familyName));
+ }
+
+ public User findUserById(String userId) {
+ return commandService.execute(new FindUser(userId));
+ }
+
+ public List<User> findUsers() {
+ return commandService.execute(new FindUsers());
+ }
+
+ public void deleteUser(String userId) {
+ commandService.execute(new DeleteUser(userId));
+ }
+
+ public String createGroup(String groupName) {
+ return commandService.execute(new CreateGroup(groupName, null, null));
+ }
+
+ public String createGroup(String groupName, String groupType) {
+ return commandService.execute(new CreateGroup(groupName, groupType, null));
+ }
+
+ public String createGroup(String groupName, String groupType, String parentGroupId) {
+ return commandService.execute(new CreateGroup(groupName, groupType, parentGroupId));
+ }
+
+ public Group findGroupById(String groupId) {
+ return commandService.execute(new FindGroup(groupId));
+ }
+
+ public List<Group> findGroupsByUser(String userId) {
+ return commandService.execute(new FindGroups(userId));
+ }
+
+ public List<Group> findGroupsByUserAndGroupType(String userId, String groupType) {
+ return commandService.execute(new FindGroups(userId, groupType));
+ }
+
+ public void deleteGroup(String groupId) {
+ commandService.execute(new DeleteGroup(groupId));
+ }
+
+ public void createMembership(String userId, String groupId) {
+ commandService.execute(new CreateMembership(userId, groupId, null));
+ }
+
+ public void createMembership(String userId, String groupId, String role) {
+ commandService.execute(new CreateMembership(userId, groupId, role));
+ }
+
+
+ public void deleteMembership(String userId, String groupId, String role) {
+ commandService.execute(new DeleteMembership(userId, groupId, role));
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/IdentityServiceImpl.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/svc/ManagementServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -23,7 +23,6 @@
import org.jbpm.JobQuery;
import org.jbpm.ManagementService;
-import org.jbpm.cmd.CommandService;
import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
import org.jbpm.pvm.internal.query.JobQueryImpl;
@@ -31,10 +30,8 @@
/**
* @author Tom Baeyens
*/
-public class ManagementServiceImpl implements ManagementService {
+public class ManagementServiceImpl extends AbstractServiceImpl implements ManagementService {
- protected CommandService commandService;
-
public void executeJob(long jobDbid) {
commandService.execute(new ExecuteJobCmd(jobDbid));
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -28,7 +28,6 @@
import org.jbpm.ProcessDefinitionQuery;
import org.jbpm.ProcessService;
import org.jbpm.cmd.CommandService;
-import org.jbpm.model.OpenProcessDefinition;
import org.jbpm.pvm.internal.cmd.DeleteProcessDefinitionCmd;
import org.jbpm.pvm.internal.cmd.DeployCmd;
import org.jbpm.pvm.internal.cmd.FindLatestProcessDefinitionByKeyCmd;
@@ -43,10 +42,8 @@
*
* @author Tom Baeyens
*/
-public class ProcessServiceImpl implements ProcessService {
+public class ProcessServiceImpl extends AbstractServiceImpl implements ProcessService {
- protected CommandService commandService;
-
public Deployment createDeployment() {
return new DeploymentImpl(this);
}
@@ -78,7 +75,6 @@
public byte[] getAttachment(String processDefinitionId, String name) {
return commandService.execute(new GetAttachment(processDefinitionId, name));
}
-
public ProcessDefinitionQuery createProcessDefinitionQuery() {
return new ProcessDefinitionQueryImpl(commandService);
@@ -87,11 +83,4 @@
public List<ProcessDefinition> deploy(Deployment deployment) {
return commandService.execute(new DeployCmd((DeploymentImpl)deployment));
}
-
- public CommandService getCommandService() {
- return commandService;
- }
- public void setCommandService(CommandService commandService) {
- this.commandService = commandService;
- }
}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java (from rev 4301, 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/svc/TaskServiceImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -0,0 +1,210 @@
+/*
+ * 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.svc;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.TaskQuery;
+import org.jbpm.TaskService;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cmd.AddParticipantCmd;
+import org.jbpm.pvm.internal.cmd.AddReplyCommentCmd;
+import org.jbpm.pvm.internal.cmd.AddTaskCommentCmd;
+import org.jbpm.pvm.internal.cmd.CompositeCmd;
+import org.jbpm.pvm.internal.cmd.DeleteCommentCmd;
+import org.jbpm.pvm.internal.cmd.DeleteTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetParticipantsCmd;
+import org.jbpm.pvm.internal.cmd.GetSubTasksCmd;
+import org.jbpm.pvm.internal.cmd.GetTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetTaskCommentsCmd;
+import org.jbpm.pvm.internal.cmd.GetVariableNamesCmd;
+import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
+import org.jbpm.pvm.internal.cmd.NewTaskCmd;
+import org.jbpm.pvm.internal.cmd.RemoveParticipantCmd;
+import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
+import org.jbpm.pvm.internal.cmd.SetVariablesCmd;
+import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
+import org.jbpm.pvm.internal.cmd.TakeTaskCmd;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.task.TaskQueryImpl;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Task;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskServiceImpl extends AbstractServiceImpl implements TaskService {
+
+ public Task newTask() {
+ NewTaskCmd cmd = new NewTaskCmd(null);
+ addTxWireObjects(cmd);
+ return commandService.execute(cmd);
+ }
+
+ public Task getTask(long taskDbid) {
+ GetTaskCmd cmd = new GetTaskCmd(taskDbid);
+ return commandService.execute(cmd);
+ }
+
+ public long saveTask(Task task) {
+ SaveTaskCmd cmd = new SaveTaskCmd((TaskImpl) task);
+ return commandService.execute(cmd);
+ }
+
+ public void deleteTask(long taskDbid) {
+ DeleteTaskCmd cmd = new DeleteTaskCmd(taskDbid);
+ commandService.execute(cmd);
+ }
+
+ public void submitTask(long taskDbid) {
+ SubmitTaskCmd cmd = new SubmitTaskCmd(taskDbid);
+ commandService.execute(cmd);
+ }
+
+ public void submit(long taskDbid, Map<String, Object> variables) {
+ CompositeCmd compositeCmd = new CompositeCmd();
+ SetVariablesCmd setVariablesCommand = new SetVariablesCmd(taskDbid);
+ setVariablesCommand.setVariables(variables);
+ compositeCmd.addCommand(setVariablesCommand);
+ compositeCmd.addCommand(new SubmitTaskCmd(taskDbid));
+ commandService.execute(compositeCmd);
+ }
+
+ public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+ AddParticipantCmd cmd = new AddParticipantCmd(taskDbid, null, identityRef, participation);
+ commandService.execute(cmd);
+ }
+
+ public List<Participant> getTaskParticipants(long taskDbid) {
+ GetParticipantsCmd cmd = new GetParticipantsCmd(taskDbid, null);
+ return commandService.execute(cmd);
+ }
+
+ public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+ RemoveParticipantCmd cmd = new RemoveParticipantCmd(taskDbid, null, identityRef, participation);
+ commandService.execute(cmd);
+ }
+
+ public void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
+ AddParticipantCmd cmd = new AddParticipantCmd(null, szimlaneDbid, identityRef, participation);
+ commandService.execute(cmd);
+ }
+
+ public List<Participant> getSwimlaneParticipants(long szimlaneDbid) {
+ GetParticipantsCmd cmd = new GetParticipantsCmd(null, szimlaneDbid);
+ return commandService.execute(cmd);
+ }
+
+ public void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
+ RemoveParticipantCmd cmd = new RemoveParticipantCmd(null, szimlaneDbid, identityRef, participation);
+ commandService.execute(cmd);
+ }
+
+ public List<Task> getPersonalTaskList(String userId, int firstResult, int maxResults) {
+ return createTaskQuery()
+ .assignee(userId)
+ .orderDesc(TaskQuery.PROPERTY_PRIORITY)
+ .page(firstResult, maxResults)
+ .execute();
+ }
+
+ public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
+ return createTaskQuery()
+ .unassigned()
+ .candidate(userId)
+ .orderDesc(TaskQuery.PROPERTY_PRIORITY)
+ .page(firstResult, maxResults)
+ .execute();
+ }
+
+ public TaskQuery createTaskQuery() {
+ return new TaskQueryImpl(commandService);
+ }
+
+ public List<Task> getSubTasks(long taskDbid) {
+ GetSubTasksCmd cmd = new GetSubTasksCmd(taskDbid);
+ return commandService.execute(cmd);
+ }
+
+ public Task newTask(long parentTaskDbid) {
+ NewTaskCmd cmd = new NewTaskCmd(parentTaskDbid);
+ return commandService.execute(cmd);
+ }
+
+ public Comment addTaskComment(long taskDbid, String message) {
+ AddTaskCommentCmd cmd = new AddTaskCommentCmd(taskDbid, message);
+ return commandService.execute(cmd);
+ }
+
+ public List<Comment> getTaskComments(long taskDbid) {
+ GetTaskCommentsCmd cmd = new GetTaskCommentsCmd(taskDbid);
+ return commandService.execute(cmd);
+ }
+
+ public void deleteComment(long commentDbid) {
+ DeleteCommentCmd cmd = new DeleteCommentCmd(commentDbid);
+ commandService.execute(cmd);
+ }
+
+ public Comment addReplyComment(long commentDbid, String message) {
+ AddReplyCommentCmd cmd = new AddReplyCommentCmd(commentDbid, message);
+ return commandService.execute(cmd);
+ }
+
+ public void takeTask(long taskDbid) {
+ TakeTaskCmd cmd = new TakeTaskCmd(taskDbid);
+ addTxWireObjects(cmd);
+ commandService.execute(cmd);
+ }
+
+ public Object getVariable(long taskDbid, String variableName) {
+ Set<String> variableNames = new HashSet<String>();
+ variableNames.add(variableName);
+ GetVariablesCmd cmd = new GetVariablesCmd(taskDbid, variableNames);
+ Map<String, Object> variables = commandService.execute(cmd);
+ return variables.get(variableName);
+ }
+
+ public Set<String> getVariableNames(long taskDbid) {
+ return commandService.execute(new GetVariableNamesCmd(taskDbid));
+ }
+
+ public Map<String, Object> getVariables(long taskDbid, Set<String> variableNames) {
+ return commandService.execute(new GetVariablesCmd(taskDbid, variableNames));
+ }
+
+ public void setVariable(long taskDbid, String name, Object value) {
+ SetVariablesCmd cmd = new SetVariablesCmd(taskDbid);
+ cmd.addVariable(name, value);
+ commandService.execute(cmd);
+ }
+
+ public void setVariables(long taskDbid, Map<String, Object> variables) {
+ SetVariablesCmd cmd = new SetVariablesCmd(taskDbid);
+ cmd.setVariables(variables);
+ commandService.execute(cmd);
+ }
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -22,11 +22,13 @@
package org.jbpm.pvm.internal.task;
import java.io.Serializable;
+import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
import org.jbpm.JbpmException;
import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.cal.Duration;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ProcessElementImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
@@ -66,8 +68,14 @@
protected Descriptor assignerDescriptor;
public void initialize(TaskImpl task) {
+ task.setName(name);
+ task.setDescription(description);
+ task.setBlocking(isBlocking);
+ task.setSignalling(isSignalling);
task.setPriority(priority);
+ // TODO duedate calculation
+
if (assigneeExpression!=null) {
String assignee = resolveAssignmentExpression(assigneeExpression, assigneeExpressionLanguage, task.getExecution());
task.setAssignee(assignee);
@@ -91,7 +99,7 @@
}
}
}
-
+
protected String resolveAssignmentExpression(String expression, String expressionLanguage, ExecutionImpl execution) {
ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
Object result = scriptManager.evaluateExpression(expression, execution, expressionLanguage);
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-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -33,7 +33,6 @@
import org.jbpm.JbpmException;
import org.jbpm.env.Environment;
import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.cal.Duration;
import org.jbpm.pvm.internal.env.Authentication;
import org.jbpm.pvm.internal.model.CommentImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -117,25 +116,9 @@
return task;
}
-
- public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
- if (taskDefinition!=null) {
- this.name = taskDefinition.getName();
- this.description = taskDefinition.getDescription();
- this.isBlocking = taskDefinition.isBlocking();
- this.isSignalling = taskDefinition.isSignalling();
- this.priority = taskDefinition.getPriority();
-
- String durationText = taskDefinition.getDueDateDuration();
- if (durationText!=null) {
- this.dueDate = calculateDueDate(new Duration(durationText));
- }
- }
- }
- protected static Date calculateDueDate(Duration dueDate) {
- // TODO
- return null;
+ public ScopeInstanceImpl getParentVariableScope() {
+ return execution;
}
// participants /////////////////////////////////////////////////////////////
Deleted: 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-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -1,216 +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.sql.Connection;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.TaskQuery;
-import org.jbpm.TaskService;
-import org.jbpm.cmd.CommandService;
-import org.jbpm.env.WireObject;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.cmd.AbstractCommand;
-import org.jbpm.pvm.internal.cmd.AddParticipantCmd;
-import org.jbpm.pvm.internal.cmd.AddReplyCommentCmd;
-import org.jbpm.pvm.internal.cmd.AddTaskCommentCmd;
-import org.jbpm.pvm.internal.cmd.DeleteCommentCmd;
-import org.jbpm.pvm.internal.cmd.DeleteTaskCmd;
-import org.jbpm.pvm.internal.cmd.GetParticipantsCmd;
-import org.jbpm.pvm.internal.cmd.GetSubTasksCmd;
-import org.jbpm.pvm.internal.cmd.GetTaskCmd;
-import org.jbpm.pvm.internal.cmd.GetTaskCommentsCmd;
-import org.jbpm.pvm.internal.cmd.NewTaskCmd;
-import org.jbpm.pvm.internal.cmd.RemoveParticipantCmd;
-import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
-import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
-import org.jbpm.pvm.internal.cmd.TakeTaskCmd;
-import org.jbpm.pvm.internal.env.ProvidedAuthentication;
-import org.jbpm.task.IdentityRef;
-import org.jbpm.task.Participant;
-import org.jbpm.task.Task;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskServiceImpl implements TaskService {
-
- protected CommandService commandService;
-
- protected ThreadLocal<List<WireObject>> contextThreadLocal;
-
- public TaskServiceImpl() {
- }
-
- public TaskServiceImpl(CommandService commandService) {
- this.commandService = commandService;
- }
-
- public CommandService getCommandService() {
- return commandService;
- }
-
- public void setCommandService(CommandService commandService) {
- this.commandService = commandService;
- }
-
- public Task newTask() {
- NewTaskCmd cmd = new NewTaskCmd(null);
- addTxWireObjects(cmd);
- return commandService.execute(cmd);
- }
-
- public Task getTask(long taskDbid) {
- GetTaskCmd cmd = new GetTaskCmd(taskDbid);
- return commandService.execute(cmd);
- }
-
- public long saveTask(Task task) {
- SaveTaskCmd cmd = new SaveTaskCmd((TaskImpl) task);
- return commandService.execute(cmd);
- }
-
- public void deleteTask(long taskDbid) {
- DeleteTaskCmd cmd = new DeleteTaskCmd(taskDbid);
- commandService.execute(cmd);
- }
-
- public void submitTask(long taskDbid) {
- SubmitTaskCmd cmd = new SubmitTaskCmd(taskDbid);
- commandService.execute(cmd);
- }
-
- public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
- AddParticipantCmd cmd = new AddParticipantCmd(taskDbid, null, identityRef, participation);
- commandService.execute(cmd);
- }
-
- public List<Participant> getTaskParticipants(long taskDbid) {
- GetParticipantsCmd cmd = new GetParticipantsCmd(taskDbid, null);
- return commandService.execute(cmd);
- }
-
- public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
- RemoveParticipantCmd cmd = new RemoveParticipantCmd(taskDbid, null, identityRef, participation);
- commandService.execute(cmd);
- }
-
- public void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
- AddParticipantCmd cmd = new AddParticipantCmd(null, szimlaneDbid, identityRef, participation);
- commandService.execute(cmd);
- }
-
- public List<Participant> getSwimlaneParticipants(long szimlaneDbid) {
- GetParticipantsCmd cmd = new GetParticipantsCmd(null, szimlaneDbid);
- return commandService.execute(cmd);
- }
-
- public void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
- RemoveParticipantCmd cmd = new RemoveParticipantCmd(null, szimlaneDbid, identityRef, participation);
- commandService.execute(cmd);
- }
-
- public List<Task> getPersonalTaskList(String userId, int firstResult, int maxResults) {
- return createTaskQuery()
- .assignee(userId)
- .orderDesc(TaskQuery.PROPERTY_PRIORITY)
- .page(firstResult, maxResults)
- .execute();
- }
-
- public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
- return createTaskQuery()
- .unassigned()
- .candidate(userId)
- .orderDesc(TaskQuery.PROPERTY_PRIORITY)
- .page(firstResult, maxResults)
- .execute();
- }
-
- public TaskQuery createTaskQuery() {
- return new TaskQueryImpl(commandService);
- }
-
- public List<Task> getSubTasks(long taskDbid) {
- GetSubTasksCmd cmd = new GetSubTasksCmd(taskDbid);
- return commandService.execute(cmd);
- }
-
- public Task newTask(long parentTaskDbid) {
- NewTaskCmd cmd = new NewTaskCmd(parentTaskDbid);
- return commandService.execute(cmd);
- }
-
- public Comment addTaskComment(long taskDbid, String message) {
- AddTaskCommentCmd cmd = new AddTaskCommentCmd(taskDbid, message);
- return commandService.execute(cmd);
- }
-
- public List<Comment> getTaskComments(long taskDbid) {
- GetTaskCommentsCmd cmd = new GetTaskCommentsCmd(taskDbid);
- return commandService.execute(cmd);
- }
-
- public void deleteComment(long commentDbid) {
- DeleteCommentCmd cmd = new DeleteCommentCmd(commentDbid);
- commandService.execute(cmd);
- }
-
- public Comment addReplyComment(long commentDbid, String message) {
- AddReplyCommentCmd cmd = new AddReplyCommentCmd(commentDbid, message);
- return commandService.execute(cmd);
- }
-
- public void takeTask(long taskDbid) {
- TakeTaskCmd cmd = new TakeTaskCmd(taskDbid);
- addTxWireObjects(cmd);
- commandService.execute(cmd);
- }
-
- public void setUserId(String userId) {
- addTxWireObject(new WireObject(new ProvidedAuthentication(userId)));
- }
-
- public void setConnection(Connection connection) {
- addTxWireObject(new WireObject(connection));
- }
-
- protected synchronized void addTxWireObject(WireObject wireObject) {
- if (contextThreadLocal==null) {
- contextThreadLocal = new ThreadLocal<List<WireObject>>();
- }
- List<WireObject> txWireObjects = contextThreadLocal.get();
- if (txWireObjects==null) {
- txWireObjects = new ArrayList<WireObject>();
- contextThreadLocal.set(txWireObjects);
- }
- txWireObjects.add(wireObject);
- }
-
- protected void addTxWireObjects(AbstractCommand cmd) {
- if (contextThreadLocal!=null) {
- cmd.setTxWireObjects(contextThreadLocal.get());
- contextThreadLocal.set(null);
- }
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.identity.impl.IdentityServiceImpl;
+import org.jbpm.pvm.internal.svc.IdentityServiceImpl;
import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java 2009-03-20 16:51:42 UTC (rev 4301)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java 2009-03-20 20:39:04 UTC (rev 4302)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.task.TaskServiceImpl;
+import org.jbpm.pvm.internal.svc.TaskServiceImpl;
import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
More information about the jbpm-commits
mailing list