Author: tom.baeyens(a)jboss.com
Date: 2008-12-03 12:06:54 -0500 (Wed, 03 Dec 2008)
New Revision: 3184
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByNameCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionNamesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessIdDeployer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessVersionDeployer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessIdBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessVersionBinding.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ManagementServiceTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
jbpm4/trunk/modules/api/src/main/resources/cfg.xsd
jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml
jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/pvm/pom.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.definition.hbm.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/basicfeatures/AutomaticDecisionDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/timer/TimerIntegrationTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java
jbpm4/trunk/modules/pvm/src/test/resources/environment.cfg.xml
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml
jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/userguide/.settings/attachedFile.properties
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml
Log:
sanetized process service for usage with keys instead of names
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2008-12-03
14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -55,32 +55,6 @@
Execution startExecutionById(String processDefinitionId, Map<String, Object>
variables, String executionKey);
/** starts a new execution in the latest version of the given process definition.
- * @param processDefinitionName is the name of the process definition for which the
latest version will be taken. */
- Execution startExecutionByName(String processDefinitionName);
-
- /** starts a new execution in the latest version of the given processDefinitionName.
- * @param processDefinitionName is the name of the process definition
- * for which the latest version will be taken.
- * @param executionKey is a user provided reference for the new execution
- * that must be unique over all process versions with the same name. */
- Execution startExecutionByName(String processDefinitionName, String executionKey);
-
- /** starts a new execution in the latest version of the given processDefinitionName.
- * @param processDefinitionName is the name of the process definition
- * for which the latest version will be taken.
- * @param variables are the initial values of the process variables that
- * will be set before the execution starts (read: before the initial
- * node is executed). */
- Execution startExecutionByName(String processDefinitionName, Map<String, Object>
variables);
-
- /** starts a new execution in the latest version of the given processDefinitionName.
- * @param processDefinitionName is the name of the process definition for which the
latest version will be taken.
- * @param variables are the initial values of the process variables that will be set
before the execution starts.
- * @param executionKey is a user provided reference for the new execution that must be
unique over all
- * process versions with the same name. */
- Execution startExecutionByName(String processDefinitionName, Map<String, Object>
variables, String executionKey);
-
- /** starts a new execution in the latest version of the given process definition.
* @param processDefinitionKey is the key of the process definition for which the
latest version will be taken. */
Execution startExecutionByKey(String processDefinitionKey);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java 2008-12-03 14:28:41
UTC (rev 3183)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java 2008-12-03 17:06:54
UTC (rev 3184)
@@ -33,23 +33,17 @@
/** start a deployment */
Deployment createDeployment();
- /** TODO REMOVE: deploy a new process definition into the process repository. */
- List<ProcessDefinition> deploy(Deployment deployment);
+ /** all deployed process definition keys. */
+ List<String> findProcessDefinitionKeys();
- /** all deployed process names. */
- List<String> findProcessDefinitionNames();
-
/** all versions of the given process. */
- List<ProcessDefinition> findProcessDefinitions(String processDefinitionName);
+ List<ProcessDefinition> findProcessDefinitionsByKey(String
processDefinitionKey);
- /** latest version of the processDefinition with the given name. */
- ProcessDefinition findLatestProcessDefinitionByName(String processDefinitionName);
-
/** latest version of the processDefinition with the given key. */
ProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey);
/** specific version of a named processDefinition. */
- ProcessDefinition findProcessDefinition(String processDefinitionName, int
processDefinitionVersion);
+ ProcessDefinition findProcessDefinitionById(String processDefinitionId);
/** deletes process definition if there are no existing executions.
* @throws JbpmException if there are existing executions. */
@@ -57,4 +51,8 @@
/** deletes process definition and the existing executions. */
void deleteProcessDefinitionAndInstances(String processDefinitionId);
+
+
+ /** TODO REMOVE: deploy a new process definition into the process repository. */
+ List<ProcessDefinition> deploy(Deployment deployment);
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2008-12-03
14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -34,26 +34,35 @@
* @author Tom Baeyens
*/
public interface PvmDbSession extends DbSession {
+
+ // process definition queries ///////////////////////////////////////////////
/** all deployed process names. */
- List<String> findProcessDefinitionNames();
+ List<String> findProcessDefinitionKeys();
- /** all versions of the given process. */
- List<ClientProcessDefinition> findProcessDefinitionsByName(String name);
+ /** latest version of the processDefinition for the given key. */
+ ClientProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey);
- /** specific version of a named processDefinition. */
- ClientProcessDefinition findProcessDefinitionByName(String name, int version);
+ /** all versions of the processDefinition for the given key. */
+ List<ClientProcessDefinition> findProcessDefinitionsByKey(String
processDefinitionKey);
- /** latest version of the processDefinition for the given name. */
- ClientProcessDefinition findLatestProcessDefinitionByName(String name);
-
/** the process definition uniquely identified by the given
* processDefinition id. */
ClientProcessDefinition findProcessDefinitionById(String processDefinitionId);
- /** latest version of the processDefinition for the given key. */
- ClientProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey);
+ /** the first key for an existing process definition with the given
processDefinitionName
+ * @returns null in case no such processDefinitionName exists */
+ String findProcessDefinitionKeyByName(String processDefinitionName);
+ /** the first name for an existing process definition with the given
processDefinitionKey
+ * @returns null in case no such processDefinitionKey exists */
+ String findProcessDefinitionNameByKey(String processDefinitionKey);
+
+ /** delete process definition */
+ void deleteProcessDefinition(String processDefinitionId, boolean
deleteProcessInstances);
+
+ // process execution queries ////////////////////////////////////////////////
+
/** the execution uniquely identified by the given executionKey. */
ClientExecution findExecutionById(String executionId);
@@ -61,6 +70,14 @@
* and the execution key. */
Execution findExecutionByKey(String processDefinitionName, String executionKey);
+ /* find ids for all process instances for a given process definition. */
+ List<String> findProcessInstanceIds(String processDefinitionId);
+
+ /** delete the process instance */
+ void deleteProcessInstance(String processInstanceId);
+
+ // job queries //////////////////////////////////////////////////////////////
+
/** timers */
List<Timer> findTimers(int firstResult, int maxResults);
@@ -70,14 +87,4 @@
/** the jobs for which all the retries have failed and which will not be
* picked up any more by the jobImpl executor */
public List<Job> findJobsWithException(int firstResult, int maxResults);
-
- /* find ids for all process instances for a given process definition. */
- List<String> findProcessInstanceIds(String processDefinitionId);
-
- /** delete the process instance */
- void deleteProcessInstance(String processInstanceId);
-
- /** delete process definition */
- void deleteProcessDefinition(String processDefinitionId, boolean
deleteProcessInstances);
-
}
Modified: jbpm4/trunk/modules/api/src/main/resources/cfg.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/cfg.xsd 2008-12-03 14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/api/src/main/resources/cfg.xsd 2008-12-03 17:06:54 UTC (rev 3184)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
-
targetNamespace="http://jbpm.org/xsd/cfg"
-
xmlns:tns="http://jbpm.org/xsd/cfg"
+
targetNamespace="http://jbpm.org/4/cfg"
+
xmlns:tns="http://jbpm.org/4/cfg"
elementFormDefault="qualified">
<annotation>
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd 2008-12-03 14:28:41 UTC (rev
3183)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd 2008-12-03 17:06:54 UTC (rev
3184)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
-
targetNamespace="http://jbpm.org/jpdl4"
-
xmlns:tns="http://jbpm.org/jpdl4"
+
targetNamespace="http://jbpm.org/4/jpdl"
+
xmlns:tns="http://jbpm.org/4/jpdl"
elementFormDefault="qualified"
attributeFormDefault="qualified">
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml
===================================================================
---
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-ExecutionModes.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -111,8 +111,7 @@
<file extension=".jpdl.xml"
type="jpdl" />
</assign-file-type>
<parse-jpdl />
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified: jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.cfg.xml 2008-12-03 14:28:41 UTC (rev
3183)
+++ jbpm4/trunk/modules/jpdl/src/test/resources/jbpm.cfg.xml 2008-12-03 17:06:54 UTC (rev
3184)
@@ -9,8 +9,7 @@
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
<parse-jpdl />
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml 2008-12-03 14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/pvm/pom.xml 2008-12-03 17:06:54 UTC (rev 3184)
@@ -180,6 +180,8 @@
<exclude>**/TimerIntegrationTest.java</exclude>
<exclude>**/ProcessServiceTest.java</exclude>
<exclude>**/JobExecutorTest.java</exclude>
+ <exclude>**/ContinuationTest.java</exclude>
+ <exclude>**/LanguageExtensionsDbTest.java</exclude>
</excludes>
</configuration>
</plugin>
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByNameCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByNameCmd.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindLatestProcessDefinitionByNameCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.session.PvmDbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FindLatestProcessDefinitionByNameCmd implements
Command<OpenProcessDefinition> {
-
- private static final long serialVersionUID = 1L;
-
- protected String processDefinitionName;
-
- public FindLatestProcessDefinitionByNameCmd(String processDefinitionName) {
- this.processDefinitionName = processDefinitionName;
- }
-
- public OpenProcessDefinition execute(Environment environment) throws Exception {
- return
environment.get(PvmDbSession.class).findLatestProcessDefinitionByName(processDefinitionName);
- }
-}
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.OpenProcessDefinition;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindProcessDefinitionByIdCmd implements Command<OpenProcessDefinition>
{
+
+ private static final long serialVersionUID = 1L;
+
+ protected String processDefinitionId;
+
+ public FindProcessDefinitionByIdCmd(String processDefinitionId) {
+ this.processDefinitionId = processDefinitionId;
+ }
+
+ public OpenProcessDefinition execute(Environment environment) throws Exception {
+ return
environment.get(PvmDbSession.class).findProcessDefinitionById(processDefinitionId);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionByIdCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionCmd.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import org.jbpm.JbpmException;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.model.OpenProcessDefinition;
-import org.jbpm.session.PvmDbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FindProcessDefinitionCmd implements Command<OpenProcessDefinition> {
-
- private static final long serialVersionUID = 1L;
-
- protected String processDefinitionName;
- protected int processDefinitionVersion;
-
- public FindProcessDefinitionCmd(String processDefinitionName, int
processDefinitionVersion) {
- if (processDefinitionName==null) {
- throw new JbpmException("processDefinitionName is null");
- }
- this.processDefinitionName = processDefinitionName;
- this.processDefinitionVersion = processDefinitionVersion;
- }
-
- public OpenProcessDefinition execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- return pvmDbSession.findProcessDefinitionByName(processDefinitionName,
processDefinitionVersion);
- }
-}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java
(from rev 3143,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionNamesCmd.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -0,0 +1,42 @@
+/*
+ * 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.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindProcessDefinitionKeysCmd implements Command<List<String>> {
+
+ private static final long serialVersionUID = 1L;
+
+ public List<String> execute(Environment environment) throws Exception {
+ return environment.get(PvmDbSession.class).findProcessDefinitionKeys();
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionKeysCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionNamesCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionNamesCmd.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionNamesCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import java.util.List;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.session.PvmDbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FindProcessDefinitionNamesCmd implements Command<List<String>>
{
-
- private static final long serialVersionUID = 1L;
-
- public List<String> execute(Environment environment) throws Exception {
- return environment.get(PvmDbSession.class).findProcessDefinitionNames();
- }
-
-}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java
(from rev 3143,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsCmd.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -0,0 +1,48 @@
+/*
+ * 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.jbpm.client.ClientProcessDefinition;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FindProcessDefinitionsByKeyCmd implements
Command<List<ClientProcessDefinition>> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String processDefinitionKey;
+
+ public FindProcessDefinitionsByKeyCmd(String processDefinitionKey) {
+ this.processDefinitionKey = processDefinitionKey;
+ }
+
+ public List<ClientProcessDefinition> execute(Environment environment) throws
Exception {
+ return
environment.get(PvmDbSession.class).findProcessDefinitionsByKey(processDefinitionKey);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsByKeyCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsCmd.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/FindProcessDefinitionsCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.cmd;
-
-import java.util.List;
-
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.session.PvmDbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FindProcessDefinitionsCmd implements
Command<List<ClientProcessDefinition>> {
-
- private static final long serialVersionUID = 1L;
-
- protected String processDefinitionName;
-
- public FindProcessDefinitionsCmd(String processDefinitionName) {
- this.processDefinitionName = processDefinitionName;
- }
-
- public List<ClientProcessDefinition> execute(Environment environment) throws
Exception {
- return
environment.get(PvmDbSession.class).findProcessDefinitionsByName(processDefinitionName);
- }
-
-}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartExecutionInLatestCmd.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -38,24 +38,13 @@
private static final long serialVersionUID = 1L;
- protected String processDefinitionName;
protected String processDefinitionKey;
protected String executionKey;
- public StartExecutionInLatestCmd(String processDefinitionName, String
processDefinitionKey, Map<String, Object> variables, String executionKey) {
- if ( (processDefinitionName==null)
- && (processDefinitionKey==null)
- ) {
- throw new JbpmException("processDefinitionName and processDefinitionKey are
both null");
+ public StartExecutionInLatestCmd(String processDefinitionKey, Map<String, Object>
variables, String executionKey) {
+ if (processDefinitionKey==null) {
+ throw new JbpmException("processDefinitionKey is null");
}
-
- if ( (processDefinitionName!=null)
- && (processDefinitionKey!=null)
- ) {
- throw new JbpmException("processDefinitionName and processDefinitionKey are
both not-null. only one should be not null.");
- }
-
- this.processDefinitionName = processDefinitionName;
this.processDefinitionKey = processDefinitionKey;
this.variables = variables;
this.executionKey = executionKey;
@@ -66,14 +55,10 @@
ClientProcessDefinition processDefinition = null;
- if (processDefinitionName!=null) {
- processDefinition =
pvmDbSession.findLatestProcessDefinitionByName(processDefinitionName);
- } else {
- processDefinition =
pvmDbSession.findLatestProcessDefinitionByKey(processDefinitionKey);
- }
+ processDefinition =
pvmDbSession.findLatestProcessDefinitionByKey(processDefinitionKey);
if (processDefinition==null) {
- throw new JbpmException("no process definition with
"+(processDefinitionName!=null ? "name '"+processDefinitionName :
"key '"+processDefinitionKey)+"'");
+ throw new JbpmException("no process definition with key
'"+processDefinitionKey+"'");
}
ClientProcessInstance processInstance =
processDefinition.createProcessInstance(executionKey);
@@ -84,12 +69,6 @@
return processInstance;
}
- public String getProcessDefinitionName() {
- return processDefinitionName;
- }
- public void setProcessDefinitionName(String processName) {
- this.processDefinitionName = processName;
- }
public String getExecutionKey() {
return executionKey;
}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java
(from rev 3159,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessVersionDeployer.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessDeployer.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -0,0 +1,157 @@
+/*
+ * 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.deploy;
+
+import java.util.List;
+
+import org.jbpm.ProcessDefinition;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+import org.jbpm.pvm.internal.wire.binding.CheckProcessBinding;
+import org.jbpm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CheckProcessDeployer implements Deployer {
+
+ private static final Log log = Log.getLog(CheckProcessDeployer.class.getName());
+
+ protected boolean assignVersion = true;
+ protected boolean assignKey = true;
+
+ public void deploy(DeploymentImpl deployment) {
+ Environment environment = Environment.getCurrent();
+ if (environment==null) {
+ deployment.addProblem("environment is required by deployer
"+CheckProcessBinding.TAG);
+ return;
+ }
+
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ if (pvmDbSession==null) {
+ deployment.addProblem(PvmDbSession.class.getName()+" is required in the
environment by deployer "+CheckProcessBinding.TAG);
+ return;
+ }
+
+ for (String processSourceName : deployment.getObjectNames()) {
+ Object object = deployment.getObject(processSourceName);
+ if (object instanceof ProcessDefinition) {
+ checkProcessDefinition(processSourceName, (ProcessDefinitionImpl)object,
deployment, pvmDbSession);
+ }
+ }
+ }
+
+ public void checkProcessDefinition(String processSourceName, ProcessDefinitionImpl
processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+ if ( (processDefinition.getName()==null)
+ || ("".equals(processDefinition.getName()))
+ ) {
+ // A problem was already added by the JpdlParser
+ return;
+ }
+
+ checkKey(processSourceName, processDefinition, deployment, pvmDbSession);
+ checkVersion(processSourceName, processDefinition, deployment, pvmDbSession);
+ checkId(processSourceName, processDefinition, deployment, pvmDbSession);
+
+ String key = processDefinition.getKey();
+
+ }
+
+ protected void checkKey(String processSourceName, ProcessDefinitionImpl
processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+ String name = processDefinition.getName();
+ String key = processDefinition.getKey();
+ if ( (key==null)
+ && assignKey
+ ) {
+ // replace any non-word character with an underscore
+ key = name.replaceAll("\\W", "_");
+
+ processDefinition.setKey(key);
+ }
+
+ String existingKey = pvmDbSession.findProcessDefinitionKeyByName(name);
+ if ( (existingKey!=null)
+ && (!existingKey.equals(key))
+ ) {
+ deployment.addProblem("invalid key '"+key+"' in process
"+processSourceName+". Existing process has name '"+name+"'
and key '"+existingKey+"'");
+ }
+
+ String existingName = pvmDbSession.findProcessDefinitionNameByKey(key);
+ if ( (existingName!=null)
+ && (!existingName.equals(name))
+ ) {
+ deployment.addProblem("invalid name '"+name+"' in process
"+processSourceName+". Existing process has name
'"+existingName+"' and key '"+key+"'");
+ }
+ }
+
+ protected void checkVersion(String processSourceName, ProcessDefinitionImpl
processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+ int version = processDefinition.getVersion();
+ String key = processDefinition.getKey();
+ if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
+ && ! assignVersion
+ ) {
+ deployment.addProblem("no version specified in process definition
"+key);
+ }
+
+ if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
+ && assignVersion
+ ) {
+ ClientProcessDefinition latestDeployedVersion =
pvmDbSession.findLatestProcessDefinitionByKey(key);
+ if (latestDeployedVersion!=null) {
+ version = latestDeployedVersion.getVersion() + 1;
+ } else {
+ version = 1;
+ }
+ log.debug("assigning version "+version+" to process definition
"+key);
+ processDefinition.setVersion(version);
+
+ }
+ }
+
+ protected void checkId(String processSourceName, ProcessDefinitionImpl
processDefinition, DeploymentImpl deployment, PvmDbSession pvmDbSession) {
+ String id = processDefinition.getId();
+ if (id==null) {
+ id = processDefinition.getKey()+":"+processDefinition.getVersion();
+ log.trace("created id '"+id+"' for
"+processDefinition);
+ processDefinition.setId(id);
+ }
+
+ if (pvmDbSession.findProcessDefinitionById(id) != null) {
+ deployment.addProblem("process '" + id + "' already
exists");
+ }
+ }
+
+ public void setAssignVersion(boolean assignVersion) {
+ this.assignVersion = assignVersion;
+ }
+
+ public void setAssignKey(boolean assignKey) {
+ this.assignKey = assignKey;
+ }
+
+ public String toString() {
+ return "check-process";
+ }
+}
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessIdDeployer.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessIdDeployer.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessIdDeployer.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.deploy;
-
-import org.jbpm.ProcessDefinition;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.svc.DeploymentImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class CheckProcessIdDeployer implements Deployer {
-
- private static final Log log = Log.getLog(CheckProcessIdDeployer.class.getName());
-
- public void deploy(DeploymentImpl deployment) {
- for (String objectName : deployment.getObjectNames()) {
- Object object = deployment.getObject(objectName);
- if (object instanceof ProcessDefinition) {
- createId((ProcessDefinitionImpl)object, deployment);
- }
- }
- }
-
- private void createId(ProcessDefinitionImpl processDefinition, DeploymentImpl
deployment) {
- if (processDefinition.getKey()==null) {
- String key = processDefinition.getKey();
- if (key==null) {
- key = processDefinition.getName();
- }
-
- if ("".equals(key)) {
- deployment.addProblem("empty string is not a valid key");
- }
-
- // replace any non-word character with an underscore
- key = key.replaceAll("\\W", "_");
-
- processDefinition.setKey(key);
- }
-
- if (processDefinition.getId()==null) {
- String id =
processDefinition.getKey()+":"+processDefinition.getVersion();
-
- log.trace("created id '"+id+"' for
"+processDefinition);
- processDefinition.setId(id);
- }
- }
-
- public String toString() {
- return "check-process-id";
- }
-}
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessVersionDeployer.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessVersionDeployer.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/deploy/CheckProcessVersionDeployer.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,101 +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.deploy;
-
-import org.jbpm.ProcessDefinition;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.svc.DeploymentImpl;
-import org.jbpm.session.PvmDbSession;
-
-/**
- * @author Tom Baeyens
- */
-public class CheckProcessVersionDeployer implements Deployer {
-
- private static final Log log =
Log.getLog(CheckProcessVersionDeployer.class.getName());
-
- protected boolean assign = true;
-
- public void deploy(DeploymentImpl deployment) {
- for (String objectName : deployment.getObjectNames()) {
- Object object = deployment.getObject(objectName);
- if (object instanceof ProcessDefinition) {
- checkProcessDefinition((ProcessDefinitionImpl)object, deployment);
- }
- }
- }
-
- public void checkProcessDefinition(ProcessDefinitionImpl processDefinition,
DeploymentImpl deployment) {
- String name = processDefinition.getName();
- if (name == null) {
- deployment.addProblem("process must have a name to deploy it");
- }
-
- int version = processDefinition.getVersion();
- if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
- && ! assign
- ) {
- deployment.addProblem("no version specified in process definition
"+name);
- }
-
- Environment environment = Environment.getCurrent();
- if (environment==null) {
- deployment.addProblem("environment is required by deployer
check-version");
- return;
- }
-
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- if (pvmDbSession==null) {
- deployment.addProblem(PvmDbSession.class.getName()+" is required in the
environment by "+getClass().getName());
- return;
- }
-
- if ( (version==ProcessDefinitionImpl.UNASSIGNED_VERSION)
- && assign
- ) {
- ClientProcessDefinition latestDeployedVersion =
pvmDbSession.findLatestProcessDefinitionByName(name);
- if (latestDeployedVersion!=null) {
- version = latestDeployedVersion.getVersion() + 1;
- } else {
- version = 1;
- }
- log.debug("assigning version "+version+" to process definition
"+name);
- processDefinition.setVersion(version);
-
- } else {
- if (pvmDbSession.findProcessDefinitionByName(name, version) != null) {
- deployment.addProblem("process '" + name + "' version
" + version + " already exists");
- }
- }
- }
-
- public void setAssign(boolean assign) {
- this.assign = assign;
- }
-
- public String toString() {
- return "check-process-version";
- }
-}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -45,11 +45,73 @@
public HibernatePvmDbSession() {
}
- public List<String> findProcessDefinitionNames() {
+ // process definition queries ///////////////////////////////////////////////
+
+ public List<String> findProcessDefinitionKeys() {
// query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
- return session.getNamedQuery("findProcessDefinitionNames").list();
+ return session.getNamedQuery("findProcessDefinitionKeys").list();
}
+ public ClientProcessDefinition findLatestProcessDefinitionByKey(String
processDefinitionKey) {
+ // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
+ Query query = session.getNamedQuery("findProcessDefinitionsByKey");
+ query.setString("key", processDefinitionKey);
+ query.setMaxResults(1);
+ ClientProcessDefinition processDefinition = (ClientProcessDefinition)
query.uniqueResult();
+ return processDefinition;
+ }
+
+ public List<ClientProcessDefinition> findProcessDefinitionsByKey(String
processDefinitionKey) {
+ // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
+ Query query = session.getNamedQuery("findProcessDefinitionsByKey");
+ query.setString("key", processDefinitionKey);
+ return query.list();
+ }
+
+ public ClientProcessDefinition findProcessDefinitionById(String processDefinitionId) {
+ // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
+ Query query = session.getNamedQuery("findProcessDefinitionById");
+ query.setString("id", processDefinitionId);
+ query.setMaxResults(1);
+ ClientProcessDefinition processDefinition = (ClientProcessDefinition)
query.uniqueResult();
+ return processDefinition;
+ }
+
+ public String findProcessDefinitionKeyByName(String processDefinitionName) {
+ // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
+ Query query = session.getNamedQuery("findProcessDefinitionKeysByName");
+ query.setString("name", processDefinitionName);
+ query.setMaxResults(1);
+ return (String) query.uniqueResult();
+ }
+
+ public String findProcessDefinitionNameByKey(String processDefinitionKey) {
+ // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
+ Query query = session.getNamedQuery("findProcessDefinitionNamesByKey");
+ query.setString("key", processDefinitionKey);
+ query.setMaxResults(1);
+ return (String) query.uniqueResult();
+ }
+
+ public void deleteProcessDefinition(String processDefinitionId, boolean
deleteProcessInstances) {
+ List<String> processInstanceIds = findProcessInstanceIds(processDefinitionId);
+
+ if (deleteProcessInstances) {
+ for (String processInstanceId : processInstanceIds) {
+ deleteProcessInstance(processInstanceId);
+ }
+ } else {
+ if (processInstanceIds.size()>0) {
+ throw new JbpmException("still "+processInstanceIds.size()+"
process instances for process definition "+processDefinitionId);
+ }
+ }
+
+ ProcessDefinition processDefinition =
findProcessDefinitionById(processDefinitionId);
+ session.delete(processDefinition);
+ }
+
+ // process execution queries ////////////////////////////////////////////////
+
public List<ClientProcessDefinition> findProcessDefinitionsByName(String
processDefinitionName) {
// query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
Query query = session.getNamedQuery("findProcessDefinitionsByName");
@@ -75,24 +137,6 @@
return processDefinition;
}
- public ClientProcessDefinition findLatestProcessDefinitionByKey(String
processDefinitionKey) {
- // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
- Query query = session.getNamedQuery("findProcessDefinitionsByKey");
- query.setString("key", processDefinitionKey);
- query.setMaxResults(1);
- ClientProcessDefinition processDefinition = (ClientProcessDefinition)
query.uniqueResult();
- return processDefinition;
- }
-
- public ClientProcessDefinition findProcessDefinitionById(String processDefinitionId) {
- // query definition can be found at the bottom of resource
jbpm.pvm.definition.hbm.xml
- Query query = session.getNamedQuery("findProcessDefinitionsById");
- query.setString("id", processDefinitionId);
- query.setMaxResults(1);
- ClientProcessDefinition processDefinition = (ClientProcessDefinition)
query.uniqueResult();
- return processDefinition;
- }
-
public ClientExecution findExecutionById(String executionId) {
// query definition can be found at the bottom of resource
jbpm.pvm.execution.hbm.xml
Query query = session.getNamedQuery("findExecutionById");
@@ -146,21 +190,4 @@
log.debug("deleting process instance "+processInstanceId);
session.delete(processInstance);
}
-
- public void deleteProcessDefinition(String processDefinitionId, boolean
deleteProcessInstances) {
- List<String> processInstanceIds = findProcessInstanceIds(processDefinitionId);
-
- if (deleteProcessInstances) {
- for (String processInstanceId : processInstanceIds) {
- deleteProcessInstance(processInstanceId);
- }
- } else {
- if (processInstanceIds.size()>0) {
- throw new JbpmException("still "+processInstanceIds.size()+"
process instances for process definition "+processDefinitionId);
- }
- }
-
- ProcessDefinition processDefinition =
findProcessDefinitionById(processDefinitionId);
- session.delete(processDefinition);
- }
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -62,37 +62,20 @@
}
- public Execution startExecutionByName(String processDefinitionName) {
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionName,
null, null, null));
- }
-
- public Execution startExecutionByName(String processDefinitionName, Map<String,
Object> variables){
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionName,
null, variables, null));
- }
-
- public Execution startExecutionByName(String processDefinitionName, String
executionKey) {
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionName,
null, null, executionKey));
- }
-
- public Execution startExecutionByName(String processDefinitionName, Map<String,
Object> variables, String executionKey){
- return commandService.execute(new StartExecutionInLatestCmd(processDefinitionName,
null, variables, executionKey));
- }
-
-
public Execution startExecutionByKey(String processDefinitionKey) {
- return commandService.execute(new StartExecutionInLatestCmd(null,
processDefinitionKey, null, null));
+ return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey,
null, null));
}
public Execution startExecutionByKey(String processDefinitionKey, Map<String,
Object> variables){
- return commandService.execute(new StartExecutionInLatestCmd(null,
processDefinitionKey, variables, null));
+ return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey,
variables, null));
}
public Execution startExecutionByKey(String processDefinitionKey, String executionKey)
{
- return commandService.execute(new StartExecutionInLatestCmd(null,
processDefinitionKey, null, executionKey));
+ return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey,
null, executionKey));
}
public Execution startExecutionByKey(String processDefinitionKey, Map<String,
Object> variables, String executionKey){
- return commandService.execute(new StartExecutionInLatestCmd(null,
processDefinitionKey, variables, executionKey));
+ return commandService.execute(new StartExecutionInLatestCmd(processDefinitionKey,
variables, executionKey));
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -31,10 +31,9 @@
import org.jbpm.pvm.internal.cmd.DeleteProcessDefinitionCmd;
import org.jbpm.pvm.internal.cmd.DeployCmd;
import org.jbpm.pvm.internal.cmd.FindLatestProcessDefinitionByKeyCmd;
-import org.jbpm.pvm.internal.cmd.FindLatestProcessDefinitionByNameCmd;
-import org.jbpm.pvm.internal.cmd.FindProcessDefinitionCmd;
-import org.jbpm.pvm.internal.cmd.FindProcessDefinitionNamesCmd;
-import org.jbpm.pvm.internal.cmd.FindProcessDefinitionsCmd;
+import org.jbpm.pvm.internal.cmd.FindProcessDefinitionByIdCmd;
+import org.jbpm.pvm.internal.cmd.FindProcessDefinitionKeysCmd;
+import org.jbpm.pvm.internal.cmd.FindProcessDefinitionsByKeyCmd;
/** {@link ProcessService} implementation that delegates execution of the
* methods to a {@link CommandService}.
@@ -45,39 +44,26 @@
protected CommandService commandService;
- public List<ProcessDefinition> deploy(OpenProcessDefinition processDefinition) {
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- return commandService.execute(new DeployCmd(deploymentImpl));
- }
-
public Deployment createDeployment() {
return new DeploymentImpl(this);
}
- public List<ProcessDefinition> deploy(Deployment deployment) {
- return commandService.execute(new DeployCmd((DeploymentImpl)deployment));
+ public List<String> findProcessDefinitionKeys() {
+ return commandService.execute(new FindProcessDefinitionKeysCmd());
}
- public ProcessDefinition findLatestProcessDefinitionByName(String
processDefinitionName) {
- return commandService.execute(new
FindLatestProcessDefinitionByNameCmd(processDefinitionName));
- }
-
public ProcessDefinition findLatestProcessDefinitionByKey(String processDefinitionKey)
{
return commandService.execute(new
FindLatestProcessDefinitionByKeyCmd(processDefinitionKey));
}
- public ProcessDefinition findProcessDefinition(String processDefinitionName, int
version) {
- return commandService.execute(new FindProcessDefinitionCmd(processDefinitionName,
version));
+ public List<ProcessDefinition> findProcessDefinitionsByKey(String
processDefinitionName) {
+ return (List)commandService.execute(new
FindProcessDefinitionsByKeyCmd(processDefinitionName));
}
- public List<String> findProcessDefinitionNames() {
- return commandService.execute(new FindProcessDefinitionNamesCmd());
+ public ProcessDefinition findProcessDefinitionById(String processDefinitionId) {
+ return commandService.execute(new
FindProcessDefinitionByIdCmd(processDefinitionId));
}
- public List<ProcessDefinition> findProcessDefinitions(String
processDefinitionName) {
- return (List)commandService.execute(new
FindProcessDefinitionsCmd(processDefinitionName));
- }
-
public void deleteProcessDefinition(String processDefinitionId) {
commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId));
}
@@ -86,6 +72,18 @@
commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId, true));
}
+
+
+ public List<ProcessDefinition> deploy(Deployment deployment) {
+ return commandService.execute(new DeployCmd((DeploymentImpl)deployment));
+ }
+
+ public List<ProcessDefinition> deploy(OpenProcessDefinition processDefinition) {
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ return commandService.execute(new DeployCmd(deploymentImpl));
+ }
+
+
public CommandService getCommandService() {
return commandService;
}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java
(from rev 3159,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessVersionBinding.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessBinding.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -0,0 +1,61 @@
+/*
+ * 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.wire.binding;
+
+import org.jbpm.pvm.internal.deploy.CheckProcessDeployer;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/** parses a descriptor creating a {@link CheckProcessDeployer version verification
deployer}.
+ *
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class CheckProcessBinding extends WireDescriptorBinding {
+
+ public static final String TAG = "check-process";
+
+ public CheckProcessBinding() {
+ super(TAG);
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ CheckProcessDeployer checkProcessDeployer = new CheckProcessDeployer();
+
+ Boolean assignVersion = XmlUtil.attributeBoolean(element, "assign-version",
false, parse, null);
+ if (assignVersion!=null) {
+ checkProcessDeployer.setAssignVersion(assignVersion);
+ }
+
+ Boolean assignKey = XmlUtil.attributeBoolean(element, "assign-key", false,
parse, null);
+ if (assignKey!=null) {
+ checkProcessDeployer.setAssignKey(assignKey);
+ }
+
+ return new ProvidedObjectDescriptor(checkProcessDeployer);
+ }
+}
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessIdBinding.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessIdBinding.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessIdBinding.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,45 +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.wire.binding;
-
-import org.jbpm.pvm.internal.deploy.CheckProcessIdDeployer;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class CheckProcessIdBinding extends WireDescriptorBinding {
-
- public CheckProcessIdBinding() {
- super("check-process-id");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- CheckProcessIdDeployer checkProcessIdDeployer = new CheckProcessIdDeployer();
- return new ProvidedObjectDescriptor(checkProcessIdDeployer);
- }
-
-}
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessVersionBinding.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessVersionBinding.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/CheckProcessVersionBinding.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,58 +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.wire.binding;
-
-import org.jbpm.pvm.internal.deploy.CheckProcessVersionDeployer;
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.descriptor.FalseDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.TrueDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/** parses a descriptor creating a {@link CheckProcessVersionDeployer version
verification deployer}.
- *
- * See schema docs for more details.
- *
- * @author Tom Baeyens
- */
-public class CheckProcessVersionBinding extends WireDescriptorBinding {
-
- public CheckProcessVersionBinding() {
- super("check-process-version");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- CheckProcessVersionDeployer checkProcessVersionDeployer = new
CheckProcessVersionDeployer();
-
- Boolean assign = XmlUtil.attributeBoolean(element, "assign", false, parse,
null);
- if (assign!=null) {
- checkProcessVersionDeployer.setAssign(assign);
- }
-
- return new ProvidedObjectDescriptor(checkProcessVersionDeployer);
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.definition.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.definition.hbm.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.definition.hbm.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -383,49 +383,45 @@
<!-- ### QUERIES ######################################################## -->
- <query name="findProcessDefinitionNames">
+ <query name="findProcessDefinitionKeys">
<![CDATA[
- select distinct process.name
+ select distinct process.key
from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
- order by process.name asc
+ order by process.key asc
]]>
</query>
- <query name="findProcessDefinitionsByName">
+ <query name="findProcessDefinitionsByKey">
<![CDATA[
select process
from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
- where process.name = :name
+ where process.key = :key
order by process.version desc
]]>
</query>
- <query name="findProcessDefinitionsByKey">
+ <query name="findProcessDefinitionById">
<![CDATA[
select process
from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
- where process.key = :key
- order by process.version desc
+ where process.id = :id
]]>
</query>
-
- <query name="findProcessDefinitionByNameAndVersion">
+
+ <query name="findProcessDefinitionKeysByName">
<![CDATA[
- select process
+ select process.key
from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
where process.name = :name
- and process.version = :version
]]>
</query>
- <query name="findProcessDefinitionsById">
+ <query name="findProcessDefinitionNamesByKey">
<![CDATA[
- select process
+ select process.name
from org.jbpm.pvm.internal.model.ProcessDefinitionImpl as process
- where process.id = :id
+ where process.key = :key
]]>
</query>
-
-
-
+
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -59,8 +59,7 @@
<!-- deployers -->
<binding class="org.jbpm.pvm.internal.wire.binding.DeployerManagerBinding"
/>
<binding class="org.jbpm.pvm.internal.wire.binding.AssignFileTypesBinding"
/>
- <binding
class="org.jbpm.pvm.internal.wire.binding.CheckProcessVersionBinding" />
- <binding class="org.jbpm.pvm.internal.wire.binding.CheckProcessIdBinding"
/>
+ <binding class="org.jbpm.pvm.internal.wire.binding.CheckProcessBinding"
/>
<binding class="org.jbpm.pvm.internal.wire.binding.CheckProblemsBinding"
/>
<binding class="org.jbpm.pvm.internal.wire.binding.SaveBinding" />
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/basicfeatures/AutomaticDecisionDbTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/basicfeatures/AutomaticDecisionDbTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/basicfeatures/AutomaticDecisionDbTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -78,7 +78,7 @@
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("creditRate", 7);
- Execution execution =
executionService.startExecutionByName("creditProcess", variables);
+ Execution execution = executionService.startExecutionByKey("creditProcess",
variables);
assertEquals("priority delivery", execution.getNodeName());
}
@@ -90,7 +90,7 @@
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("creditRate", 2);
- Execution execution =
executionService.startExecutionByName("creditProcess", variables);
+ Execution execution = executionService.startExecutionByKey("creditProcess",
variables);
assertEquals("bulk delivery", execution.getNodeName());
@@ -103,7 +103,7 @@
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("creditRate", -7);
- Execution execution =
executionService.startExecutionByName("creditProcess", variables);
+ Execution execution = executionService.startExecutionByKey("creditProcess",
variables);
assertEquals("payment upfront", execution.getNodeName());
}
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/continuation/ContinuationTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -105,9 +105,14 @@
public Object execute(Environment environment) throws Exception
{
log.debug("building process 'continuations'");
- OpenProcessDefinition processDefinition =
ProcessFactory.build("continuations").node("start").initial().behaviour(
-
AutomaticActivity.class).asyncExecute().transition().to("a").node("a").behaviour(AutomaticActivity.class).asyncExecute()
-
.transition().to("b").node("b").behaviour(AutomaticActivity.class).asyncExecute().transition().to("c").node("c").behaviour(
+ OpenProcessDefinition processDefinition =
ProcessFactory.build("continuations")
+ .node("start").initial().behaviour(AutomaticActivity.class)
+ .asyncExecute()
+ .transition().to("a")
+ .node("a").behaviour(AutomaticActivity.class)
+ .asyncExecute()
+ .transition().to("b")
+
.node("b").behaviour(AutomaticActivity.class).asyncExecute().transition().to("c").node("c").behaviour(
AutomaticActivity.class).asyncExecute().transition().to("end").node("end").behaviour(WaitState.class).done();
log.debug("saving process 'continuations'");
@@ -126,7 +131,7 @@
public Object execute(Environment environment) throws Exception
{
PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- ClientProcessDefinition processDefinition =
pvmDbSession.findLatestProcessDefinitionByName("continuations");
+ ClientProcessDefinition processDefinition =
pvmDbSession.findLatestProcessDefinitionByKey("continuations");
ClientExecution execution = processDefinition.startProcessInstance();
pvmDbSession.save(execution);
return null;
Deleted:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ExecutionServiceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,325 +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.api.db.svc;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.Test;
-
-import org.jbpm.Execution;
-import org.jbpm.ExecutionService;
-import org.jbpm.ProcessDefinition;
-import org.jbpm.ProcessService;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.pvm.internal.svc.DeploymentImpl;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
-import org.jbpm.test.OldDbTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class ExecutionServiceTest extends OldDbTestCase
-{
-
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ExecutionServiceTest.class);
- }
-
- public void testStartExecutionById()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // deploy process with key 'NCLFU' and version 1
- // then we know that the key for this process will be 'NCLFU:1'
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion")
- .version(1)
- .key("NCLFU")
- .node("initial").initial()
- .behaviour(WaitState.class)
- .done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- // start an execution for the process with the given id
- Execution execution = executionService.startExecutionById("NCLFU:1");
- assertNotNull(execution);
-
- // checking the state
- assertEquals("initial", execution.getNodeName());
-
- // checking the generated id
- assertNull(execution.getName());
- assertNull(execution.getKey());
- // if there is no user defined name or key specified in the execution,
- // the default id generator will create a unique id like this:
processDefinitionId/execution.dbid
- assertEquals("NCLFU:1/", execution.getId().substring(0, 8));
- // the last part of the execution key should be the dbid.
- Long.parseLong(execution.getId().substring(8));
- }
-
- public void testStartExecutionByIdWithGivenExecutionKey()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // deploy the same process with a given key and version
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(1).key("NCLFU").node("initial").initial()
- .behaviour(WaitState.class).done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- Execution execution = executionService.startExecutionById("NCLFU:1",
"TheFirstTime");
- assertNotNull(execution);
-
- // checking the state
- assertEquals("initial", execution.getNodeName());
-
- // checking the generated id
- assertNull(execution.getName());
- assertEquals("TheFirstTime", execution.getKey());
- // if there is a user provided key in the execution, the default
- // id generator will take that to create the id
- assertEquals("NCLFU:1/TheFirstTime", execution.getId());
- }
-
- public void testStartExecutionByIdWithVariables()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(1).key("NCLFU").node("initial").initial()
- .behaviour(WaitState.class).done();
-
- processService.deploy(new DeploymentImpl(processDefinition));
-
- // create the map with variables
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- // provide the variables in the start execution method
- Execution execution = executionService.startExecutionById("NCLFU:1",
variables);
- String executionId = execution.getId();
-
- assertEquals(new Integer(1), executionService.getVariable(executionId,
"a"));
- assertEquals("text", executionService.getVariable(executionId,
"b"));
- }
-
- public void testStartExecutionInLatest()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- // start a nuclear fusion in the latest version of
- // the process definition with name 'nuclear fusion'
- Execution execution = executionService.startExecutionByName("nuclear
fusion");
- assertNotNull(execution);
-
- // in the generated id, we can see if the right process definition version was taken
- assertTrue("the execution id shows that the execution is not started in the
latest version of the process: " + execution.getId(),
- execution.getId().startsWith("NFU:3/"));
- }
-
- public void testStartExecutionInLatestByNameWithVariables()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- // create variables that are fed into the process before it starts executing
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- // feed the variables in
- Execution execution = executionService.startExecutionByName("nuclear
fusion", variables);
- String executionId = execution.getId();
-
- // verify that the variables are actually set
- assertEquals(new Integer(1), executionService.getVariable(executionId,
"a"));
- assertEquals("text", executionService.getVariable(executionId,
"b"));
-
- // in the generated id, we can see if the right process definition version was taken
- assertTrue("the execution id shows that the execution is not started in the
latest version of the process: " + execution.getId(),
- execution.getId().startsWith("NFU:3/"));
- }
-
- public void testStartExecutionByNameWithKey()
- {
- // deploy following processes
- // 'nuclear fusion' with id NFU:1
- // 'ultimate seduction' with id USD:1
- // 'ultimate seduction' with id USD:2
- // 'nuclear fusion' with id NFU:2
- // 'publish book' with id PBO:1
- // 'nuclear fusion' with id NFU:3
- deployMultipleVersionsOfProcesses();
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- Execution execution = executionService.startExecutionByName("nuclear
fusion", "TheFirstTime");
- assertNotNull(execution);
- assertEquals("TheFirstTime", execution.getKey());
- assertEquals("NFU:3/TheFirstTime", execution.getId());
- }
-
- public void testFindExecution()
- {
- // create an arbitrary execution
- Execution execution = startExecution();
- // take the id and see if the execution service can still find it back
- execution = executionService.findExecution(execution.getId());
- assertNotNull(execution);
- }
-
- public void testSetVariable()
- {
- Execution execution = startExecution();
-
- String executionId = execution.getId();
- // set variable a to value text
- executionService.setVariable(executionId, "a", "text");
- // check if we can read that value back
- assertEquals("text", executionService.getVariable(executionId,
"a"));
-
- // overwrite the value of variable a with another text
- executionService.setVariable(executionId, "a", "another text");
- // see if we can read another text back from the variable
- assertEquals("another text", executionService.getVariable(executionId,
"a"));
- }
-
- public void testSetVariables()
- {
- Execution execution = startExecution();
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("a", new Integer(1));
- variables.put("b", "text");
-
- // set variables in bulk by providing a map
- executionService.setVariables(execution.getId(), variables);
-
- Map<String, Object> expected = new HashMap<String, Object>(variables);
-
- Set<String> variableNames = new HashSet<String>();
- variableNames.add("a");
- variableNames.add("b");
-
- // read the variables back and compare
- assertEquals(expected, executionService.getVariables(execution.getId(),
variableNames));
-
- // now set variables b and c with a map
- variables = new HashMap<String, Object>();
- variables.put("b", new Integer(99));
- variables.put("c", "another text");
-
- // this should leave a untouched, overwrite b and create c
- executionService.setVariables(execution.getId(), variables);
-
- // update the expected map
- expected.put("b", new Integer(99));
- expected.put("c", "another text");
-
- // add c to the variable names that should be collected
- variableNames.add("c");
-
- // read the variables back and compare
- assertEquals(expected, executionService.getVariables(execution.getId(),
variableNames));
- }
-
- // helper methods ///////////////////////////////////////////////////////////
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the
processes 'ultimate seduction' and
- * 'publish book'
- */
- void deployMultipleVersionsOfProcesses()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").node("initial").initial().behaviour(
- WaitState.class).done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate
seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate
seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("publish
book").key("PBO").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
- }
-
- Execution startExecution()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
-
- return executionService.startExecutionByName("nuclear fusion");
- }
-}
Deleted:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ManagementServiceTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ManagementServiceTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ManagementServiceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.api.db.svc;
-
-import junit.framework.Test;
-
-import org.jbpm.ManagementService;
-import org.jbpm.test.OldDbTestCase;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
-
-/**
- * @author Tom Baeyens
- */
-public class ManagementServiceTest extends OldDbTestCase
-{
-
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ManagementServiceTest.class);
- }
-
- public void testGetJobs()
- {
- ManagementService managementService =
getEnvironmentFactory().get(ManagementService.class);
- assertEquals(0, managementService.getTimers(0, 10).size());
- assertEquals(0, managementService.getMessages(0, 10).size());
- }
-
-}
Deleted:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ProcessServiceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,322 +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.api.db.svc;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-
-import org.jbpm.ProcessDefinition;
-import org.jbpm.ProcessService;
-import org.jbpm.JbpmException;
-import org.jbpm.pvm.internal.svc.DeploymentImpl;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.test.OldDbTestCase;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessServiceTest extends OldDbTestCase
-{
-
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(ProcessServiceTest.class);
- }
-
- public void testSimplestDeployment()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // create the simplest possible process
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
-
- // deploy it
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- // fetch it back from the process service
- List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitions("nuclear fusion");
- assertNotNull(processDefinitions);
-
- // verify there is only one
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- processDefinition = processDefinitions.get(0);
-
- // verify that it is the right one
- assertEquals("nuclear fusion", processDefinition.getName());
- }
-
- public void testAutomaticVersioning()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // create first process and only give it a name
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
-
- // deploy it
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- // look it up again
- List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitions("nuclear fusion");
- assertNotNull(processDefinitions);
-
- // verify that there is only one
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- processDefinition = processDefinitions.get(0);
- // and check that automatically assigned version starts with 1
- assertEquals(1, processDefinition.getVersion());
-
- // create a second process with the same name
- processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class).done();
-
- // deploy the second process
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- // verify that there now are 2 process definitions with that name
- processDefinitions = processService.findProcessDefinitions("nuclear
fusion");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 2, processDefinitions.size());
- // the process definitions are ordered by version in descending order
- // so the first one
- processDefinition = processDefinitions.get(0);
- // is the one that is last deployed
- // and hence it should have the version number 2
- assertEquals(2, processDefinition.getVersion());
- }
-
- public void testUserProvidedVersion()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // create a process with a user specified version
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(35).node("initial").initial().behaviour(
- WaitState.class).done();
-
- // deploy it
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- // load it
- List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitions("nuclear fusion");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- processDefinition = processDefinitions.get(0);
-
- // verify that the user specified version was used
- // (and not overwritten by an automatically assigned versioning)
- assertEquals(35, processDefinition.getVersion());
- }
-
- public void testIdGenerationFromName()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // specify only a name, no key or version in the process
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitions("nuclear fusion");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- processDefinition = processDefinitions.get(0);
- assertEquals("nuclear fusion", processDefinition.getName());
-
- // now check that the generated id. the id generator always replaces all non-word
- // chars [a-zA-Z_0-9] with underscores
- assertEquals("nuclear_fusion:1", processDefinition.getId());
- assertNull(processDefinition.getKey());
- }
-
- public void testIdGenerationFromKey()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // now we specify a name and a key
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").key("NCF").node("initial").initial().behaviour(
- WaitState.class).done();
-
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitions("nuclear fusion");
- assertNotNull(processDefinitions);
- assertEquals(processDefinitions.toString(), 1, processDefinitions.size());
- processDefinition = processDefinitions.get(0);
- assertEquals("nuclear fusion", processDefinition.getName());
-
- // and we check that the id is based on the key (and not on the name)
- assertEquals("NCF:1", processDefinition.getId());
- assertEquals("NCF", processDefinition.getKey());
- }
-
- public void testDuplicateDeployment()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // we create a simple process definition
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(1).node("initial").initial().behaviour(
- WaitState.class).done();
-
- // deploy it
- processService.deploy(new DeploymentImpl(processDefinition));
-
- // then we create a process definition with the same name and version
- processDefinition = ProcessFactory.build("nuclear
fusion").version(1).node("initial").initial().behaviour(WaitState.class).done();
-
- try
- {
- // and then we verify that the deployment fails
- processService.deploy(new DeploymentImpl(processDefinition));
- fail("expected exception");
- }
- catch (JbpmException e)
- {
- assertTextPresent(e.getMessage(), "process 'nuclear fusion' version 1
already exists");
- }
- }
-
- public void testFindProcessDefinitionByNameAndVersion()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- // create a process with a user specified version
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(35).node("initial").initial().behaviour(
- WaitState.class).done();
-
- // deploy it
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- // load it with by name and version
- processDefinition = processService.findProcessDefinition("nuclear fusion",
35);
-
- // verify that the right process definition was returned
- assertEquals("nuclear fusion", processDefinition.getName());
- assertEquals(35, processDefinition.getVersion());
- }
-
- public void testFindProcessDefinitionNames()
- {
- deployMultipleVersionsOfProcesses();
-
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- List<String> processNames = processService.findProcessDefinitionNames();
-
- List<String> expected = new ArrayList<String>();
- expected.add("nuclear fusion");
- expected.add("publish book");
- expected.add("ultimate seduction");
-
- assertEquals(expected, processNames);
- }
-
- public void testFindProcessDefinitions()
- {
- deployMultipleVersionsOfProcesses();
-
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- List<ProcessDefinition> processDefinitions =
processService.findProcessDefinitions("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();
-
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition retrieved =
processService.findLatestProcessDefinitionByName("nuclear fusion");
- assertNotNull(retrieved);
-
- assertEquals("nuclear fusion", retrieved.getName());
- assertEquals(3, retrieved.getVersion());
- }
-
- public void testLatestProcessDefinition()
- {
- deployMultipleVersionsOfProcesses();
-
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition retrieved =
processService.findLatestProcessDefinitionByName("nuclear fusion");
- assertNotNull(retrieved);
-
- assertEquals("nuclear fusion", retrieved.getName());
- assertEquals(3, retrieved.getVersion());
- }
-
- /**
- * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the
processes 'ultimate seduction' and
- * 'publish book'
- */
- void deployMultipleVersionsOfProcesses()
- {
- ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
-
- ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class)
- .done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate
seduction").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("ultimate
seduction").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("publish
book").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
-
- processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class).done();
- deploymentImpl = new DeploymentImpl(processDefinition);
- processService.deploy(deploymentImpl);
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/WaitState.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -1,37 +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.api.db.svc;
-
-import java.util.Map;
-
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-
-public class WaitState implements ExternalActivity {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
- execution.waitForSignal();
- }
- public void signal(ActivityExecution execution, String signalName, Map<String,
Object> parameters) {
- throw new UnsupportedOperationException();
- }
-}
\ No newline at end of file
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/timer/TimerIntegrationTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/timer/TimerIntegrationTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/timer/TimerIntegrationTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -74,7 +74,7 @@
DeploymentImpl deploymentImpl = new DeploymentImpl(definition);
processService.deploy(deploymentImpl);
- Execution processInstance =
getExecutionService().startExecutionByName(definition.getName());
+ Execution processInstance =
getExecutionService().startExecutionByKey(definition.getKey());
return (ExecutionImpl) processInstance;
}
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/db/langext/LanguageExtensionsDbTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -74,7 +74,7 @@
newTransaction();
PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- Execution execution =
pvmDbSession.findLatestProcessDefinitionByName("addresses").startProcessInstance();
+ Execution execution =
pvmDbSession.findLatestProcessDefinitionByKey("addresses").startProcessInstance();
assertTrue(execution.isEnded());
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -42,16 +42,14 @@
import org.jbpm.job.Job;
import org.jbpm.log.Log;
import org.jbpm.model.Comment;
-import org.jbpm.pvm.api.db.svc.ExecutionServiceTest;
import org.jbpm.pvm.internal.job.CommandMessage;
import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.svc.DeploymentImpl;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.session.MessageSession;
import org.jbpm.session.PvmDbSession;
-import org.jbpm.test.OldDbTestCase;
import org.jbpm.test.EnvironmentFactoryTestSetup;
+import org.jbpm.test.OldDbTestCase;
/**
* @author Tom Baeyens
Modified:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -60,7 +60,7 @@
ExecutionService executionService = ExamplesConfiguration.getExecutionService();
- Execution execution = executionService.startExecutionByName("basic",
"one");
+ Execution execution = executionService.startExecutionByKey("basic",
"one");
assertEquals("a", execution.getNodeName());
Modified: jbpm4/trunk/modules/pvm/src/test/resources/environment.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/environment.cfg.xml 2008-12-03 14:28:41 UTC
(rev 3183)
+++ jbpm4/trunk/modules/pvm/src/test/resources/environment.cfg.xml 2008-12-03 17:06:54 UTC
(rev 3184)
@@ -8,8 +8,7 @@
<assign-file-type>
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified:
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/db/svc/environment.cfg.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -8,8 +8,7 @@
<assign-file-type>
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified:
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/api/timer/environment.cfg.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -20,8 +20,7 @@
<assign-file-type>
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified:
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml
===================================================================
---
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -8,8 +8,7 @@
<assign-file-type>
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified: jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml 2008-12-03 14:28:41 UTC (rev
3183)
+++ jbpm4/trunk/modules/task/src/test/resources/jbpm.cfg.xml 2008-12-03 17:06:54 UTC (rev
3184)
@@ -8,8 +8,7 @@
<assign-file-type>
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/StateTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -75,7 +75,7 @@
"</process>"
);
- Execution execution = executionService.startExecutionByName("p",
"one");
+ Execution execution = executionService.startExecutionByKey("p",
"one");
assertEquals("ed", execution.getNodeName());
execution = executionService.signalExecution("p/one", "left");
assertEquals("b", execution.getNodeName());
@@ -106,7 +106,7 @@
"</process>"
);
- executionService.startExecutionByName("p", "one");
+ executionService.startExecutionByKey("p", "one");
try {
executionService.signalExecution("p/one", "left");
} catch (JbpmException e) {
@@ -131,7 +131,7 @@
"</process>"
);
- executionService.startExecutionByName("p", "one");
+ executionService.startExecutionByKey("p", "one");
Execution execution = executionService.signalExecution("p/one",
"up");
assertEquals("a", execution.getNodeName());
}
@@ -146,7 +146,7 @@
"</process>"
);
- executionService.startExecutionByName("p", "one");
+ executionService.startExecutionByKey("p", "one");
Execution execution = executionService.signalExecution("p/one");
assertEquals("a", execution.getNodeName());
}
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ExecutionServiceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -21,7 +21,6 @@
*/
package org.jbpm.test.svc;
-import org.jbpm.Execution;
import org.jbpm.test.DbTestCase;
@@ -29,7 +28,11 @@
* @author Tom Baeyens
*/
public class ExecutionServiceTest extends DbTestCase {
-
+
+ public void testDummy() {
+ }
+
+ /*
public void testDefaultSignalWithoutTransitions() {
deployJpdlXmlString(
"<process name='p'>" +
@@ -44,4 +47,278 @@
Execution execution = executionService.signalExecution("p/one");
assertEquals("a", execution.getNodeName());
}
+
+ public void testStartExecutionById()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ // deploy process with key 'NCLFU' and version 1
+ // then we know that the key for this process will be 'NCLFU:1'
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion")
+ .version(1)
+ .key("NCLFU")
+ .node("initial").initial()
+ .behaviour(WaitState.class)
+ .done();
+
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ // start an execution for the process with the given id
+ Execution execution = executionService.startExecutionById("NCLFU:1");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("initial", execution.getNodeName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertNull(execution.getKey());
+ // if there is no user defined name or key specified in the execution,
+ // the default id generator will create a unique id like this:
processDefinitionId/execution.dbid
+ assertEquals("NCLFU:1/", execution.getId().substring(0, 8));
+ // the last part of the execution key should be the dbid.
+ Long.parseLong(execution.getId().substring(8));
+ }
+
+ public void testStartExecutionByIdWithGivenExecutionKey()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ // deploy the same process with a given key and version
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(1).key("NCLFU").node("initial").initial()
+ .behaviour(WaitState.class).done();
+
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ Execution execution = executionService.startExecutionById("NCLFU:1",
"TheFirstTime");
+ assertNotNull(execution);
+
+ // checking the state
+ assertEquals("initial", execution.getNodeName());
+
+ // checking the generated id
+ assertNull(execution.getName());
+ assertEquals("TheFirstTime", execution.getKey());
+ // if there is a user provided key in the execution, the default
+ // id generator will take that to create the id
+ assertEquals("NCLFU:1/TheFirstTime", execution.getId());
+ }
+
+ public void testStartExecutionByIdWithVariables()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ClientProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").version(1).key("NCLFU").node("initial").initial()
+ .behaviour(WaitState.class).done();
+
+ processService.deploy(new DeploymentImpl(processDefinition));
+
+ // create the map with variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ // provide the variables in the start execution method
+ Execution execution = executionService.startExecutionById("NCLFU:1",
variables);
+ String executionId = execution.getId();
+
+ assertEquals(new Integer(1), executionService.getVariable(executionId,
"a"));
+ assertEquals("text", executionService.getVariable(executionId,
"b"));
+ }
+
+ public void testStartExecutionInLatest()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ // start a nuclear fusion in the latest version of
+ // the process definition with name 'nuclear fusion'
+ Execution execution = executionService.startExecutionByKey("NFU");
+ assertNotNull(execution);
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue("the execution id shows that the execution is not started in the
latest version of the process: " + execution.getId(),
+ execution.getId().startsWith("NFU:3/"));
+ }
+
+ public void testStartExecutionInLatestByNameWithVariables()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ // create variables that are fed into the process before it starts executing
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // feed the variables in
+ Execution execution = executionService.startExecutionByName("nuclear
fusion", variables);
+ String executionId = execution.getId();
+
+ // verify that the variables are actually set
+ assertEquals(new Integer(1), executionService.getVariable(executionId,
"a"));
+ assertEquals("text", executionService.getVariable(executionId,
"b"));
+
+ // in the generated id, we can see if the right process definition version was taken
+ assertTrue("the execution id shows that the execution is not started in the
latest version of the process: " + execution.getId(),
+ execution.getId().startsWith("NFU:3/"));
+ }
+
+ public void testStartExecutionByNameWithKey()
+ {
+ // deploy following processes
+ // 'nuclear fusion' with id NFU:1
+ // 'ultimate seduction' with id USD:1
+ // 'ultimate seduction' with id USD:2
+ // 'nuclear fusion' with id NFU:2
+ // 'publish book' with id PBO:1
+ // 'nuclear fusion' with id NFU:3
+ deployMultipleVersionsOfProcesses();
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ Execution execution = executionService.startExecutionByName("nuclear
fusion", "TheFirstTime");
+ assertNotNull(execution);
+ assertEquals("TheFirstTime", execution.getKey());
+ assertEquals("NFU:3/TheFirstTime", execution.getId());
+ }
+
+ public void testFindExecution()
+ {
+ // create an arbitrary execution
+ Execution execution = startExecution();
+ // take the id and see if the execution service can still find it back
+ execution = executionService.findExecution(execution.getId());
+ assertNotNull(execution);
+ }
+
+ public void testSetVariable()
+ {
+ Execution execution = startExecution();
+
+ String executionId = execution.getId();
+ // set variable a to value text
+ executionService.setVariable(executionId, "a", "text");
+ // check if we can read that value back
+ assertEquals("text", executionService.getVariable(executionId,
"a"));
+
+ // overwrite the value of variable a with another text
+ executionService.setVariable(executionId, "a", "another text");
+ // see if we can read another text back from the variable
+ assertEquals("another text", executionService.getVariable(executionId,
"a"));
+ }
+
+ public void testSetVariables()
+ {
+ Execution execution = startExecution();
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("a", new Integer(1));
+ variables.put("b", "text");
+
+ // set variables in bulk by providing a map
+ executionService.setVariables(execution.getId(), variables);
+
+ Map<String, Object> expected = new HashMap<String, Object>(variables);
+
+ Set<String> variableNames = new HashSet<String>();
+ variableNames.add("a");
+ variableNames.add("b");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(),
variableNames));
+
+ // now set variables b and c with a map
+ variables = new HashMap<String, Object>();
+ variables.put("b", new Integer(99));
+ variables.put("c", "another text");
+
+ // this should leave a untouched, overwrite b and create c
+ executionService.setVariables(execution.getId(), variables);
+
+ // update the expected map
+ expected.put("b", new Integer(99));
+ expected.put("c", "another text");
+
+ // add c to the variable names that should be collected
+ variableNames.add("c");
+
+ // read the variables back and compare
+ assertEquals(expected, executionService.getVariables(execution.getId(),
variableNames));
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ /**
+ * deploys 3 versions of process with name 'nuclear fusion', 2 versions of the
processes 'ultimate seduction' and
+ * 'publish book'
+ void deployMultipleVersionsOfProcesses()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").node("initial").initial().behaviour(
+ WaitState.class).done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate
seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("ultimate
seduction").key("USD").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("publish
book").key("PBO").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ processDefinition = ProcessFactory.build("nuclear
fusion").key("NFU").node("initial").initial().behaviour(WaitState.class).done();
+ deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+ }
+
+ Execution startExecution()
+ {
+ ProcessService processService = getEnvironmentFactory().get(ProcessService.class);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("nuclear
fusion").node("initial").initial().behaviour(WaitState.class)
+ .done();
+ DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
+ processService.deploy(deploymentImpl);
+
+ ExecutionService executionService =
getEnvironmentFactory().get(ExecutionService.class);
+
+ return executionService.startExecutionByName("nuclear fusion");
+ }
+
+ */
}
Copied:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
(from rev 3143,
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/db/svc/ManagementServiceTest.java)
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -0,0 +1,36 @@
+/*
+ * 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.svc;
+
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ManagementServiceTest extends DbTestCase {
+
+ public void testGetJobs() {
+ assertEquals(0, managementService.getTimers(0, 10).size());
+ assertEquals(0, managementService.getMessages(0, 10).size());
+ }
+
+}
Property changes on:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ManagementServiceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -21,7 +21,11 @@
*/
package org.jbpm.test.svc;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jbpm.Execution;
+import org.jbpm.JbpmException;
import org.jbpm.ProcessDefinition;
import org.jbpm.test.DbTestCase;
@@ -41,7 +45,7 @@
"</process>"
);
- Execution execution = executionService.startExecutionByName("minimal");
+ Execution execution = executionService.startExecutionByKey("minimal");
assertEquals("end", execution.getNodeName());
assertTrue(execution.isEnded());
@@ -56,7 +60,7 @@
"</process>"
);
- Execution execution = executionService.startExecutionByName("minimal");
+ Execution execution = executionService.startExecutionByKey("minimal");
assertTrue(execution.isEnded());
assertTrue(execution.isFinished());
@@ -116,24 +120,178 @@
"</process>"
);
- ProcessDefinition processDefinition =
processService.findLatestProcessDefinitionByName("minimal");
+ ProcessDefinition processDefinition =
processService.findLatestProcessDefinitionByKey("M");
-
assertEquals("M", processDefinition.getKey());
assertEquals("M:1", processDefinition.getId());
assertEquals(1, processDefinition.getVersion());
}
- public void testGivenVersion() {
+ public void testAutomaticVersioning()
+ {
deployJpdlXmlString(
- "<process name='minimal' version='23'>" +
+ "<process name='versionme'>" +
" <start />" +
"</process>"
);
- ProcessDefinition processDefinition =
processService.findLatestProcessDefinitionByName("minimal");
-
- assertEquals(23, processDefinition.getVersion());
- assertEquals("minimal:23", processDefinition.getId());
+ // 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 it 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());
+ }
+ }
+
+ public void testFindProcessDefinitionNames() {
+ 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 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());
+ }
+
+ /**
+ * 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>"
+ );
+ }
+
+
+
}
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-03
14:28:41 UTC (rev 3183)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/BasicVariablesTest.java 2008-12-03
17:06:54 UTC (rev 3184)
@@ -44,7 +44,7 @@
"</process>"
);
- executionService.startExecutionByName("var", "one");
+ executionService.startExecutionByKey("var", "one");
Set<String> variableNames =
executionService.getVariableNames("var/one");
assertNotNull(variableNames);
assertEquals(0, variableNames.size());
@@ -68,7 +68,7 @@
Set<String> expectedVariableNames = new
HashSet<String>(variables.keySet());
Map<String, Object> expectedVariables = new HashMap<String,
Object>(variables);
- executionService.startExecutionByName("var", variables, "one");
+ executionService.startExecutionByKey("var", variables, "one");
Set<String> variableNames =
executionService.getVariableNames("var/one");
assertNotNull(variableNames);
Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-03 14:28:41 UTC
(rev 3183)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-03 17:06:54 UTC
(rev 3184)
@@ -9,8 +9,7 @@
<file extension=".jpdl.xml" type="jpdl" />
</assign-file-type>
<parse-jpdl />
- <check-process-version />
- <check-process-id />
+ <check-process />
<check-problems />
<save />
</deployer-manager>
Modified: jbpm4/trunk/modules/userguide/.settings/attachedFile.properties
===================================================================
--- jbpm4/trunk/modules/userguide/.settings/attachedFile.properties 2008-12-03 14:28:41
UTC (rev 3183)
+++ jbpm4/trunk/modules/userguide/.settings/attachedFile.properties 2008-12-03 17:06:54
UTC (rev 3184)
@@ -1,2 +1,2 @@
## index of importer -> set(imports)
-#Wed Dec 03 08:29:43 CET 2008
+#Wed Dec 03 17:57:37 CET 2008
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml 2008-12-03
14:28:41 UTC (rev 3183)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch03-Services.xml 2008-12-03
17:06:54 UTC (rev 3184)
@@ -70,20 +70,20 @@
definition. The <literal>id</literal> will have format
<literal>{key}:{version}</literal>
</para>
- <para>Process definition properties <literal>name</literal>,
<literal>key</literal>
- and <literal>id</literal> are important for referencing the deployed
process
- definition later on.
+ <para>If <literal>key</literal> is not provided, it is generated
automatically
+ based on the name. All non alpha numeric characters in the name will be replaced
+ by underscores to generate the key.
</para>
- <para>If a <literal>key</literal> is not provided, it is generated
based on the
- name. All non alpha numeric characters in the name will be replaced by underscores.
+ <para>The same <literal>name</literal> can only be associated to
one
+ <literal>key</literal> and vice verca.
</para>
- <para>If no <literal>version</literal> is specified,
- a <literal>version</literal> (<literal>int</literal>) will be
assigned. For version
+ <para>If <literal>version</literal> is not provided, a
<literal>version</literal>
+ will be automatically be assigned. For version
assignment, the versions of all deployed process definitions with the same name will
be taken into account. The assigned <literal>version</literal> will be
one higher
then the highest <literal>version</literal> number of deployed process
definitions
- with the same name. If no similarly named process definitions have been deployed,
- version number 1 is assigned.
+ with the same <literal>key</literal>. If no process definitions with a
similar
+ <literal>key</literal> have been deployed, version number 1 is assigned.
</para>
<para>In this first example, we'll supply a name and nothing
else.</para>
<programlisting><process name="Insurance
claim">
@@ -93,36 +93,40 @@
Then it will get the following properties:
</para>
<table><title>Process properties without key</title>
- <tgroup cols="2" rowsep="1" colsep="1">
+ <tgroup cols="3" rowsep="1" colsep="1">
<thead>
<row>
<entry>Property</entry>
<entry>Value</entry>
+ <entry>Source</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>name</literal></entry>
<entry>Insurance claim</entry>
+ <entry>process xml</entry>
</row>
<row>
<entry><literal>key</literal></entry>
<entry>Insurance_claim</entry>
+ <entry>generated</entry>
</row>
<row>
<entry><literal>version</literal></entry>
<entry>1</entry>
+ <entry>generated</entry>
</row>
<row>
<entry><literal>id</literal></entry>
<entry>Insurance_claim:1</entry>
+ <entry>generated</entry>
</row>
</tbody>
</tgroup>
</table>
-
<para>And as a second example, we'll show how you can get shorter ids by
- specifying a process key in the process element:</para>
+ specifying a process key:</para>
<programlisting><process name="Insurance claim"
key="ICL">
...
</process></programlisting>
@@ -133,24 +137,29 @@
<row>
<entry>Property</entry>
<entry>Value</entry>
+ <entry>Source</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>name</literal></entry>
<entry>Insurance claim</entry>
+ <entry>process xml</entry>
</row>
<row>
<entry><literal>key</literal></entry>
<entry>ICL</entry>
+ <entry>process xml</entry>
</row>
<row>
<entry><literal>version</literal></entry>
<entry>1</entry>
+ <entry>generated</entry>
</row>
<row>
<entry><literal>id</literal></entry>
<entry>ICL:1</entry>
+ <entry>generated</entry>
</row>
</tbody>
</tgroup>