[jbpm-commits] JBoss JBPM SVN: r4347 - in jbpm4/branches/tbaeyens/modules: api/src/main/java/org/jbpm/session and 24 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Mar 29 07:04:11 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-03-29 07:04:09 -0400 (Sun, 29 Mar 2009)
New Revision: 4347
Added:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStreamCmd.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java
Removed:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStream.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/ProcessServiceTest.java
Modified:
jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java
jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/RepositoryService.java
jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/RepositorySession.java
jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml
jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml
jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java
jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.task.hbm.xml
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.task.hbm.xml
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml
jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java
jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.task.hbm.xml
jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
Log:
revisiting deployment
Modified: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ExecutionQuery.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -31,8 +31,6 @@
String PROPERTY_KEY = "key";
- ExecutionQuery processDefinitionNameLike(String processDefinitionName);
- ExecutionQuery processDefinitionKeyLike(String processDefinitionKey);
ExecutionQuery processDefinitionId(String processDefinitionId);
ExecutionQuery processInstanceId(String processInstanceId);
Modified: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinition.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -47,5 +47,8 @@
* represents the sequence number for process definitions with
* the same {@link ObservableElement#getId() name}. */
int getVersion();
-
+
+ /** references the deployment in which this process definition is
+ * deployed. */
+ long getDeploymentDbid();
}
Modified: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/ProcessDefinitionQuery.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -37,6 +37,8 @@
ProcessDefinitionQuery id(String id);
ProcessDefinitionQuery key(String key);
ProcessDefinitionQuery nameLike(String name);
+ ProcessDefinitionQuery name(String name);
+ ProcessDefinitionQuery deploymentDbid(long deploymentDbid);
ProcessDefinitionQuery orderAsc(String property);
ProcessDefinitionQuery orderDesc(String property);
Modified: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/RepositoryService.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/RepositoryService.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/RepositoryService.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -32,9 +32,10 @@
Deployment createDeployment();
void deleteDeployment(long deploymentDbid);
+ void deleteDeploymentCascade(long deploymentDbid);
InputStream getResourceAsStream(long deploymentDbid, String resourceName);
ProcessDefinitionQuery createProcessDefinitionQuery();
-}
\ No newline at end of file
+}
Modified: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -23,6 +23,7 @@
import java.util.List;
+import org.jbpm.Execution;
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.job.Job;
Modified: jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/RepositorySession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/RepositorySession.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/api/src/main/java/org/jbpm/session/RepositorySession.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -22,7 +22,6 @@
package org.jbpm.session;
import java.io.InputStream;
-import java.util.List;
import org.jbpm.Deployment;
import org.jbpm.ProcessDefinitionQuery;
@@ -42,9 +41,5 @@
ProcessDefinitionQuery createProcessDefinitionQuery();
-
- List<String> findObjectNames(String propertyKey, String propertyValue);
- List<String> findObjectPropertyValues(String objectName, String propertyKey);
- Object findObjectByPropertyValue(String propertyKey, String propertyValue);
- ClientProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey);
+ ClientProcessDefinition loadProcessDefinitionById(String processDefinitionId);
}
Modified: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.execution.hbm.xml 2009-03-29 11:04:09 UTC (rev 4347)
@@ -348,22 +348,4 @@
]]>
</query>
- <!-- query name="findExecutionByKey">
- <![CDATA[
- select execution
- from org.jbpm.pvm.internal.model.ExecutionImpl as execution
- where execution.key = :executionKey
- and execution.processDefinition.name = :processDefinitionName
- ]]>
- </query -->
-
- <query name="findProcessInstanceIds">
- <![CDATA[
- select processInstance.id
- from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
- where processInstance.processDefinitionId = :processDefinitionId
- and processInstance.parent is null
- ]]>
- </query>
-
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/hibernate/mapping.files/jbpm.task.hbm.xml 2009-03-29 11:04:09 UTC (rev 4347)
@@ -118,11 +118,7 @@
column="SWIMLANE_"
foreign-key="FK_TASK_SWIML" />
- <!-- many-to-one name="taskDefinition"
- column="TASKDEF_"
- class="org.jbpm.pvm.internal.task.TaskDefinitionImpl"
- foreign-key="FK_TSK_TASKDEF"
- index="IDX_TSK_TASKDEF" / -->
+ <property name="taskDefinitionName" column="TASKDEFNAME_"/>
<list name="comments" cascade="all-delete-orphan">
<key column="TASK_" />
Modified: jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/ejb/EjbTimerSessionTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -36,7 +36,7 @@
import org.jbpm.enterprise.internal.custom.WaitState;
import org.jbpm.env.Environment;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.cmd.StartProcessInstanceCmd;
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.session.DbSession;
@@ -118,7 +118,7 @@
public void testSchedule() throws CreateException {
// start an execution
environment.get(CommandService.class).execute(
- new StartExecutionCmd(processDefinitionId, null, null));
+ new StartProcessInstanceCmd(processDefinitionId, null, null));
// wait for activity to execute
Date executionDate = HappyListener.waitFor();
Modified: jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.task.hbm.xml 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.task.hbm.xml 2009-03-29 11:04:09 UTC (rev 4347)
@@ -118,11 +118,7 @@
column="SWIMLANE_"
foreign-key="FK_TASK_SWIML" />
- <!-- many-to-one name="taskDefinition"
- column="TASKDEF_"
- class="org.jbpm.pvm.internal.task.TaskDefinitionImpl"
- foreign-key="FK_TSK_TASKDEF"
- index="IDX_TSK_TASKDEF" / -->
+ <property name="taskDefinitionName" column="TASKDEFNAME_"/>
<list name="comments" cascade="all-delete-orphan">
<key column="TASK_" />
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -21,13 +21,8 @@
*/
package org.jbpm.jpdl.internal.activity;
-import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.jbpm.pvm.internal.task.AssignableDefinitionImpl;
-import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -46,68 +41,9 @@
public Object parse(Element element, Parse parse, Parser parser) {
TaskActivity taskActivity = new TaskActivity();
- TaskDefinitionImpl taskDefinition = parseTaskDefinition(element, parse, parser);
+ TaskDefinitionImpl taskDefinition = JpdlParser.parseTaskDefinition(element, parse, parser);
taskActivity.setTaskDefinition(taskDefinition);
-
+
return taskActivity;
}
-
- public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, Parser parser) {
- TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
-
- taskDefinition.setName(XmlUtil.attribute(element, "name"));
-
- String swimlaneName = XmlUtil.attribute(element, "swimlane");
- if (swimlaneName!=null) {
- JpdlProcessDefinition jpdlProcessDefinition = parse.findObject(JpdlProcessDefinition.class);
- SwimlaneDefinitionImpl swimlaneDefinition = jpdlProcessDefinition.getSwimlaneDefinition(swimlaneName);
- if (swimlaneDefinition!=null) {
- taskDefinition.setSwimlaneDefinition(swimlaneDefinition);
- } else {
- parse.addProblem("swimlane "+swimlaneName+" not declared");
- }
- }
-
- Element taskHandlerElement = XmlUtil.element(element, "task-handler");
- if (taskHandlerElement!=null) {
- ObjectDescriptor objectDescriptor = JpdlParser.parseObjectDescriptor(taskHandlerElement, parse);
- taskDefinition.setTaskHandlerDescriptor(objectDescriptor);
- }
-
- parseAssignmentAttributes(element, taskDefinition, parse);
-
- return taskDefinition;
- }
-
- public static void parseAssignmentAttributes(Element element, AssignableDefinitionImpl assignableDefinition, Parse parse) {
- Element descriptionElement = XmlUtil.element(element, "description");
- if (descriptionElement!=null) {
- String description = XmlUtil.getContentText(descriptionElement);
- assignableDefinition.setDescription(description);
- }
-
- Element assignmentHandlerElement = XmlUtil.element(element, "assignment-handler");
- if (assignmentHandlerElement!=null) {
- ObjectDescriptor objectDescriptor = JpdlParser.parseObjectDescriptor(assignmentHandlerElement, parse);
- assignableDefinition.setAssignmentHandlerDescriptor(objectDescriptor);
- }
-
- String assigneeExpression = XmlUtil.attribute(element, "assignee");
- assignableDefinition.setAssigneeExpression(assigneeExpression);
-
- String assigneeExpressionLanguage = XmlUtil.attribute(element, "assignee-lang");
- assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
-
- String candidateUsersExpression = XmlUtil.attribute(element, "candidate-users");
- assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
-
- String candidateUsersExpressionLanguage = XmlUtil.attribute(element, "candidate-users-lang");
- assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
-
- String candidateGroupsExpression = XmlUtil.attribute(element, "candidate-groups");
- assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
-
- String candidateGroupsExpressionLanguage = XmlUtil.attribute(element, "candidate-groups-lang");
- assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
- }
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -44,6 +44,10 @@
private static Log log = Log.getLog(JpdlDeployer.class.getName());
+ public static final String KEY_ID = "id";
+ public static final String KEY_KEY = "key";
+ public static final String KEY_VERSION = "version";
+
static JpdlParser jpdlParser = new JpdlParser();
public void deploy(DeploymentImpl deployment) {
@@ -63,9 +67,9 @@
processDefinition.setDeploymentDbid(deployment.getDbid());
if (deployment.hasObjectProperties(processDefinitionName)) {
- String key = (String) deployment.getObjectProperty(processDefinitionName, "key");
- String id = (String) deployment.getObjectProperty(processDefinitionName, "id");
- String version = (String) deployment.getObjectProperty(processDefinitionName, "version");
+ String key = (String) deployment.getObjectProperty(processDefinitionName, KEY_KEY);
+ String id = (String) deployment.getObjectProperty(processDefinitionName, KEY_ID);
+ String version = (String) deployment.getObjectProperty(processDefinitionName, KEY_VERSION);
processDefinition.setId(id);
processDefinition.setKey(key);
processDefinition.setVersion(Integer.parseInt(version));
@@ -75,9 +79,9 @@
checkVersion(processDefinition, deployment);
checkId(processDefinition, deployment);
- deployment.addObjectProperty(processDefinitionName, "key", processDefinition.getKey());
- deployment.addObjectProperty(processDefinitionName, "version", new Long(processDefinition.getVersion()));
- deployment.addObjectProperty(processDefinitionName, "id", processDefinition.getId());
+ deployment.addObjectProperty(processDefinitionName, KEY_KEY, processDefinition.getKey());
+ deployment.addObjectProperty(processDefinitionName, KEY_VERSION, new Long(processDefinition.getVersion()));
+ deployment.addObjectProperty(processDefinitionName, KEY_ID, processDefinition.getId());
}
deployment.addObject(processDefinitionName, processDefinition);
@@ -99,18 +103,25 @@
}
RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
- List<String> existingKeys = repositorySession.findObjectPropertyValues(processDefinitionName, "jpdl.key");
- if ( (!existingKeys.isEmpty())
- && existingKeys.get(0).equals(processDefinitionKey)
- ) {
- deployment.addProblem("invalid key '"+processDefinitionKey+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+
+ List<ProcessDefinition> existingProcesses = repositorySession.createProcessDefinitionQuery()
+ .name(processDefinitionName)
+ .execute();
+
+ for (ProcessDefinition existingProcess: existingProcesses) {
+ if (!processDefinitionKey.equals(existingProcess.getKey())) {
+ deployment.addProblem("invalid key '"+processDefinitionKey+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ }
}
- List<String> existingNames = repositorySession.findObjectNames("jpdl.key", processDefinitionKey);
- if ( (!existingNames.isEmpty())
- && existingNames.get(0).equals(processDefinitionName)
- ) {
- deployment.addProblem("invalid name '"+processDefinitionName+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ existingProcesses = repositorySession.createProcessDefinitionQuery()
+ .key(processDefinitionKey)
+ .execute();
+
+ for (ProcessDefinition existingProcess: existingProcesses) {
+ if (!processDefinitionName.equals(existingProcess.getName())) {
+ deployment.addProblem("invalid name '"+processDefinitionName+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ }
}
}
@@ -123,7 +134,10 @@
}
RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
- if (repositorySession.findObjectByPropertyValue("jpdl.id", id) != null) {
+ ProcessDefinition existingProcessDefinition = repositorySession.createProcessDefinitionQuery()
+ .id(id)
+ .uniqueResult();
+ if (existingProcessDefinition != null) {
deployment.addProblem("process '" + id + "' already exists");
}
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -30,10 +30,12 @@
import org.jbpm.activity.ActivityBehaviour;
import org.jbpm.internal.log.Log;
import org.jbpm.jpdl.internal.activity.JpdlActivityBinding;
-import org.jbpm.jpdl.internal.activity.TaskBinding;
import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.task.AssignableDefinitionImpl;
import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
@@ -132,7 +134,7 @@
if (swimlaneName!=null) {
SwimlaneDefinitionImpl swimlaneDefinition =
processDefinition.createSwimlaneDefinition(swimlaneName);
- TaskBinding.parseAssignmentAttributes(swimlaneElement, swimlaneDefinition, parse);
+ JpdlParser.parseAssignmentAttributes(swimlaneElement, swimlaneDefinition, parse);
}
}
@@ -173,6 +175,73 @@
return processDefinition;
}
+ public static void parseAssignmentAttributes(Element element, AssignableDefinitionImpl assignableDefinition, Parse parse) {
+ Element descriptionElement = XmlUtil.element(element, "description");
+ if (descriptionElement!=null) {
+ String description = XmlUtil.getContentText(descriptionElement);
+ assignableDefinition.setDescription(description);
+ }
+
+ Element assignmentHandlerElement = XmlUtil.element(element, "assignment-handler");
+ if (assignmentHandlerElement!=null) {
+ ObjectDescriptor objectDescriptor = parseObjectDescriptor(assignmentHandlerElement, parse);
+ assignableDefinition.setAssignmentHandlerDescriptor(objectDescriptor);
+ }
+
+ String assigneeExpression = XmlUtil.attribute(element, "assignee");
+ assignableDefinition.setAssigneeExpression(assigneeExpression);
+
+ String assigneeExpressionLanguage = XmlUtil.attribute(element, "assignee-lang");
+ assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
+
+ String candidateUsersExpression = XmlUtil.attribute(element, "candidate-users");
+ assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
+
+ String candidateUsersExpressionLanguage = XmlUtil.attribute(element, "candidate-users-lang");
+ assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
+
+ String candidateGroupsExpression = XmlUtil.attribute(element, "candidate-groups");
+ assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
+
+ String candidateGroupsExpressionLanguage = XmlUtil.attribute(element, "candidate-groups-lang");
+ assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
+ }
+
+ public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, Parser parser) {
+ TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
+
+ String taskName = XmlUtil.attribute(element, "name");
+ taskDefinition.setName(taskName);
+
+ ProcessDefinitionImpl processDefinition = parse.findObject(ProcessDefinitionImpl.class);
+ if (processDefinition.getTaskDefinition(taskName)!=null) {
+ parse.addProblem("duplicate task name "+taskName);
+ } else {
+ processDefinition.addTaskDefinitionImpl(taskDefinition);
+ }
+
+ String swimlaneName = XmlUtil.attribute(element, "swimlane");
+ if (swimlaneName!=null) {
+ JpdlProcessDefinition jpdlProcessDefinition = parse.findObject(JpdlProcessDefinition.class);
+ SwimlaneDefinitionImpl swimlaneDefinition = jpdlProcessDefinition.getSwimlaneDefinition(swimlaneName);
+ if (swimlaneDefinition!=null) {
+ taskDefinition.setSwimlaneDefinition(swimlaneDefinition);
+ } else {
+ parse.addProblem("swimlane "+swimlaneName+" not declared");
+ }
+ }
+
+ Element taskHandlerElement = XmlUtil.element(element, "task-handler");
+ if (taskHandlerElement!=null) {
+ ObjectDescriptor objectDescriptor = parseObjectDescriptor(taskHandlerElement, parse);
+ taskDefinition.setTaskHandlerDescriptor(objectDescriptor);
+ }
+
+ JpdlParser.parseAssignmentAttributes(element, taskDefinition, parse);
+
+ return taskDefinition;
+ }
+
public static ObjectDescriptor parseObjectDescriptor(Element element, Parse parse) {
ObjectDescriptor objectDescriptor = new ObjectDescriptor();
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.task.hbm.xml 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.task.hbm.xml 2009-03-29 11:04:09 UTC (rev 4347)
@@ -118,11 +118,7 @@
column="SWIMLANE_"
foreign-key="FK_TASK_SWIML" />
- <!-- many-to-one name="taskDefinition"
- column="TASKDEF_"
- class="org.jbpm.pvm.internal.task.TaskDefinitionImpl"
- foreign-key="FK_TSK_TASKDEF"
- index="IDX_TSK_TASKDEF" / -->
+ <property name="taskDefinitionName" column="TASKDEFNAME_"/>
<list name="comments" cascade="all-delete-orphan">
<key column="TASK_" />
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+import org.jbpm.pvm.internal.repository.RepositoryCache;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.session.RepositorySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeleteDeploymentCmd implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ long deploymentDbid;
+ boolean cascade;
+
+ public DeleteDeploymentCmd(long deploymentDbid) {
+ this.deploymentDbid = deploymentDbid;
+ }
+
+ public DeleteDeploymentCmd(long deploymentDbid, boolean cascade) {
+ this.deploymentDbid = deploymentDbid;
+ this.cascade = cascade;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ RepositorySession repositorySession = environment.get(RepositorySession.class);
+ List<ProcessDefinition> processDefinitions = repositorySession.createProcessDefinitionQuery()
+ .deploymentDbid(deploymentDbid)
+ .execute();
+
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+
+ for (ProcessDefinition processDefinition: processDefinitions) {
+ String processDefinitionId = processDefinition.getId();
+ List<String> processInstanceIds = pvmDbSession.findProcessInstanceIds(processDefinitionId);
+ if (cascade) {
+ for (String processInstanceId: processInstanceIds) {
+ pvmDbSession.deleteProcessInstance(processInstanceId, false);
+ }
+ } else {
+ if (!processInstanceIds.isEmpty()) {
+ throw new JbpmException("cannot delete deployment "+deploymentDbid+": still executions for "+processDefinition+": "+processInstanceIds);
+ }
+ }
+ }
+
+ Session session = environment.get(Session.class);
+ DeploymentImpl deployment = (DeploymentImpl) session.load(DeploymentImpl.class, deploymentDbid);
+ session.delete(deployment);
+
+ RepositoryCache repositoryCache = environment.get(RepositoryCache.class);
+ repositoryCache.set(deploymentDbid, null);
+
+ return null;
+ }
+
+}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStream.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStream.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStream.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import java.io.InputStream;
-
-import org.jbpm.env.Environment;
-import org.jbpm.session.RepositorySession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class GetResourceAsStream extends AbstractCommand<InputStream> {
-
- private static final long serialVersionUID = 1L;
-
- protected long deploymentDbid;
- protected String resourceName;
-
- public GetResourceAsStream(long deploymentDbid, String resourceName) {
- this.deploymentDbid = deploymentDbid;
- this.resourceName = resourceName;
- }
-
- public InputStream execute(Environment environment) {
- RepositorySession repositorySession = environment.get(RepositorySession.class);
- InputStream resourceStream = repositorySession.getResourceAsStream(deploymentDbid, resourceName);
- return resourceStream;
- }
-}
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStreamCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStreamCmd.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetResourceAsStreamCmd.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.io.InputStream;
+
+import org.jbpm.env.Environment;
+import org.jbpm.session.RepositorySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetResourceAsStreamCmd extends AbstractCommand<InputStream> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected long deploymentDbid;
+ protected String resourceName;
+
+ public GetResourceAsStreamCmd(long deploymentDbid, String resourceName) {
+ this.deploymentDbid = deploymentDbid;
+ this.resourceName = resourceName;
+ }
+
+ public InputStream execute(Environment environment) {
+ RepositorySession repositorySession = environment.get(RepositorySession.class);
+ InputStream resourceStream = repositorySession.getResourceAsStream(deploymentDbid, resourceName);
+ return resourceStream;
+ }
+}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionCmd.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import java.util.Map;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.env.Environment;
-import org.jbpm.session.PvmDbSession;
-
-/**
- * @author Tom Baeyens
- */
-public class StartExecutionCmd extends VariablesCmd<Execution> {
-
- private static final long serialVersionUID = 1L;
-
- protected String processDefinitionId;
- protected String executionKey;
-
- public StartExecutionCmd(String processDefinitionId, Map<String, Object> variables, String executionKey) {
- this.processDefinitionId = processDefinitionId;
- this.variables = variables;
- this.executionKey = executionKey;
- }
-
- public Execution execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
-
- ClientProcessDefinition processDefinition = null;
-
- processDefinition = pvmDbSession.findProcessDefinitionById(processDefinitionId);
- if (processDefinition==null) {
- throw new JbpmException("no process definition with id '"+processDefinitionId+"'");
- }
-
- ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
- processInstance.setVariables(variables);
- processInstance.start();
-
- pvmDbSession.save(processInstance);
- return processInstance;
- }
-
- public String getProcessDefinitionKey() {
- return processDefinitionId;
- }
- public void setProcessDefinitionKey(String processDefinitionKey) {
- this.processDefinitionId = processDefinitionKey;
- }
- public String getExecutionKey() {
- return executionKey;
- }
- public void setExecutionKey(String executionKey) {
- this.executionKey = executionKey;
- }
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import java.util.Map;
-
-import org.hibernate.Session;
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.client.ClientProcessInstance;
-import org.jbpm.env.Environment;
-import org.jbpm.session.RepositorySession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class StartExecutionInLatestCmd extends VariablesCmd<Execution> {
-
- private static final long serialVersionUID = 1L;
-
- protected String processDefinitionKey;
- protected String executionKey;
-
- public StartExecutionInLatestCmd(String processDefinitionKey, Map<String, Object> variables, String executionKey) {
- if (processDefinitionKey==null) {
- throw new JbpmException("processDefinitionKey is null");
- }
- this.processDefinitionKey = processDefinitionKey;
- this.variables = variables;
- this.executionKey = executionKey;
- }
-
- public Execution execute(Environment environment) throws Exception {
- ClientProcessDefinition processDefinition = null;
-
- RepositorySession repositorySession = environment.get(RepositorySession.class);
- processDefinition = (ClientProcessDefinition) repositorySession
- .findObjectByPropertyValue("key", processDefinitionKey);
-
- if (processDefinition==null) {
- throw new JbpmException("no process definition with key '"+processDefinitionKey+"'");
- }
-
- ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
- processInstance.setVariables(variables);
- processInstance.start();
-
- Session session = Environment.getFromCurrent(Session.class);
- session.save(processInstance);
- return processInstance;
- }
-
- public String getExecutionKey() {
- return executionKey;
- }
- public void setExecutionKey(String executionKey) {
- this.executionKey = executionKey;
- }
-}
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Map;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.session.RepositorySession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartProcessInstanceCmd extends VariablesCmd<Execution> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String processDefinitionId;
+ protected String executionKey;
+
+ public StartProcessInstanceCmd(String processDefinitionId, Map<String, Object> variables, String executionKey) {
+ this.processDefinitionId = processDefinitionId;
+ this.variables = variables;
+ this.executionKey = executionKey;
+ }
+
+ public Execution execute(Environment environment) throws Exception {
+ RepositorySession repositorySession = environment.get(RepositorySession.class);
+
+ ClientProcessDefinition processDefinition = (ClientProcessDefinition)
+ repositorySession.loadProcessDefinitionById(processDefinitionId);
+ if (processDefinition==null) {
+ throw new JbpmException("no process definition with id '"+processDefinitionId+"'");
+ }
+
+ ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
+ processInstance.setVariables(variables);
+ processInstance.start();
+
+ Session session = Environment.getFromCurrent(Session.class);
+ session.save(processInstance);
+
+ return processInstance;
+ }
+
+ public String getProcessDefinitionKey() {
+ return processDefinitionId;
+ }
+ public void setProcessDefinitionKey(String processDefinitionKey) {
+ this.processDefinitionId = processDefinitionKey;
+ }
+ public String getExecutionKey() {
+ return executionKey;
+ }
+ public void setExecutionKey(String executionKey) {
+ this.executionKey = executionKey;
+ }
+}
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import java.util.Map;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
+import org.jbpm.session.RepositorySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StartProcessInstanceInLatestCmd extends VariablesCmd<Execution> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String processDefinitionKey;
+ protected String executionKey;
+
+ public StartProcessInstanceInLatestCmd(String processDefinitionKey, Map<String, Object> variables, String executionKey) {
+ if (processDefinitionKey==null) {
+ throw new JbpmException("processDefinitionKey is null");
+ }
+ this.processDefinitionKey = processDefinitionKey;
+ this.variables = variables;
+ this.executionKey = executionKey;
+ }
+
+ public Execution execute(Environment environment) throws Exception {
+ ClientProcessDefinition processDefinition = null;
+
+ RepositorySession repositorySession = environment.get(RepositorySession.class);
+ processDefinition = (ClientProcessDefinition) repositorySession.createProcessDefinitionQuery()
+ .key(processDefinitionKey)
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .page(0, 1)
+ .uniqueResult();
+
+ if (processDefinition==null) {
+ throw new JbpmException("no process definition with key '"+processDefinitionKey+"'");
+ }
+
+ processDefinition = repositorySession.loadProcessDefinitionById(processDefinition.getId());
+
+ ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);
+ processInstance.setVariables(variables);
+ processInstance.start();
+
+ Session session = Environment.getFromCurrent(Session.class);
+ session.save(processInstance);
+ return processInstance;
+ }
+
+ public String getExecutionKey() {
+ return executionKey;
+ }
+ public void setExecutionKey(String executionKey) {
+ this.executionKey = executionKey;
+ }
+}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -208,7 +208,12 @@
public List<String> findProcessInstanceIds(String processDefinitionId) {
// query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
- Query query = session.getNamedQuery("findProcessInstanceIds");
+ Query query = session.createQuery(
+ "select processInstance.id " +
+ "from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance " +
+ "where processInstance.processDefinitionId = :processDefinitionId " +
+ " and processInstance.parent is null"
+ );
query.setString("processDefinitionId", processDefinitionId);
return query.list();
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1024,7 +1024,7 @@
&& (processDefinitionId!=null)
) {
RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
- processDefinition = (ProcessDefinitionImpl) repositorySession.findObjectByPropertyValue("id", processDefinitionId);
+ processDefinition = (ProcessDefinitionImpl) repositorySession.loadProcessDefinitionById(processDefinitionId);
if (processDefinition==null) {
throw new JbpmException("couldn't find process definition "+processDefinitionId+" in the repository");
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -35,6 +35,7 @@
import org.jbpm.model.IdGenerator;
import org.jbpm.model.OpenProcessDefinition;
import org.jbpm.pvm.internal.lob.Lob;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.IoUtil;
/**
@@ -72,6 +73,8 @@
/** the activity which is executed when the process starts */
protected ActivityImpl initial;
+ protected Map<String, TaskDefinitionImpl> taskDefinitions;
+
/** the attachments */
protected Map<String, Lob> attachments;
@@ -127,6 +130,22 @@
public IdGenerator getIdGenerator() {
return Environment.getFromCurrent(IdGenerator.class, false);
}
+
+ // task definitions /////////////////////////////////////////////////////////
+
+ public void addTaskDefinitionImpl(TaskDefinitionImpl taskDefinition) {
+ if (taskDefinitions==null) {
+ taskDefinitions = new HashMap<String, TaskDefinitionImpl>();
+ }
+ taskDefinitions.put(taskDefinition.getName(), taskDefinition);
+ }
+
+ public TaskDefinitionImpl getTaskDefinition(String name) {
+ if (taskDefinitions!=null) {
+ return taskDefinitions.get(name);
+ }
+ return null;
+ }
// attachments //////////////////////////////////////////////////////////////
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ExecutionQueryImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -39,8 +39,6 @@
private static final long serialVersionUID = 1L;
protected boolean onlyProcessInstances;
- protected String processDefinitionNameLike;
- protected String processDefinitionKeyLike;
protected String processDefinitionId;
protected String processInstanceId;
@@ -80,17 +78,9 @@
}
if (processDefinitionId!=null) {
- appendWhereClause("execution.processDefinition.id = '"+processDefinitionId+"' ", hql);
+ appendWhereClause("execution.processDefinitionId = '"+processDefinitionId+"' ", hql);
}
- if (processDefinitionNameLike!=null) {
- appendWhereClause("execution.processDefinition.name like '"+processDefinitionNameLike+"' ", hql);
- }
-
- if (processDefinitionKeyLike!=null) {
- appendWhereClause("execution.processDefinition.key like '"+processDefinitionKeyLike+"' ", hql);
- }
-
appendOrderByClause(hql);
return hql.toString();
@@ -114,16 +104,6 @@
return this;
}
- public ExecutionQuery processDefinitionKeyLike(String processDefinitionKey) {
- this.processDefinitionKeyLike = processDefinitionKey;
- return this;
- }
-
- public ExecutionQuery processDefinitionNameLike(String processDefinitionName) {
- this.processDefinitionNameLike = processDefinitionName;
- return this;
- }
-
public ExecutionQuery page(int firstResult, int maxResults) {
this.page = new Page(firstResult, maxResults);
return this;
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -24,8 +24,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
import org.hibernate.Query;
import org.hibernate.Session;
@@ -48,7 +46,8 @@
protected String id;
protected String key;
protected String nameLike;
- protected String versionSortDirection;
+ protected String name;
+ protected Long deploymentDbid;
public ProcessDefinitionQueryImpl(CommandService commandService) {
super(commandService);
@@ -59,14 +58,14 @@
}
public ProcessDefinition uniqueResult() {
- List list = execute();
+ List<ProcessDefinition> list = execute();
if (list.isEmpty()) {
return null;
}
if (list.size()>1) {
throw new JbpmException("result not unique: "+list.size());
}
- return (ProcessDefinition) list.get(0);
+ return list.get(0);
}
public Object execute(Session session) {
@@ -78,6 +77,7 @@
processDefinition.setName((String)properties.get("name"));
processDefinition.setKey((String)properties.get("key"));
processDefinition.setId((String)properties.get("id"));
+ processDefinition.setDeploymentDbid((Long)properties.get("deploymentDbid"));
Long versionLong = (Long)properties.get("version");
processDefinition.setVersion(versionLong.intValue());
@@ -90,8 +90,9 @@
public String hql() {
StringBuffer hql = new StringBuffer();
hql.append("select new map( idProperty.objectName as name, " +
- "idProperty.stringValue as id, " +
- "keyProperty.stringValue as key," +
+ "idProperty.stringValue as id," +
+ "idProperty.deployment.dbid as deploymentDbid, " +
+ "keyProperty.stringValue as key, " +
"versionProperty.longValue as version ) ");
hql.append("from ");
hql.append(DeploymentImpl.class.getName());
@@ -115,17 +116,25 @@
appendWhereClause("versionProperty.deployment = deployment ", hql);
if (id!=null) {
- appendWhereClause("idProperty = '"+id+"'", hql);
+ appendWhereClause("idProperty.stringValue = '"+id+"'", hql);
}
if (nameLike!=null) {
appendWhereClause("idProperty.objectName like '"+nameLike+"' ", hql);
}
+ if (name!=null) {
+ appendWhereClause("idProperty.objectName = '"+nameLike+"' ", hql);
+ }
+
if (key!=null) {
appendWhereClause("keyProperty.stringValue = '"+key+"' ", hql);
}
+ if (deploymentDbid!=null) {
+ appendWhereClause("idProperty.deployment.dbid = "+deploymentDbid+" ", hql);
+ }
+
appendOrderByClause(hql);
return hql.toString();
@@ -149,6 +158,16 @@
return this;
}
+ public ProcessDefinitionQuery name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public ProcessDefinitionQuery deploymentDbid(long deploymentDbid) {
+ this.deploymentDbid = deploymentDbid;
+ return this;
+ }
+
public ProcessDefinitionQuery orderAsc(String property) {
addOrderByClause(property+" asc");
return this;
@@ -162,5 +181,5 @@
public ProcessDefinitionQuery page(int firstResult, int maxResults) {
this.page = new Page(firstResult, maxResults);
return this;
- }
+ }
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -41,15 +41,19 @@
}
public void set(long deploymentDbid, Map<String, Object> objects) {
- Map<String, Object> deploymentObjects = deployments.get(deploymentDbid);
- if (deploymentObjects==null) {
- deploymentObjects = new HashMap<String, Object>();
- deployments.put(deploymentDbid, deploymentObjects);
+ if (objects==null) {
+ deployments.put(deploymentDbid, null);
+ } else {
+ Map<String, Object> deploymentObjects = deployments.get(deploymentDbid);
+ if (deploymentObjects==null) {
+ deploymentObjects = new HashMap<String, Object>();
+ deployments.put(deploymentDbid, deploymentObjects);
+ }
+ for (String objectName: objects.keySet()) {
+ Object object = objects.get(objectName);
+ deploymentObjects.put(objectName, object);
+ }
}
- for (String objectName: objects.keySet()) {
- Object object = objects.get(objectName);
- deploymentObjects.put(objectName, object);
- }
}
public void clear() {
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -27,7 +27,8 @@
import org.jbpm.ProcessDefinitionQuery;
import org.jbpm.RepositoryService;
import org.jbpm.cmd.CommandService;
-import org.jbpm.pvm.internal.cmd.GetResourceAsStream;
+import org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd;
+import org.jbpm.pvm.internal.cmd.GetResourceAsStreamCmd;
import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
/**
@@ -42,13 +43,19 @@
}
public void deleteDeployment(long deploymentDbid) {
+ commandService.execute(new DeleteDeploymentCmd(deploymentDbid));
}
-
+
+ public void deleteDeploymentCascade(long deploymentDbid) {
+ commandService.execute(new DeleteDeploymentCmd(deploymentDbid, true));
+ }
+
public InputStream getResourceAsStream(long deploymentDbid, String resource) {
- return commandService.execute(new GetResourceAsStream(deploymentDbid, resource));
+ return commandService.execute(new GetResourceAsStreamCmd(deploymentDbid, resource));
}
public ProcessDefinitionQuery createProcessDefinitionQuery() {
return new ProcessDefinitionQueryImpl(commandService);
}
+
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -23,7 +23,6 @@
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.List;
import org.hibernate.Session;
import org.jbpm.Deployment;
@@ -107,45 +106,21 @@
return new ProcessDefinitionQueryImpl(session);
}
-
- public Object findObjectByPropertyValue(String key, String value) {
+ public ClientProcessDefinition loadProcessDefinitionById(String processDefinitionId) {
DeploymentProperty deploymentProperty = (DeploymentProperty) session.createQuery(
"select deploymentProperty " +
"from "+DeploymentProperty.class.getName()+" as deploymentProperty " +
- "where deploymentProperty.key = '"+key+"' " +
- " and deploymentProperty.stringValue = '"+value+"' " +
- "order by deploymentProperty.deployment.timestamp desc "
+ "where deploymentProperty.key = 'id' " +
+ " and deploymentProperty.stringValue = '"+processDefinitionId+"' "
).setMaxResults(1).uniqueResult();
if (deploymentProperty!=null) {
long deploymentDbid = deploymentProperty.getDeployment().getDbid();
String objectName = deploymentProperty.getObjectName();
- return getObject(deploymentDbid, objectName);
+ return (ClientProcessDefinition) getObject(deploymentDbid, objectName);
}
return null;
}
-
- public List<String> findObjectNames(String key, String value) {
- return session.createQuery(
- "select distinct deploymentProperty.objectName " +
- "from "+DeploymentProperty.class.getName()+" as deploymentProperty " +
- "where deploymentProperty.key = '"+key+"' " +
- " and deploymentProperty.stringValue = '"+value+"' "
- ).list();
- }
-
- public List<String> findObjectPropertyValues(String objectName, String key) {
- return session.createQuery(
- "select distinct deploymentProperty.stringValue " +
- "from "+DeploymentProperty.class.getName()+" as deploymentProperty " +
- "where deploymentProperty.objectName = '"+objectName+"' " +
- " and deploymentProperty.key = '"+key+"' "
- ).list();
- }
-
- public ClientProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey) {
- return (ClientProcessDefinition) findObjectByPropertyValue("key", processDefinitionKey);
- }
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -37,8 +37,8 @@
import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
import org.jbpm.pvm.internal.cmd.SetVariablesCmd;
import org.jbpm.pvm.internal.cmd.SignalCmd;
-import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
-import org.jbpm.pvm.internal.cmd.StartExecutionInLatestCmd;
+import org.jbpm.pvm.internal.cmd.StartProcessInstanceCmd;
+import org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd;
import org.jbpm.pvm.internal.query.ExecutionQueryImpl;
@@ -48,35 +48,35 @@
public class ExecutionServiceImpl extends AbstractServiceImpl implements ExecutionService {
public Execution startProcessInstanceById(String processDefinitionId){
- return commandService.execute(new StartExecutionCmd(processDefinitionId, null, null));
+ return commandService.execute(new StartProcessInstanceCmd(processDefinitionId, null, null));
}
public Execution startProcessInstanceById(String processDefinitionId, String executionKey) {
- return commandService.execute(new StartExecutionCmd(processDefinitionId, null, executionKey));
+ return commandService.execute(new StartProcessInstanceCmd(processDefinitionId, null, executionKey));
}
public Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables){
- return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, null));
+ return commandService.execute(new StartProcessInstanceCmd(processDefinitionId, variables, null));
}
public Execution startProcessInstanceById(String processDefinitionId, Map<String, Object> variables, String executionKey){
- return commandService.execute(new StartExecutionCmd(processDefinitionId, variables, executionKey));
+ return commandService.execute(new StartProcessInstanceCmd(processDefinitionId, variables, executionKey));
}
public Execution startProcessInstanceByKey(String processDefinitionKey) {
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, null, null));
+ return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, null, null));
}
public Execution startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables){
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, variables, null));
+ return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, variables, null));
}
public Execution startProcessInstanceByKey(String processDefinitionKey, String executionKey) {
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, null, executionKey));
+ return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, null, executionKey));
}
public Execution startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String executionKey){
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey, variables, executionKey));
+ return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, variables, executionKey));
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -34,7 +34,7 @@
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionByIdCmd;
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionKeysCmd;
import org.jbpm.pvm.internal.cmd.FindProcessDefinitionsByKeyCmd;
-import org.jbpm.pvm.internal.cmd.GetResourceAsStream;
+import org.jbpm.pvm.internal.cmd.GetResourceAsStreamCmd;
import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -39,6 +39,7 @@
import org.jbpm.pvm.internal.history.events.TaskStart;
import org.jbpm.pvm.internal.model.CommentImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.util.Priority;
@@ -86,7 +87,9 @@
protected String state;
+ protected String taskDefinitionName;
protected TaskDefinitionImpl taskDefinition;
+
protected ExecutionImpl execution;
protected ExecutionImpl processInstance;
protected SwimlaneImpl swimlane;
@@ -348,7 +351,7 @@
}
public TaskHandler getTaskHandler() {
- if ( (taskDefinition==null)
+ if ( (getTaskDefinition()==null)
|| (taskDefinition.getTaskHandlerDescriptor()==null)
) {
return DEFAULT_TASK_HANDLER;
@@ -358,6 +361,26 @@
return taskHandler;
}
+ // special getters and setters //////////////////////////////////////////////
+
+ public TaskDefinitionImpl getTaskDefinition() {
+ if ( (taskDefinition==null)
+ && (taskDefinitionName!=null)
+ && (execution!=null)
+ ) {
+ ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
+ taskDefinition = processDefinition.getTaskDefinition(taskDefinitionName);
+ }
+
+ return taskDefinition;
+ }
+
+ public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
+ this.taskDefinition = taskDefinition;
+ this.taskDefinitionName = taskDefinition.getName();
+ }
+
+
// getters and setters //////////////////////////////////////////////////////
public long getDbid() {
@@ -465,10 +488,5 @@
public void setSignalling(boolean isSignalling) {
this.isSignalling = isSignalling;
}
- public TaskDefinitionImpl getTaskDefinition() {
- return taskDefinition;
- }
- public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
- this.taskDefinition = taskDefinition;
- }
+
}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessCacheDbTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,614 +0,0 @@
-/**
- * Copyright (C) 2007 Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library 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
- * version 2.1 of the License.
- * This library 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
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301, USA.
- **/
-package org.jbpm.pvm.internal.db.model;
-
-import java.util.List;
-
-import org.hibernate.Session;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.model.Activity;
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.model.Transition;
-import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.test.EnvironmentDbTestCase;
-import org.jbpm.session.DbSession;
-import org.jbpm.session.PvmDbSession;
-
-/**
- * @author Guillaume Porcher
- *
- */
-public class ProcessCacheDbTest extends EnvironmentDbTestCase {
-
- /**
- * Defines a simple process: only activities. persists it.
- */
- public void testCacheProcessDefinitionActivities() {
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .endActivity()
- .startActivity("b")
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endProcess();
-
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- pvmDbSession.save(processDefinition);
-
- environment.get(Session.class).flush();
-
- newTransaction(); // ///////////////////////////////////////////////////////
-
- // only the processDefinition.getDbid() is carried over from the previous
- // transaction
-
- pvmDbSession = environment.get(PvmDbSession.class);
- processDefinition = pvmDbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(processDefinition);
- List<Activity> activities = processDefinition.getActivities();
- assertNotNull(activities);
-
- Activity a = activities.get(0);
- assertEquals("a", a.getName());
- assertTrue(a.getActivities().isEmpty());
-
- Activity b = activities.get(1);
- assertEquals("b", b.getName());
- assertTrue(b.getActivities().isEmpty());
-
- Activity c = activities.get(2);
- assertEquals("c", c.getName());
- assertTrue(c.getActivities().isEmpty());
-
- assertEquals(3, activities.size());
-
- newTransaction(); // ///////////////////////////////////////////////////////
-
- beginCacheTest(); // /////////////
- // only the processDefinition.getDbid() is carried over from the previous
- // transaction
-
- pvmDbSession = environment.get(PvmDbSession.class);
- processDefinition = pvmDbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(processDefinition);
- activities = processDefinition.getActivities();
- assertNotNull(activities);
-
- a = activities.get(0);
- assertEquals("a", a.getName());
- assertTrue(a.getActivities().isEmpty());
-
- b = activities.get(1);
- assertEquals("b", b.getName());
- assertTrue(b.getActivities().isEmpty());
-
- c = activities.get(2);
- assertEquals("c", c.getName());
- assertTrue(c.getActivities().isEmpty());
-
- assertEquals(3, activities.size());
-
- endCacheTest(); // ///////////
- }
-
- /**
- * Defines a simple process: only activities. persists it.
- */
- public void testCacheProcessDefinitionActivityOrder() {
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .endActivity()
- .startActivity("b")
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endProcess();
-
- DbSession dbSession = environment.get(DbSession.class);
- dbSession.save(processDefinition);
-
- newTransaction(); // ///////////////////////////////////////////////////////
-
- // only the processDefinition.getDbid() is carried over from the previous
- // transaction
-
- dbSession = environment.get(DbSession.class);
- processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(processDefinition);
- List<Activity> activities = processDefinition.getActivities();
- assertNotNull(activities);
- assertEquals(3, activities.size());
-
- Activity a = activities.get(0);
- assertEquals("a", a.getName());
- assertEquals(0, a.getActivities().size());
-
- Activity b = activities.get(1);
- assertEquals("b", b.getName());
- assertEquals(0, b.getActivities().size());
-
- Activity c = activities.get(2);
- assertEquals("c", c.getName());
- assertEquals(0, c.getActivities().size());
-
- newTransaction(); // ///////////////////////////////////////////////////////
-
- dbSession = environment.get(DbSession.class);
- processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(processDefinition);
-
- activities = processDefinition.getActivities();
- assertNotNull(activities);
-
- // Pass a to the end -> activity order is "b,c,a"
- activities.add(activities.remove(0));
-
- activities = processDefinition.getActivities();
- b = activities.get(0);
- assertEquals("b", b.getName());
- assertEquals(0, b.getActivities().size());
-
- c = activities.get(1);
- assertEquals("c", c.getName());
- assertEquals(0, c.getActivities().size());
-
- a = activities.get(2);
- assertEquals("a", a.getName());
- assertEquals(0, a.getActivities().size());
-
- newTransaction(); // ///////////////////////////////////////////////////////
-
- dbSession = environment.get(DbSession.class);
- processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(processDefinition);
- activities = processDefinition.getActivities();
- assertNotNull(activities);
- assertEquals(3, activities.size());
-
- b = activities.get(0);
- assertEquals("b", b.getName());
- assertEquals(0, b.getActivities().size());
-
- c = activities.get(1);
- assertEquals("c", c.getName());
- assertEquals(0, c.getActivities().size());
-
- a = activities.get(2);
- assertEquals("a", a.getName());
- assertEquals(0, a.getActivities().size());
-
- newTransaction(); // ///////////////////////////////////////////////////////
- beginCacheTest(); // /////////
-
- dbSession = environment.get(DbSession.class);
- processDefinition = dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(processDefinition);
- activities = processDefinition.getActivities();
- assertNotNull(activities);
- assertEquals(3, activities.size());
-
- b = activities.get(0);
- assertEquals("b", b.getName());
- assertEquals(0, b.getActivities().size());
-
- c = activities.get(1);
- assertEquals("c", c.getName());
- assertEquals(0, c.getActivities().size());
-
- a = activities.get(2);
- assertEquals("a", a.getName());
- assertEquals(0, a.getActivities().size());
-
- endCacheTest(); // //////////////
- }
-
- /**
- * Test processDefinition initial activity
- */
- public void testCacheProcessDefinitionInitialActivity() {
- ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
- ActivityImpl activity = (ActivityImpl) processDefinition.createActivity();
- activity.setName("initial activity");
- activity.setDescription("very important activity");
-
- processDefinition.setInitial(activity);
-
- environment.get(DbSession.class).save(processDefinition);
-
- newTransaction(); // /////////////////////////////////////////////////////
-
- ProcessDefinitionImpl p = environment.get(DbSession.class).get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(p);
-
- ActivityImpl n = p.getInitial();
-
- assertNotNull(n);
- assertEquals(activity.getName(), n.getName());
- assertEquals(activity.getDescription(), n.getDescription());
-
- newTransaction(); // /////////////////////////////////////////////////////
- beginCacheTest(); // //////////
-
- p = environment.get(DbSession.class).get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(p);
-
- n = p.getInitial();
-
- assertNotNull(n);
- assertEquals(activity.getName(), n.getName());
- assertEquals(activity.getDescription(), n.getDescription());
-
- endCacheTest(); // ///////////
- }
-
- /**
- * Defines a simple process: only nested activities. persists it, reloads it and
- * tries to access the nested activities
- */
- public void testCacheProcessDefinitionNestedActivities() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity()
- .initial()
- .startActivity("a")
- .endActivity()
- .startActivity("b")
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endActivity()
- .endProcess();
-
- persistenceSession.save(processDefinition);
-
- newTransaction(); // /////////////////////////////////////////////////////
-
- persistenceSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(p);
-
- assertNotSame(processDefinition, p);
- p.getActivities();
- assertNotNull(p.getInitial());
- assertNotNull(p.getInitial().getActivity("a"));
- assertNotNull(p.getInitial().getActivity("b"));
- assertNotNull(p.getInitial().getActivity("c"));
-
- newTransaction(); // /////////////////////////////////////////////////////
- beginCacheTest(); // /////////
-
- persistenceSession = (DbSession) environment.get(DbSession.class);
-
- p = (OpenProcessDefinition) persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(p);
-
- assertNotSame(processDefinition, p);
- p.getActivities();
- assertNotNull(p.getInitial());
- assertNotNull(p.getInitial().getActivity("a"));
- assertNotNull(p.getInitial().getActivity("b"));
- assertNotNull(p.getInitial().getActivity("c"));
-
- endCacheTest(); // ////////
- }
-
- /**
- * Defines a process with nested activities with nested activities. persists it, reloads
- * it and tries to access the nested activities
- */
- public void testCacheProcessDefinitionNestedNestedActivities() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity()
- .initial()
- .startActivity("a")
- .startActivity("aa")
- .endActivity()
- .startActivity("ab")
- .endActivity()
- .startActivity("ac")
- .endActivity()
- .endActivity()
- .startActivity("b")
- .startActivity("ba")
- .endActivity()
- .startActivity("bb")
- .endActivity()
- .startActivity("bc")
- .endActivity()
- .endActivity()
- .startActivity("c")
- .startActivity("ca")
- .endActivity()
- .startActivity("cb")
- .endActivity()
- .startActivity("cc")
- .endActivity()
- .endActivity()
- .endActivity()
- .endProcess();
-
- persistenceSession.save(processDefinition);
-
- newTransaction(); // /////////////////////////////////////////////////////
-
- persistenceSession = (DbSession) environment.get(DbSession.class);
-
- ClientProcessDefinition p = persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(p);
-
- assertNotSame(processDefinition, p);
- p.getActivities();
- assertNotNull(p.getInitial());
- Activity n = p.getInitial().getActivity("a");
- assertNotNull(n);
- List<Activity> l = n.getActivities();
- assertEquals(3, l.size());
- assertEquals("aa", l.get(0).getName());
- assertEquals("ab", l.get(1).getName());
- assertEquals("ac", l.get(2).getName());
-
- n = p.getInitial().getActivity("b");
- assertNotNull(n);
- l = n.getActivities();
- assertEquals(3, l.size());
- assertEquals("ba", l.get(0).getName());
- assertEquals("bb", l.get(1).getName());
- assertEquals("bc", l.get(2).getName());
-
- n = p.getInitial().getActivity("c");
- assertNotNull(n);
- l = n.getActivities();
- assertEquals(3, l.size());
- assertEquals("ca", l.get(0).getName());
- assertEquals("cb", l.get(1).getName());
- assertEquals("cc", l.get(2).getName());
-
- newTransaction(); // /////////////////////////////////////////////////////
- beginCacheTest(); // //////////
-
- persistenceSession = (DbSession) environment.get(DbSession.class);
-
- p = persistenceSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
- assertNotNull(p);
-
- assertNotSame(processDefinition, p);
- p.getActivities();
- assertNotNull(p.getInitial());
- n = p.getInitial().getActivity("a");
- assertNotNull(n);
- l = n.getActivities();
- assertEquals(3, l.size());
- assertEquals("aa", l.get(0).getName());
- assertEquals("ab", l.get(1).getName());
- assertEquals("ac", l.get(2).getName());
-
- n = p.getInitial().getActivity("b");
- assertNotNull(n);
- l = n.getActivities();
- assertEquals(3, l.size());
- assertEquals("ba", l.get(0).getName());
- assertEquals("bb", l.get(1).getName());
- assertEquals("bc", l.get(2).getName());
-
- n = p.getInitial().getActivity("c");
- assertNotNull(n);
- l = n.getActivities();
- assertEquals(3, l.size());
- assertEquals("ca", l.get(0).getName());
- assertEquals("cb", l.get(1).getName());
- assertEquals("cc", l.get(2).getName());
-
- endCacheTest(); // ///////////
- }
-
- /**
- * Defines a simple process: only activities and default transitions. persists it,
- * reloads and navigates through the transitions.
- */
- public void testCacheDefaultTransition() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity()
- .initial()
- .transition("a")
- .endActivity()
- .startActivity("a")
- .transition("b")
- .endActivity()
- .startActivity("b")
- .transition("c")
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endProcess();
-
- persistenceSession.save(processDefinition);
-
- newTransaction(); // /////////////////////////////////////////////////////
-
- DbSession testSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- Activity activity = p.getInitial();
- assertNotNull(activity.getDefaultTransition());
- assertEquals(activity, activity.getDefaultTransition().getSource());
-
- activity = activity.getDefaultTransition().getDestination();
-
- assertEquals(p.getActivity("a"), activity);
- assertNotNull(activity.getDefaultTransition());
- assertEquals(activity, activity.getDefaultTransition().getSource());
-
- activity = activity.getDefaultTransition().getDestination();
-
- assertEquals(p.getActivity("b"), activity);
- assertNotNull(activity.getDefaultTransition());
- assertEquals(activity, activity.getDefaultTransition().getSource());
-
- activity = activity.getDefaultTransition().getDestination();
- assertEquals(p.getActivity("c"), activity);
- assertNull(activity.getDefaultTransition());
-
- newTransaction(); // /////////////////////////////////////////////////////
- beginCacheTest(); // //////////
-
- testSession = (DbSession) environment.get(DbSession.class);
-
- p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- activity = p.getInitial();
- assertNotNull(activity.getDefaultTransition());
- assertEquals(activity, activity.getDefaultTransition().getSource());
-
- activity = activity.getDefaultTransition().getDestination();
-
- assertEquals(p.getActivity("a"), activity);
- assertNotNull(activity.getDefaultTransition());
- assertEquals(activity, activity.getDefaultTransition().getSource());
-
- activity = activity.getDefaultTransition().getDestination();
-
- assertEquals(p.getActivity("b"), activity);
- assertNotNull(activity.getDefaultTransition());
- assertEquals(activity, activity.getDefaultTransition().getSource());
-
- activity = activity.getDefaultTransition().getDestination();
- assertEquals(p.getActivity("c"), activity);
- assertNull(activity.getDefaultTransition());
-
- endCacheTest(); // //////////
- }
-
- /**
- * Defines a simple process: only activities and transitions. persists it, reloads
- * and navigates through the transitions.
- */
- public void testCacheTwoTransitions() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity()
- .initial()
- .transition("a")
- .transition("b")
- .endActivity()
- .startActivity("a")
- .endActivity()
- .startActivity("b")
- .endActivity()
- .endProcess();
-
- persistenceSession.save(processDefinition);
-
- newTransaction(); // /////////////////////////////////////////////////////
-
- DbSession testSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- Activity activity = p.getInitial();
- List<Transition> l = activity.getOutgoingTransitions();
- assertNotNull(l);
- assertEquals(2, l.size());
-
- Activity a = p.getActivity("a");
- assertNotNull(a);
-
- Activity b = p.getActivity("b");
- assertNotNull(b);
-
- assertEquals(activity, l.get(0).getSource());
- assertEquals(activity, l.get(1).getSource());
-
- assertEquals(a, l.get(0).getDestination());
- assertEquals(b, l.get(1).getDestination());
-
- List<Transition> la = a.getIncomingTransitions();
- assertNotNull(la);
- assertEquals(1, la.size());
- assertSame(la.get(0), l.get(0));
-
- List<Transition> lb = b.getIncomingTransitions();
- assertNotNull(lb);
- assertEquals(1, lb.size());
- assertSame(lb.get(0), l.get(1));
-
- newTransaction(); // /////////////////////////////////////////////////////
-
- testSession = (DbSession) environment.get(DbSession.class);
- beginCacheTest(); // ///////
-
- p = (OpenProcessDefinition) testSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- activity = p.getInitial();
- l = activity.getOutgoingTransitions();
- assertNotNull(l);
- assertEquals(2, l.size());
-
- a = p.getActivity("a");
- assertNotNull(a);
-
- b = p.getActivity("b");
- assertNotNull(b);
-
- assertEquals(activity, l.get(0).getSource());
- assertEquals(activity, l.get(1).getSource());
-
- assertEquals(a, l.get(0).getDestination());
- assertEquals(b, l.get(1).getDestination());
-
- la = a.getIncomingTransitions();
- assertNotNull(la);
- assertEquals(1, la.size());
- assertSame(la.get(0), l.get(0));
-
- lb = b.getIncomingTransitions();
- assertNotNull(lb);
- assertEquals(1, lb.size());
- assertSame(lb.get(0), l.get(1));
-
- endCacheTest(); // ////////
- }
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/ProcessDefinitionDbTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,486 +0,0 @@
-/**
- * Copyright (C) 2007 Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library 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
- * version 2.1 of the License.
- * This library 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
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301, USA.
- **/
-package org.jbpm.pvm.internal.db.model;
-
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import org.jbpm.model.Event;
-import org.jbpm.model.Activity;
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.model.Transition;
-import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.model.EventImpl;
-import org.jbpm.pvm.internal.model.EventListenerReference;
-import org.jbpm.pvm.internal.model.ExceptionHandlerImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.test.EnvironmentDbTestCase;
-import org.jbpm.session.DbSession;
-
-/**
- * @author Charles Souillard
- * @author Guillaume Porcher
- */
-public class ProcessDefinitionDbTest extends EnvironmentDbTestCase {
-
- public void testProcessDefinitionBasicProperties() {
- Date deploymentTime = new Date();
-
- ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
- processDefinition.setName("name");
- processDefinition.setDescription("description");
- processDefinition.setVersion(3);
- processDefinition.setDeploymentTime(deploymentTime);
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- assertEquals("name", processDefinition.getName());
- assertEquals("description", processDefinition.getDescription());
- assertEquals(3, processDefinition.getVersion());
- assertEquals(deploymentTime, processDefinition.getDeploymentTime());
- }
-
- public void testProcessDefinitionActivities() {
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .endActivity()
- .startActivity("b")
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- assertNotNull(processDefinition);
- List<Activity> activities = processDefinition.getActivities();
- assertNotNull(activities);
-
- Activity a = activities.get(0);
- assertEquals("a", a.getName());
- assertTrue(a.getActivities().isEmpty());
-
- Activity b = activities.get(1);
- assertEquals("b", b.getName());
- assertTrue(b.getActivities().isEmpty());
-
- Activity c = activities.get(2);
- assertEquals("c", c.getName());
- assertTrue(c.getActivities().isEmpty());
-
- assertEquals(3, activities.size());
- }
-
- public void testInitialActivity() {
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .endActivity()
- .startActivity("b")
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- Activity initial = processDefinition.getInitial();
- assertNotNull(initial);
-
- // check that the initial activity is still in the list of activities
- assertSame(processDefinition.getActivity("a"), initial);
- // check that the initial activity is not two times in the list of activities
- assertEquals(3, processDefinition.getActivities().size());
- }
-
- public void testProcessDefinitionNestedActivities() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity("top")
- .initial()
- .startActivity("a")
- .endActivity()
- .startActivity("b")
- .startActivity("b1")
- .endActivity()
- .startActivity("b2")
- .endActivity()
- .startActivity("b3")
- .endActivity()
- .endActivity()
- .startActivity("c")
- .endActivity()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- assertNotNull(processDefinition);
- Activity initial = processDefinition.getInitial();
- assertNotNull(initial);
- assertEquals(initial, processDefinition.getActivity("top"));
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- List<Activity> activities = processDefinition.getActivities();
- assertNotNull(activities);
- assertEquals("expected size 1. activity list was: " + activities.toString(), 1, activities.size());
- Activity top = activities.get(0);
- assertNotNull(top);
-
- activities = top.getActivities();
- assertNotNull(activities);
- assertEquals("expected size 3. activity list was: " + activities.toString(), 3, activities.size());
- assertEquals("a", activities.get(0).getName());
- assertEquals("b", activities.get(1).getName());
- assertEquals("c", activities.get(2).getName());
-
- activities = processDefinition.getActivity("top").getActivity("b").getActivities();
- assertNotNull(activities);
- assertEquals("expected size 3. activity list was: " + activities.toString(), 3, activities.size());
- assertEquals("b1", activities.get(0).getName());
- assertEquals("b2", activities.get(1).getName());
- assertEquals("b3", activities.get(2).getName());
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- Activity activity = processDefinition.findActivity("b2");
- assertNotNull(activity);
- assertEquals("b", activity.getParent().getName());
- assertEquals("top", activity.getParent().getParent().getName());
- }
-
- public void testDefaultTransition() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .transition("a")
- .transition("b", "tob")
- .transition("c", "toc")
- .endActivity()
- .startActivity("b")
- .transition("a", "toa")
- .transition("b")
- .transition("c", "toc")
- .endActivity()
- .startActivity("c")
- .transition("c")
- .endActivity()
- .startActivity("d")
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- assertEquals("a", processDefinition.getActivity("a").getDefaultTransition().getDestination().getName());
- assertEquals("a", processDefinition.getActivity("b").getDefaultTransition().getDestination().getName());
- assertEquals("c", processDefinition.getActivity("c").getDefaultTransition().getDestination().getName());
- assertNull(processDefinition.getActivity("d").getDefaultTransition());
- }
-
- public void testTwoTransitionsWithoutAName() {
- DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(persistenceSession);
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity()
- .initial()
- .transition("a")
- .transition("b")
- .endActivity()
- .startActivity("a")
- .endActivity()
- .startActivity("b")
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- assertNotNull(processDefinition);
- Activity activity = processDefinition.getInitial();
- List<Transition> l = activity.getOutgoingTransitions();
- assertNotNull(l);
- assertEquals(2, l.size());
-
- Activity a = processDefinition.getActivity("a");
- assertNotNull(a);
-
- Activity b = processDefinition.getActivity("b");
- assertNotNull(b);
-
- assertEquals(activity, l.get(0).getSource());
- assertEquals(activity, l.get(1).getSource());
-
- assertEquals(a, l.get(0).getDestination());
- assertEquals(b, l.get(1).getDestination());
-
- List<Transition> la = a.getIncomingTransitions();
- assertNotNull(la);
- assertEquals(1, la.size());
- assertSame(la.get(0), l.get(0));
-
- List<Transition> lb = b.getIncomingTransitions();
- assertNotNull(lb);
- assertEquals(1, lb.size());
- assertSame(lb.get(0), l.get(1));
- }
-
- public void testEventsOnProcessDefinition() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startEvent(Event.START)
- .listener("one")
- .listener("two")
- .endEvent()
- .startEvent(Event.END)
- .listener("three")
- .listener("four")
- .endEvent()
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- EventImpl event = processDefinition.getEvent(Event.START);
- List<EventListenerReference> listenerReferences = event.getListenerReferences();
- assertEquals("one", listenerReferences.get(0).getExpression());
- assertEquals("two", listenerReferences.get(1).getExpression());
-
- event = processDefinition.getEvent(Event.END);
- listenerReferences = event.getListenerReferences();
- assertEquals("three", listenerReferences.get(0).getExpression());
- assertEquals("four", listenerReferences.get(1).getExpression());
- }
-
- public void testEventsOnActivity() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .startEvent(Event.START)
- .listener("one")
- .listener("two")
- .endEvent()
- .startEvent(Event.END)
- .listener("three")
- .listener("four")
- .endEvent()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- EventImpl event = processDefinition.getActivity("a").getEvent(Event.START);
- List<EventListenerReference> listenerReferences = event.getListenerReferences();
- assertEquals("one", listenerReferences.get(0).getExpression());
- assertEquals("two", listenerReferences.get(1).getExpression());
-
- event = processDefinition.getActivity("a").getEvent(Event.END);
- listenerReferences = event.getListenerReferences();
- assertEquals("three", listenerReferences.get(0).getExpression());
- assertEquals("four", listenerReferences.get(1).getExpression());
- }
-
- public void testListenersOnTransition() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .startFlow("b")
- .listener("one")
- .listener("two")
- .endFlow()
- .endActivity()
- .startActivity("b")
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- EventImpl event = processDefinition.getActivity("a").getDefaultTransition().getEvent();
- List<EventListenerReference> listenerReferences = event.getListenerReferences();
- assertEquals("one", listenerReferences.get(0).getExpression());
- assertEquals("two", listenerReferences.get(1).getExpression());
- }
-
- public void testExceptionHandlersOnProcessDefinition() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startExceptionHandler(IllegalArgumentException.class)
- .listener("one")
- .listener("two")
- .endExceptionHandler()
- .startExceptionHandler(RuntimeException.class)
- .listener("three")
- .listener("four")
- .endExceptionHandler()
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- List<ExceptionHandlerImpl> exceptionHandlers = processDefinition.getExceptionHandlers();
-
- ExceptionHandlerImpl exceptionHandler = exceptionHandlers.get(0);
- assertEquals(IllegalArgumentException.class.getName(), exceptionHandler.getExceptionClassName());
- assertEquals("one", exceptionHandler.getEventListenerReferences().get(0).getExpression());
- assertEquals("two", exceptionHandler.getEventListenerReferences().get(1).getExpression());
-
- exceptionHandler = exceptionHandlers.get(1);
- assertEquals(RuntimeException.class.getName(), exceptionHandler.getExceptionClassName());
- assertEquals("three", exceptionHandler.getEventListenerReferences().get(0).getExpression());
- assertEquals("four", exceptionHandler.getEventListenerReferences().get(1).getExpression());
- }
-
- public void testExceptionHandlersOnActivity() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .startExceptionHandler(IllegalArgumentException.class)
- .listener("one")
- .listener("two")
- .endExceptionHandler()
- .startExceptionHandler(RuntimeException.class)
- .listener("three")
- .listener("four")
- .endExceptionHandler()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- List<ExceptionHandlerImpl> exceptionHandlers = processDefinition.getActivity("a").getExceptionHandlers();
-
- ExceptionHandlerImpl exceptionHandler = exceptionHandlers.get(0);
- assertEquals(IllegalArgumentException.class.getName(), exceptionHandler.getExceptionClassName());
- assertEquals("one", exceptionHandler.getEventListenerReferences().get(0).getExpression());
- assertEquals("two", exceptionHandler.getEventListenerReferences().get(1).getExpression());
-
- exceptionHandler = exceptionHandlers.get(1);
- assertEquals(RuntimeException.class.getName(), exceptionHandler.getExceptionClassName());
- assertEquals("three", exceptionHandler.getEventListenerReferences().get(0).getExpression());
- assertEquals("four", exceptionHandler.getEventListenerReferences().get(1).getExpression());
- }
-
- public void testProcessDynamicProperties() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .property("key1", "val1")
- .property("key2", "val2")
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- assertEquals("val1", processDefinition.getProperty("key1"));
- assertEquals("val2", processDefinition.getProperty("key2"));
- }
-
- public void testActivityDynamicProperties() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startActivity()
- .initial()
- .property("key1", "val1")
- .property("key2", "val2")
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- Activity activity = processDefinition.getInitial();
- assertEquals("val1", activity.getProperty("key1"));
- assertEquals("val2", activity.getProperty("key2"));
- }
-
- public void testTransitionDynamicProperties() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startActivity("a")
- .initial()
- .startFlow("a")
- .property("key1", "val1")
- .property("key2", "val2")
- .endFlow()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- Transition transition = processDefinition.getInitial().getDefaultTransition();
- assertEquals("val1", transition.getProperty("key1"));
- assertEquals("val2", transition.getProperty("key2"));
- }
-
- public void testEventDynamicProperties() {
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .startEvent(Event.START)
- .property("key1", "val1")
- .property("key2", "val2")
- .endEvent()
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- EventImpl event = processDefinition.getEvent(Event.START);
- assertEquals("val1", event.getProperty("key1"));
- assertEquals("val2", event.getProperty("key2"));
- }
-
- public void testProcessDefinitionAttachments() {
-
- if (true) {
- System.err.print("FIXME: JBPM-1972 finish process attachments");
- return;
- }
-
- StringBuffer text = new StringBuffer();
- for (int i=0; i<500; i++) {
- text.append("This is a lot of bytes! ");
- }
- byte[] bytes = text.toString().getBytes();
-
- ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) ProcessDefinitionBuilder
- .startProcess()
- .attachment("msgbytes", bytes)
- .endProcess();
-
- processDefinition = reload(processDefinition, ProcessDefinitionImpl.class);
-
- byte[] retrievedBytes = processDefinition.getAttachment("msgbytes");
- // assertTrue(Arrays.equals(bytes, retrievedBytes));
- }
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/SessionFactoryDbTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,38 +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.db.model;
-
-import org.hibernate.SessionFactory;
-import org.jbpm.pvm.test.EnvironmentDbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class SessionFactoryDbTest extends EnvironmentDbTestCase
-{
-
- public void testSessionFactory()
- {
- environment.get(SessionFactory.class);
- }
-
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireDbTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,600 +0,0 @@
-/**
- * Copyright (C) 2007 Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library 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
- * version 2.1 of the License.
- * This library 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
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301, USA.
- **/
-package org.jbpm.pvm.internal.db.model;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.model.EventImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
-import org.jbpm.pvm.internal.model.WireProperties;
-import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ByteDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.CharacterDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ClassDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.DoubleDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.FloatDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.MapDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.NullDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.SetDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ShortDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor;
-import org.jbpm.pvm.internal.wire.operation.FieldOperation;
-import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
-import org.jbpm.pvm.test.EnvironmentDbTestCase;
-import org.jbpm.session.DbSession;
-
-/**
- * @author Guillaume Porcher
- *
- * This class uses process annotations to test wire descriptors
- * persistence
- */
-public class WireDbTest extends EnvironmentDbTestCase {
-
- public void testCharacterDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- CharacterDescriptor descriptor = new CharacterDescriptor();
- descriptor.setName("n");
- descriptor.setValue('c');
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (CharacterDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals('c', descriptor.construct(null));
- }
-
- public void testByteDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- ByteDescriptor descriptor = new ByteDescriptor();
- descriptor.setName("n");
- descriptor.setValue((byte) 6);
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (ByteDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals((byte) 6, descriptor.construct(null));
- }
-
- public void testClassDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- ClassDescriptor descriptor = new ClassDescriptor();
- descriptor.setName("n");
- descriptor.setClassName(EventImpl.class.getName());
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (ClassDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals(EventImpl.class, WireContext.create(descriptor));
- }
-
- public void testDoubleDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- DoubleDescriptor descriptor = new DoubleDescriptor();
- descriptor.setName("n");
- descriptor.setValue(6.666);
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (DoubleDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals(6.666, descriptor.construct(null));
- }
-
- public void testFalseDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- FalseDescriptor descriptor = new FalseDescriptor();
- descriptor.setName("n");
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (FalseDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals(Boolean.FALSE, descriptor.construct(null));
- }
-
- public void testFloatDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- FloatDescriptor descriptor = new FloatDescriptor();
- descriptor.setName("n");
- descriptor.setValue((float) 6.666);
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (FloatDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals((float) 6.666, descriptor.construct(null));
- }
-
- public void testIntegerDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- IntegerDescriptor descriptor = new IntegerDescriptor();
- descriptor.setName("n");
- descriptor.setValue(6);
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (IntegerDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals(6, descriptor.construct(null));
- }
-
- public void testLongDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- LongDescriptor descriptor = new LongDescriptor();
- descriptor.setName("n");
- descriptor.setValue(6L);
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (LongDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals(6L, descriptor.construct(null));
- }
-
- public void testNullDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- NullDescriptor descriptor = new NullDescriptor();
- descriptor.setName("n");
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (NullDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertNull(descriptor.construct(null));
- }
-
- public void testShortDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- ShortDescriptor descriptor = new ShortDescriptor();
- descriptor.setName("n");
- descriptor.setValue((short) 6);
-
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (ShortDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals((short) 6, descriptor.construct(null));
- }
-
- public void testStringDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- StringDescriptor descriptor = new StringDescriptor();
- descriptor.setName("n");
- descriptor.setValue("s");
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (StringDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals("s", descriptor.construct(null));
- }
-
- public void testTrueDescriptor() {
- DbSession dbSession = environment.get(DbSession.class);
-
- TrueDescriptor descriptor = new TrueDescriptor();
- descriptor.setName("n");
- dbSession.save(descriptor);
-
- newTransaction();
- dbSession = environment.get(DbSession.class);
-
- descriptor = (TrueDescriptor) dbSession.get(AbstractDescriptor.class, descriptor.getDbid());
- assertEquals("n", descriptor.getName());
- assertEquals(Boolean.TRUE, descriptor.construct(null));
- }
-
- public void testRefDescriptor() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- WireProperties configurations = new WireProperties();
-
- StringDescriptor referencedDescriptor = new StringDescriptor();
- referencedDescriptor.setName("referenced");
- referencedDescriptor.setValue("text");
- configurations.add(referencedDescriptor);
-
- ReferenceDescriptor descriptor = new ReferenceDescriptor();
- descriptor.setName("reference");
- descriptor.setValue("referenced");
- configurations.add(descriptor);
-
- dbSession.save(configurations);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- configurations = dbSession.get(WireProperties.class, configurations.getDbid());
-
- assertNotNull(configurations);
- assertEquals("text", configurations.get("reference"));
- }
-
- /**
- * Check that list descriptors are persisted
- */
- public void testListDescriptor() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- StringDescriptor stringD = new StringDescriptor();
- stringD.setValue("value");
-
- StringDescriptor string2D = new StringDescriptor();
- string2D.setValue("value2");
-
- List<Descriptor> listValues = new ArrayList<Descriptor>();
- listValues.add(stringD);
- listValues.add(string2D);
-
- ListDescriptor listD = new ListDescriptor();
- listD.setName("list");
- listD.setValueDescriptors(listValues);
- listD.setClassName(LinkedList.class.getName());
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .property(listD)
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- dbSession.save(processDefinition);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- List<String> result = (List<String>) p.getProperty("list");
- assertNotNull(result);
- assertEquals(2, result.size());
- assertEquals("value", result.get(0));
- assertEquals("value2", result.get(1));
-
- assertTrue(result instanceof LinkedList);
- }
-
- /**
- * Check that set descriptors are persisted
- */
- public void testSetDescriptor() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- StringDescriptor stringD = new StringDescriptor();
- stringD.setValue("value");
-
- StringDescriptor string2D = new StringDescriptor();
- string2D.setValue("value2");
-
- List<Descriptor> listValues = new ArrayList<Descriptor>();
- listValues.add(stringD);
- listValues.add(string2D);
-
- SetDescriptor setD = new SetDescriptor();
- setD.setName("set");
- setD.setValueDescriptors(listValues);
- setD.setClassName(TreeSet.class.getName());
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .property(setD)
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- dbSession.save(processDefinition);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- Set<String> result = (Set<String>) p.getProperty("set");
- assertNotNull(result);
- assertTrue(result.contains("value"));
- assertTrue(result.contains("value2"));
- assertEquals(2, result.size());
-
- assertTrue(result instanceof TreeSet);
- }
-
- /**
- * Check that map descriptors are persisted
- */
- public void testMapDescriptor() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- StringDescriptor keyD = new StringDescriptor();
- keyD.setValue("key");
-
- StringDescriptor key2D = new StringDescriptor();
- key2D.setValue("key2");
-
- StringDescriptor stringD = new StringDescriptor();
- stringD.setValue("value");
-
- StringDescriptor string2D = new StringDescriptor();
- string2D.setValue("value2");
-
- List<Descriptor> mapKeys = new ArrayList<Descriptor>();
- mapKeys.add(keyD);
- mapKeys.add(key2D);
-
- List<Descriptor> mapValues = new ArrayList<Descriptor>();
- mapValues.add(stringD);
- mapValues.add(string2D);
-
- MapDescriptor mapD = new MapDescriptor();
- mapD.setName("map");
- mapD.setValueDescriptors(mapValues);
- mapD.setKeyDescriptors(mapKeys);
- mapD.setClassName(TreeMap.class.getName());
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .property(mapD)
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- dbSession.save(processDefinition);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- Map<String, String> result = (Map<String, String>) p.getProperty("map");
- assertNotNull(result);
- assertEquals(2, result.size());
- assertEquals("value", result.get("key"));
- assertEquals("value2", result.get("key2"));
-
- assertTrue(result instanceof TreeMap);
- }
-
- /**
- * Check that map descriptors are persisted
- */
- public void testObjectDescriptor() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- ObjectDescriptor objDefault = new ObjectDescriptor();
- objDefault.setName("objectByEmptyConstr");
- objDefault.setClassName(Object.class.getName());
-
- ObjectDescriptor objConstr = new ObjectDescriptor();
- objConstr.setName("objectByConstr");
- objConstr.setClassName(Integer.class.getName());
-
- ArgDescriptor argObjConstr = new ArgDescriptor();
- argObjConstr.setTypeName(int.class.getName());
- IntegerDescriptor argObjConstrVal = new IntegerDescriptor();
- argObjConstrVal.setValue(42);
- argObjConstr.setDescriptor(argObjConstrVal);
-
- objConstr.addArgDescriptor(argObjConstr);
-
- ObjectDescriptor objStaticMethod = new ObjectDescriptor();
- objStaticMethod.setName("objectByStaticMethod");
- objStaticMethod.setClassName(Integer.class.getName());
- objStaticMethod.setMethodName("signum");
- ArgDescriptor argStaticMethod = new ArgDescriptor();
- argStaticMethod.setTypeName(int.class.getName());
- IntegerDescriptor argStaticMethodValue = new IntegerDescriptor();
- argStaticMethodValue.setValue(42);
- argStaticMethod.setDescriptor(argStaticMethodValue);
-
- objStaticMethod.addArgDescriptor(argStaticMethod);
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .property(objDefault)
- .property(objConstr)
- .property(objStaticMethod)
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- dbSession.save(processDefinition);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- assertNotNull(p.getProperty("objectByEmptyConstr"));
- assertEquals(42, p.getProperty("objectByConstr"));
- assertTrue(p.getProperty("objectByConstr") instanceof Integer);
-
- assertEquals(1, p.getProperty("objectByStaticMethod"));
- }
-
- /**
- * Check that map descriptors are persisted
- */
- public void testFieldOperation() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- ObjectDescriptor objDescr = new ObjectDescriptor(VariableDefinitionImpl.class.getName());
- objDescr.setName("object");
-
- FieldOperation fieldOp = new FieldOperation();
- fieldOp.setFieldName("name");
-
- StringDescriptor varNameDescriptor = new StringDescriptor();
- varNameDescriptor.setValue("varName");
-
- fieldOp.setDescriptor(varNameDescriptor);
-
- objDescr.addOperation(fieldOp);
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .property(objDescr)
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- dbSession.save(processDefinition);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- assertNotNull(p.getProperty("object"));
- assertTrue(p.getProperty("object") instanceof VariableDefinitionImpl);
- assertEquals("varName", ((VariableDefinitionImpl) p.getProperty("object")).getName());
- }
-
- /**
- * Check that map descriptors are persisted
- */
- public void testPropertyOperation() {
- DbSession dbSession = (DbSession) environment.get(DbSession.class);
- assertNotNull(dbSession);
-
- ObjectDescriptor objDescr = new ObjectDescriptor();
- objDescr.setName("object");
- objDescr.setClassName(VariableDefinitionImpl.class.getName());
-
- PropertyOperation propertyOp = new PropertyOperation();
- propertyOp.setPropertyName("name");
-
- StringDescriptor varNameDescriptor = new StringDescriptor();
- varNameDescriptor.setValue("varName");
-
- propertyOp.setDescriptor(varNameDescriptor);
-
- objDescr.addOperation(propertyOp);
-
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder
- .startProcess()
- .property(objDescr)
- .startActivity()
- .initial()
- .endActivity()
- .endProcess();
-
- dbSession.save(processDefinition);
-
- newTransaction();
-
- dbSession = (DbSession) environment.get(DbSession.class);
-
- OpenProcessDefinition p = (OpenProcessDefinition) dbSession.get(ProcessDefinitionImpl.class, processDefinition.getDbid());
-
- assertNotNull(p);
- assertNotSame(processDefinition, p);
-
- assertNotNull(p.getProperty("object"));
- assertTrue(p.getProperty("object") instanceof VariableDefinitionImpl);
- assertEquals("varName", ((VariableDefinitionImpl) p.getProperty("object")).getName());
- }
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/model/WireTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,108 +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.db.model;
-
-import org.hibernate.Session;
-import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.test.EnvironmentDbTestCase;
-import org.jbpm.session.DbSession;
-
-/**
- * @author Tom Baeyens
- */
-public class WireTest extends EnvironmentDbTestCase
-{
-
- public void testObjectDescriptor()
- {
- DbSession persistenceSession = (DbSession)environment.get(DbSession.class);
-
- ObjectDescriptor objStaticMethod = new ObjectDescriptor();
- objStaticMethod.setName("objectByStaticMethod");
- objStaticMethod.setClassName(Integer.class.getName());
- objStaticMethod.setMethodName("signum");
- ArgDescriptor argStaticMethod = new ArgDescriptor();
- argStaticMethod.setTypeName(int.class.getName());
- IntegerDescriptor argStaticMethodValue = new IntegerDescriptor();
- argStaticMethodValue.setValue(42);
- argStaticMethod.setDescriptor(argStaticMethodValue);
-
- objStaticMethod.addArgDescriptor(argStaticMethod);
-
- persistenceSession.save(argStaticMethodValue);
- environment.get(Session.class).flush();
-
- persistenceSession.save(objStaticMethod);
- environment.get(Session.class).flush();
-
- persistenceSession.save(objStaticMethod);
- environment.get(Session.class).flush();
-
- }
-
- /*
- * public void testObjectDescriptor() { DbSession persistenceSession = (DbSession) environment.get(DbSession.class);
- * assertNotNull(persistenceSession);
- *
- * ObjectDescriptor objDefault = new ObjectDescriptor(); objDefault.setName("objectByEmptyConstr");
- * objDefault.setClassName(Object.class.getName());
- *
- * ObjectDescriptor objConstr = new ObjectDescriptor(); objConstr.setName("objectByConstr");
- * objConstr.setClassName(Integer.class.getName());
- *
- * ArgDescriptor argObjConstr = new ArgDescriptor(); argObjConstr.setTypeName(int.class.getName()); IntegerDescriptor
- * argObjConstrVal = new IntegerDescriptor(); argObjConstrVal.setValue(42);
- * argObjConstr.setDescriptor(argObjConstrVal);
- *
- * objConstr.addArgDescriptor(argObjConstr);
- *
- * ObjectDescriptor objStaticMethod = new ObjectDescriptor(); objStaticMethod.setName("objectByStaticMethod");
- * objStaticMethod.setClassName(Integer.class.getName()); objStaticMethod.setMethodName("signum"); ArgDescriptor
- * argStaticMethod = new ArgDescriptor(); argStaticMethod.setTypeName(int.class.getName()); IntegerDescriptor
- * argStaticMethodValue = new IntegerDescriptor(); argStaticMethodValue.setValue(42);
- * argStaticMethod.setDescriptor(argStaticMethodValue);
- *
- * objStaticMethod.addArgDescriptor(argStaticMethod);
- *
- * ProcessDefinition processDefinition = ProcessFactory.build() .configuration(objDefault) .configuration(objConstr)
- * .configuration(objStaticMethod) .done();
- *
- * persistenceSession.save(processDefinition);
- *
- * newTransaction();
- *
- * DbSession testSession = (DbSession) environment.get(DbSession.class);
- *
- * ProcessDefinition p = (ProcessDefinition) testSession.get(ProcessDefinitionImpl.class,
- * processDefinition.getDbid());
- *
- * assertNotNull(p); assertNotSame(processDefinition, p);
- *
- * assertNotNull(p.getConfigurations()); assertNotNull(p.getConfigurations().get("objectByEmptyConstr"));
- * assertEquals(42 , p.getConfigurations().get("objectByConstr"));
- * assertTrue(p.getConfigurations().get("objectByConstr") instanceof Integer);
- *
- * assertEquals(1, p.getConfigurations().get("objectByStaticMethod")); }
- */
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,70 +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.execution;
-
-import org.jbpm.Execution;
-import org.jbpm.ExecutionService;
-import org.jbpm.ProcessService;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.activities.AutomaticActivity;
-import org.jbpm.pvm.activities.WaitState;
-import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
-import org.jbpm.pvm.test.EnvironmentFactoryTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class PvmProcessExecutionTest extends EnvironmentFactoryTestCase {
-
- public void testDeploy() {
- JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
- ProcessService processService = environmentFactory.get(ProcessService.class);
-
- ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("test")
- .startActivity("start", WaitState.class)
- .initial()
- .transition("end", "end")
- .endActivity()
- .startActivity("end", AutomaticActivity.class)
- .endActivity()
- .endProcess();
-
- processService
- .createDeployment()
- .addProcessDefinition(processDefinition)
- .deploy();
- }
-
- public void testStartProcessInstance() {
- JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
- ExecutionService executionService = environmentFactory.get(ExecutionService.class);
- Execution execution = executionService.startProcessInstanceById("test-1", "request17");
- }
-
- public void testResumeProcessInstance() {
- JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
- ExecutionService executionService = environmentFactory.get(ExecutionService.class);
- Execution execution = executionService.signalExecutionById("test.request17", "end");
- }
-
-}
\ No newline at end of file
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/AsyncContinuationsTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,102 +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.jobexecutor;
-
-import org.hibernate.Session;
-import org.jbpm.Execution;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.pvm.activities.AutomaticActivity;
-import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class AsyncContinuationsTest extends JbpmTestCase {
-
- public void testContinuations() {
- deployProcess();
-
- Execution execution = executionService.startProcessInstanceByKey("continuations");
-
- assertEquals("start", execution.getActivityName());
- assertEquals(Execution.STATE_ASYNC, execution.getState());
-
- executeAsyncMessage(execution);
- execution = executionService.findExecution(execution.getId());
-
- assertEquals("a", execution.getActivityName());
- assertEquals(Execution.STATE_ASYNC, execution.getState());
-
- executeAsyncMessage(execution);
- execution = executionService.findExecution(execution.getId());
-
- assertEquals("b", execution.getActivityName());
- assertEquals(Execution.STATE_ASYNC, execution.getState());
-
- executeAsyncMessage(execution);
- execution = executionService.findExecution(execution.getId());
-
- assertEquals("c", execution.getActivityName());
- assertEquals(Execution.STATE_ASYNC, execution.getState());
-
- executeAsyncMessage(execution);
-
- assertNull(executionService.findExecution(execution.getId()));
- }
-
- public void deployProcess() {
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- OpenProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("continuations")
- .key("continuations")
- .startActivity("start", AutomaticActivity.class)
- .initial()
- .asyncExecute()
- .transition("a")
- .endActivity()
- .startActivity("a", AutomaticActivity.class)
- .asyncExecute()
- .transition("b")
- .endActivity()
- .startActivity("b", AutomaticActivity.class)
- .asyncExecute()
- .transition("c")
- .endActivity()
- .startActivity("c", AutomaticActivity.class)
- .asyncExecute()
- .transition("end")
- .endActivity()
- .startActivity("end", AutomaticActivity.class)
- .endActivity()
- .endProcess();
-
- Session session = environment.get(Session.class);
- session.save(processDefinition);
- return null;
- }
- });
- }
-}
Deleted: jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/java/org/jbpm/pvm/variables/CustomTypeVariableTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,82 +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.variables;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.activities.WaitState;
-import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.type.Variable;
-import org.jbpm.pvm.internal.type.variable.DateVariable;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.test.EnvironmentDbTestCase;
-
-/**
- * @author Guillaume Porcher
- */
-public class CustomTypeVariableTest extends EnvironmentDbTestCase {
-
- private static final String ENVIRONMENT_CFG_XML = "org/jbpm/pvm/variables/custom.types.jbpm.cfg.xml";
-
- public CustomTypeVariableTest() {
- super(ENVIRONMENT_CFG_XML);
- }
-
- public void testDateVariable() {
- ClientProcessDefinition clientProcessDefinition = ProcessDefinitionBuilder
- .startProcess()
- .startActivity(
- new ObjectDescriptor(WaitState.class)
- )
- .initial()
- .endActivity()
- .endProcess();
-
- getDbSession().save(clientProcessDefinition);
-
- ExecutionImpl execution = (ExecutionImpl) clientProcessDefinition.startProcessInstance();
-
- execution = reload(execution, ExecutionImpl.class);
-
- Calendar calendar = new GregorianCalendar();
- calendar.set(Calendar.YEAR, 2007);
- calendar.set(Calendar.MONTH, 10); // (10 == november)
- calendar.set(Calendar.DAY_OF_MONTH, 22);
- calendar.set(Calendar.HOUR_OF_DAY, 15);
- calendar.set(Calendar.MINUTE, 28);
- calendar.set(Calendar.SECOND, 57);
- calendar.set(Calendar.MILLISECOND, 374);
-
- execution.setVariable("v", calendar.getTime());
-
- execution = reload(execution, ExecutionImpl.class);
-
- Variable variable = execution.getVariableObject("v");
- assertEquals(DateVariable.class, variable.getClass());
-
- assertEquals(calendar.getTime(), execution.getVariable("v"));
- }
-
-}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.task.hbm.xml 2009-03-29 11:04:09 UTC (rev 4347)
@@ -118,11 +118,7 @@
column="SWIMLANE_"
foreign-key="FK_TASK_SWIML" />
- <!-- many-to-one name="taskDefinition"
- column="TASKDEF_"
- class="org.jbpm.pvm.internal.task.TaskDefinitionImpl"
- foreign-key="FK_TSK_TASKDEF"
- index="IDX_TSK_TASKDEF" / -->
+ <property name="taskDefinitionName" column="TASKDEFNAME_"/>
<list name="comments" cascade="all-delete-orphan">
<key column="TASK_" />
Modified: jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -58,14 +58,14 @@
static protected Log log = Log.getLog(BaseJbpmTestCase.class.getName());
protected void setUp() throws Exception {
- assertNull(Environment.getCurrent());
+ assertNull("there is already an environment open", Environment.getCurrent());
LogFormatter.resetIndentation();
log.debug("=== starting "+getName()+" =============================");
}
protected void tearDown() throws Exception {
log.debug("=== ending "+getName()+" =============================\n");
- assertNull(Environment.getCurrent());
+ assertNull("there is still an environment open", Environment.getCurrent());
}
public void assertTextPresent(String expected, String value) {
Modified: jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -117,7 +117,7 @@
protected void tearDown() throws Exception {
if (registeredDeployments!=null) {
for (Long deploymentDbid : registeredDeployments) {
- repositoryService.deleteDeployment(deploymentDbid);
+ repositoryService.deleteDeploymentCascade(deploymentDbid);
}
}
@@ -132,13 +132,15 @@
super.tearDown();
}
- public void deployJpdlXmlString(String jpdlXmlString) {
+ public long deployJpdlXmlString(String jpdlXmlString) {
long deploymentDbid =
repositoryService.createDeployment()
.addResourceFromString("xmlstring.jpdl.xml", jpdlXmlString)
.deploy();
registerDeployment(deploymentDbid);
+
+ return deploymentDbid;
}
public void deployJpdlResource(String resource) {
Modified: jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -175,8 +175,6 @@
"</process>"
);
- ProcessDefinition processDefinition = processService.findProcessDefinitionsByKey("ICL").get(0);
-
// start an execution for the process with the given id
Execution execution = executionService.startProcessInstanceById("ICL-1");
assertNotNull(execution);
Deleted: jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/ProcessServiceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/ProcessServiceTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/ProcessServiceTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -1,358 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.process;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.Execution;
-import org.jbpm.JbpmException;
-import org.jbpm.ProcessDefinition;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessServiceTest extends JbpmTestCase {
-
- public void testProcessWithNameOnly() {
- deployJpdlXmlString(
- "<process name='Insurance claim'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Insurance_claim");
-
- assertNotNull(processDefinition);
- assertEquals("Insurance claim", processDefinition.getName());
- assertEquals("Insurance_claim", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("Insurance_claim-1", processDefinition.getId());
- }
-
- public void testProcessWithNameAndKey() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("ICL");
-
- assertNotNull(processDefinition);
- assertEquals("Insurance claim", processDefinition.getName());
- assertEquals("ICL", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("ICL-1", processDefinition.getId());
- }
-
- // interface methods ////////////////////////////////////////////////////////
-
- public void testFindProcessDefinitionKeys() {
- deployMultipleVersionsOfProcesses();
-
- List<String> processKeys = processService.findProcessDefinitionKeys();
-
- List<String> expected = new ArrayList<String>();
- expected.add("nuclear_fusion");
- expected.add("publish_book");
- expected.add("ultimate_seduction");
-
- assertEquals(expected, processKeys);
- }
-
-
- public void testFindProcessByKey() {
- deployJpdlXmlString(
- "<process name='Name with spaces'>" +
- " <start />" +
- "</process>"
- );
-
- ProcessDefinition processDefinition = processService.findLatestProcessDefinitionByKey("Name_with_spaces");
- assertNotNull(processDefinition);
- assertEquals("Name with spaces", processDefinition.getName());
- assertEquals("Name_with_spaces", processDefinition.getKey());
- assertEquals(1, processDefinition.getVersion());
- assertEquals("Name_with_spaces-1", processDefinition.getId());
- }
-
- public void testFindProcessDefinitions() {
- deployMultipleVersionsOfProcesses();
-
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("nuclear_fusion");
- assertNotNull(processDefinitions);
-
- assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
- assertEquals("nuclear fusion", processDefinitions.get(0).getName());
- assertEquals(3, processDefinitions.get(0).getVersion());
-
- assertEquals("nuclear fusion", processDefinitions.get(1).getName());
- assertEquals(2, processDefinitions.get(1).getVersion());
-
- assertEquals("nuclear fusion", processDefinitions.get(2).getName());
- assertEquals(1, processDefinitions.get(2).getVersion());
- }
-
- public void testFindLatestProcessDefinition() {
- deployMultipleVersionsOfProcesses();
-
- ProcessDefinition retrieved = processService.findLatestProcessDefinitionByKey("nuclear_fusion");
- assertNotNull(retrieved);
-
- assertEquals(3, retrieved.getVersion());
- assertEquals("nuclear fusion", retrieved.getName());
- assertEquals("nuclear_fusion", retrieved.getKey());
- }
-
- public void testFindProcessDefinitionById() {
- deployJpdlXmlString(
- "<process name='given' version='33'>" +
- " <start />" +
- "</process>"
- );
-
- // load it
- ProcessDefinition processDefinition = processService.findProcessDefinitionById("given-33");
- assertNotNull(processDefinition);
- assertEquals("given", processDefinition.getName());
- assertEquals(33, processDefinition.getVersion());
- }
-
- public void testDeleteProcessDefinition() {
- processService.createDeployment()
- .addResourceFromString("xmlstring.jpdl.xml",
- "<process name='deleteme' version='33'>" +
- " <start />" +
- "</process>")
- .deploy();
-
- // delete it
- processService.deleteProcessDefinition("deleteme-33");
-
- // check if the db is empty
- assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
- }
-
- public void testDeleteProcessDefinitionAndInstances() {
- processService.createDeployment()
- .addResourceFromString("xmlstring.jpdl.xml",
- "<process name='deleteme' version='33'>" +
- " <start>" +
- " <transition to='w' />" +
- " </start>" +
- " <state name='w' />" +
- "</process>")
- .deploy();
-
- executionService.startProcessInstanceByKey("deleteme");
- executionService.startProcessInstanceByKey("deleteme");
- executionService.startProcessInstanceByKey("deleteme");
- executionService.startProcessInstanceByKey("deleteme");
-
- // delete it all
- processService.deleteProcessDefinitionCascade("deleteme-33");
-
- // check if the db is empty
- assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
- assertEquals(0, executionService.createExecutionQuery().execute().size());
- }
-
- public void testDeleteProcessDefinitionButNotInstances() {
- deployJpdlXmlString(
- "<process name='deleteme' version='33'>" +
- " <start>" +
- " <transition to='w' />" +
- " </start>" +
- " <state name='w' />" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("deleteme");
- executionService.startProcessInstanceByKey("deleteme");
- executionService.startProcessInstanceByKey("deleteme");
- executionService.startProcessInstanceByKey("deleteme");
-
- // delete it all
- try {
- processService.deleteProcessDefinition("deleteme-33");
- fail("expected exception");
- } catch (JbpmException e) {
- assertTextPresent("still 4 process instances for process definition deleteme-33", e.getMessage());
- }
- }
-
- // various other aspects ////////////////////////////////////////////////////
-
- public void testAutomaticVersioning() {
- deployJpdlXmlString(
- "<process name='versionme'>" +
- " <start />" +
- "</process>"
- );
-
- // look it up again
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("versionme");
- assertNotNull(processDefinitions);
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- ProcessDefinition processDefinition = processDefinitions.get(0);
- // and check that automatically assigned version starts with 1
- assertEquals(1, processDefinition.getVersion());
-
- deployJpdlXmlString(
- "<process name='versionme'>" +
- " <start />" +
- "</process>"
- );
-
- // look them up again
- processDefinitions = processService.findProcessDefinitionsByKey("versionme");
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
- // and check that automatically assigned version starts with 1
- assertEquals(2, processDefinitions.get(0).getVersion());
- assertEquals(1, processDefinitions.get(1).getVersion());
- }
-
- public void testUserProvidedVersion() {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
-
- // load it
- List<ProcessDefinition> processDefinitions = processService.findProcessDefinitionsByKey("takethis");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- ProcessDefinition processDefinition = processDefinitions.get(0);
- // verify that the user specified version was used
- // (and not overwritten by an automatically assigned versioning)
- assertEquals(234, processDefinition.getVersion());
- }
-
- public void testDuplicateUserProvidedVersion() {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
-
- try {
- deployJpdlXmlString(
- "<process name='takethis' version='234'>" +
- " <start />" +
- "</process>"
- );
- fail("expected exception");
- } catch (JbpmException e) {
- assertTextPresent("process 'takethis-234' already exists", e.getMessage());
- }
- }
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
- * 'publish book'
- */
- void deployMultipleVersionsOfProcesses() {
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='ultimate seduction'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='publish book'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='nuclear fusion'>" +
- " <start />" +
- "</process>"
- );
- }
-
- public void testMinimalProcess() {
- deployJpdlXmlString(
- "<process name='minimal'>" +
- " <start>" +
- " <transition to='end' />" +
- " </start>" +
- " <end name='end' />" +
- "</process>"
- );
-
- Execution execution = executionService.startProcessInstanceByKey("minimal");
-
- assertEquals("end", execution.getActivityName());
- assertTrue(execution.isEnded());
- assertFalse(execution.isActive());
- }
-
- public void testMostMinimalProcess() {
- deployJpdlXmlString(
- "<process name='minimal'>" +
- " <start />" +
- "</process>"
- );
-
- Execution execution = executionService.startProcessInstanceByKey("minimal");
-
- assertTrue(execution.isEnded());
- assertFalse(execution.isActive());
- }
-}
Added: jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/test/java/org/jbpm/test/process/RepositoryServiceTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -0,0 +1,378 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.process;
+
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.JbpmException;
+import org.jbpm.ProcessDefinition;
+import org.jbpm.ProcessDefinitionQuery;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RepositoryServiceTest extends JbpmTestCase {
+
+ public void testProcessWithNameOnly() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .key("Insurance_claim")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .page(0,1)
+ .uniqueResult();
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("Insurance_claim", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Insurance_claim-1", processDefinition.getId());
+ }
+
+ public void testProcessWithNameAndKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .key("ICL")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .page(0,1)
+ .uniqueResult();
+
+ assertNotNull(processDefinition);
+ assertEquals("Insurance claim", processDefinition.getName());
+ assertEquals("ICL", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("ICL-1", processDefinition.getId());
+ }
+
+ // interface methods ////////////////////////////////////////////////////////
+
+ public void testFindProcessByKey() {
+ deployJpdlXmlString(
+ "<process name='Name with spaces'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .key("Name_with_spaces")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .page(0,1)
+ .uniqueResult();
+
+ assertNotNull(processDefinition);
+ assertEquals("Name with spaces", processDefinition.getName());
+ assertEquals("Name_with_spaces", processDefinition.getKey());
+ assertEquals(1, processDefinition.getVersion());
+ assertEquals("Name_with_spaces-1", processDefinition.getId());
+ }
+
+ public void testFindProcessDefinitions() {
+ deployMultipleVersionsOfProcesses();
+
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .key("nuclear_fusion")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .execute();
+ assertNotNull(processDefinitions);
+
+ assertEquals("expected 3 but was " + processDefinitions.size() + ": " + processDefinitions, 3, processDefinitions.size());
+ assertEquals("nuclear fusion", processDefinitions.get(0).getName());
+ assertEquals(3, processDefinitions.get(0).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(1).getName());
+ assertEquals(2, processDefinitions.get(1).getVersion());
+
+ assertEquals("nuclear fusion", processDefinitions.get(2).getName());
+ assertEquals(1, processDefinitions.get(2).getVersion());
+ }
+
+ public void testFindLatestProcessDefinition() {
+ deployMultipleVersionsOfProcesses();
+
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .key("nuclear_fusion")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .page(0,1)
+ .uniqueResult();
+ assertNotNull(processDefinition);
+
+ assertEquals(3, processDefinition.getVersion());
+ assertEquals("nuclear fusion", processDefinition.getName());
+ assertEquals("nuclear_fusion", processDefinition.getKey());
+ }
+
+ public void testFindProcessDefinitionById() {
+ deployJpdlXmlString(
+ "<process name='given' version='33'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+ .id("given-33")
+ .uniqueResult();
+
+ assertNotNull(processDefinition);
+ assertEquals("given", processDefinition.getName());
+ assertEquals(33, processDefinition.getVersion());
+ }
+
+ public void testDeleteDeployment() {
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start />" +
+ "</process>")
+ .deploy();
+
+ // delete it
+ repositoryService.deleteDeployment(deploymentDbid);
+
+ // check if the db is empty
+ assertEquals(0, repositoryService.createProcessDefinitionQuery().execute().size());
+ }
+
+ public void testDeleteProcessDefinitionAndInstances() {
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromString("xmlstring.jpdl.xml",
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <transition to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>")
+ .deploy();
+
+ executionService.startProcessInstanceByKey("deleteme");
+ executionService.startProcessInstanceByKey("deleteme");
+ executionService.startProcessInstanceByKey("deleteme");
+ executionService.startProcessInstanceByKey("deleteme");
+
+ // delete it all
+ repositoryService.deleteDeploymentCascade(deploymentDbid);
+
+ // check if the db is empty
+ assertEquals(0, repositoryService.createProcessDefinitionQuery().execute().size());
+ assertEquals(0, executionService.createExecutionQuery().execute().size());
+ }
+
+ public void testDeleteProcessDefinitionButNotInstances() {
+ long deploymentDbid = deployJpdlXmlString(
+ "<process name='deleteme' version='33'>" +
+ " <start>" +
+ " <transition to='w' />" +
+ " </start>" +
+ " <state name='w' />" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("deleteme");
+ executionService.startProcessInstanceByKey("deleteme");
+ executionService.startProcessInstanceByKey("deleteme");
+ executionService.startProcessInstanceByKey("deleteme");
+
+ // delete it all
+ try {
+ repositoryService.deleteDeployment(deploymentDbid);
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("cannot delete deployment 23: still executions for process(deleteme): ", e.getMessage());
+ }
+ }
+
+ // various other aspects ////////////////////////////////////////////////////
+
+ public void testAutomaticVersioning() {
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look it up again
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .key("versionme")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .execute();
+
+ assertNotNull(processDefinitions);
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // and check that automatically assigned version starts with 1
+ assertEquals(1, processDefinition.getVersion());
+
+ deployJpdlXmlString(
+ "<process name='versionme'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // look them up again
+ processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .key("versionme")
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .execute();
+
+ // verify that there is only one
+ assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
+ // and check that automatically assigned version starts with 1
+ assertEquals(2, processDefinitions.get(0).getVersion());
+ assertEquals(1, processDefinitions.get(1).getVersion());
+ }
+
+ public void testUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ // load it
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .key("takethis")
+ .execute();
+
+ assertNotNull(processDefinitions);
+ assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
+ ProcessDefinition processDefinition = processDefinitions.get(0);
+ // verify that the user specified version was used
+ // (and not overwritten by an automatically assigned versioning)
+ assertEquals(234, processDefinition.getVersion());
+ }
+
+ public void testDuplicateUserProvidedVersion() {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ try {
+ deployJpdlXmlString(
+ "<process name='takethis' version='234'>" +
+ " <start />" +
+ "</process>"
+ );
+ fail("expected exception");
+ } catch (JbpmException e) {
+ assertTextPresent("process 'takethis-234' already exists", e.getMessage());
+ }
+ }
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the processes 'ultimate seduction' and
+ * 'publish book'
+ */
+ void deployMultipleVersionsOfProcesses() {
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='ultimate seduction'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='publish book'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='nuclear fusion'>" +
+ " <start />" +
+ "</process>"
+ );
+ }
+
+ public void testMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start>" +
+ " <transition to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("minimal");
+
+ assertEquals("end", execution.getActivityName());
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+
+ public void testMostMinimalProcess() {
+ deployJpdlXmlString(
+ "<process name='minimal'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ Execution execution = executionService.startProcessInstanceByKey("minimal");
+
+ assertTrue(execution.isEnded());
+ assertFalse(execution.isActive());
+ }
+}
Modified: jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.task.hbm.xml 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.task.hbm.xml 2009-03-29 11:04:09 UTC (rev 4347)
@@ -118,11 +118,7 @@
column="SWIMLANE_"
foreign-key="FK_TASK_SWIML" />
- <!-- many-to-one name="taskDefinition"
- column="TASKDEF_"
- class="org.jbpm.pvm.internal.task.TaskDefinitionImpl"
- foreign-key="FK_TSK_TASKDEF"
- index="IDX_TSK_TASKDEF" / -->
+ <property name="taskDefinitionName" column="TASKDEFNAME_"/>
<list name="comments" cascade="all-delete-orphan">
<key column="TASK_" />
Modified: jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java 2009-03-28 17:58:26 UTC (rev 4346)
+++ jbpm4/branches/tbaeyens/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java 2009-03-29 11:04:09 UTC (rev 4347)
@@ -32,7 +32,7 @@
import org.jbpm.cmd.Command;
import org.jbpm.env.Environment;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.cmd.StartProcessInstanceCmd;
import org.jbpm.pvm.internal.job.CommandMessage;
import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
@@ -119,7 +119,7 @@
public Object execute(Environment environment) throws Exception {
MessageSession messageSession = environment.get(MessageSession.class);
for (int i = 0; i < nbrOfTestExecutions; i++) {
- Execution execution = new StartExecutionCmd("excl:1", null, "execution-" + i).execute(environment);
+ Execution execution = new StartProcessInstanceCmd("excl:1", null, "execution-" + i).execute(environment);
for (int j = 0; j < nbrOfTestMessagesPerExecution; j++) {
CommandMessage exclusiveTestMessage = ExclusiveTestCommand.createMessage(execution);
More information about the jbpm-commits
mailing list