Author: rebody
Date: 2010-08-17 03:43:03 -0400 (Tue, 17 Aug 2010)
New Revision: 6600
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/CustomJava.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/ErrorAssignmentHandler.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/LogListener.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/RetryDecisionHandler.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/SimpleSubflowUsecaseTest.java
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ChildProcess.jpdl.xml
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ParentProcess.jpdl.xml
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java
Log:
JBPM-2706 sub process with timer and wait state testcases.
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2010-08-17
03:38:37 UTC (rev 6599)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -46,14 +46,10 @@
public String createUser(String userName, String givenName, String familyName,
String businessEmail) {
- try {
- User user = findUserById(userName);
- if (user != null) {
- throw new JbpmException("Cannot create user, userId: [" + userName +
"] has been used");
- }
- } catch(Exception ex) {
- throw new JbpmException("Cannot create user, error while validating",
ex);
+ if (findUserById(userName) != null) {
+ throw new JbpmException("Cannot create user, userId: [" + userName +
"] has been used");
}
+
UserImpl user = new UserImpl(userName, givenName, familyName);
user.setBusinessEmail(businessEmail);
@@ -105,14 +101,10 @@
}
public String createGroup(String groupName, String groupType, String parentGroupId) {
- try {
- GroupImpl group = findGroupById(groupName);
- if (group != null) {
- throw new JbpmException("Cannot create group, groupId: [" + groupName +
"] has been used");
- }
- } catch(Exception ex) {
- throw new JbpmException("Cannot create group, error while validating",
ex);
+ if (findGroupById(groupName) != null) {
+ throw new JbpmException("Cannot create group, groupId: [" + groupName +
"] has been used");
}
+
GroupImpl group = new GroupImpl();
String groupId = groupType != null ? groupType + "." + groupName :
groupName;
group.setId(groupId);
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-08-17
03:38:37 UTC (rev 6599)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -1079,8 +1079,8 @@
protected void checkActive() {
if (!isActive()) {
- throw new JbpmException(toString()+" is not active: "+state);
- } else if (this.subProcessInstance != null &&
!Execution.STATE_ENDED.equals(this.subProcessInstance.getState())) {
+ throw new JbpmException(toString() + " is not active: " + state);
+ } else if (this.subProcessInstance != null &&
!this.subProcessInstance.isEnded()) {
throw new JbpmException(toString() + " has running subprocess: "
+ this.subProcessInstance.toString() + " in state " +
this.subProcessInstance.getState());
}
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/CustomJava.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/CustomJava.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/CustomJava.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,48 @@
+package org.jbpm.examples.subprocess;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+public class CustomJava implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 123456789L;
+
+ private final static String RESULT_VARIABLE = "result";
+
+ public void execute(ActivityExecution execution) throws Exception {
+
+ try {
+ System.out.println("Invoking Custom Java Class");
+ String info = "ID [" + execution.getId() + "] Key ["
+ + execution.getKey() + "] Name [" + execution.getName()
+ + "] ";
+ System.out.println(info);
+
+ System.out.println("Setting Activity Result Status = "
+ + RetryDecisionHandler.ERROR_RETRY);
+ execution.setVariable(RESULT_VARIABLE,
+ RetryDecisionHandler.ERROR_RETRY);
+
+ System.out.println("Invoked Custom Java Class Successfully");
+ }
+
+ catch (Throwable e) {
+ System.out.println("Error During Custom Java Class: " + e);
+ execution.setVariable(RESULT_VARIABLE, RetryDecisionHandler.ERROR_FAIL);
+ }
+
+ finally {
+ System.out.println("Exiting Custom Java Class");
+ }
+ }
+
+ public void signal(ActivityExecution execution, String signalName,
+ Map<String, ?> parameters) throws Exception {
+ System.out
+ .println("Signal Received Activity [{}] "
+ + execution.getActivityName() + " Id [{}] "
+ + execution.getId());
+ }
+}
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/ErrorAssignmentHandler.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/ErrorAssignmentHandler.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/ErrorAssignmentHandler.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,18 @@
+package org.jbpm.examples.subprocess;
+
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.api.task.Assignable;
+import org.jbpm.api.task.AssignmentHandler;
+
+public class ErrorAssignmentHandler implements AssignmentHandler {
+
+ private static final long serialVersionUID = -7892865703636156082L;
+
+ public void assign(Assignable assignable, OpenExecution execution)
+ throws Exception {
+
+ System.out.println("Assigning Task To ["
+ + SimpleSubflowUsecaseTest.GROUP + "]");
+ assignable.addCandidateGroup(SimpleSubflowUsecaseTest.GROUP);
+ }
+}
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/LogListener.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/LogListener.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/LogListener.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,21 @@
+package org.jbpm.examples.subprocess;
+
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+
+public class LogListener implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ String logMessage;
+
+ public void notify(EventListenerExecution execution) {
+ String info = "ID [" + execution.getId() + "] Key ["
+ + execution.getKey() + "] Name [" + execution.getName() + "] ";
+ logEvent(info + this.logMessage);
+ }
+
+ public void logEvent(String message) {
+ System.out.println(message);
+ }
+}
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/RetryDecisionHandler.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/RetryDecisionHandler.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/RetryDecisionHandler.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,57 @@
+package org.jbpm.examples.subprocess;
+
+import org.jbpm.api.jpdl.DecisionHandler;
+import org.jbpm.api.model.OpenExecution;
+
+public class RetryDecisionHandler implements DecisionHandler {
+
+ private static final long serialVersionUID = 7836018454656817776L;
+ private final static String RETRY_VARIABLE = "jbpm.retries";
+ private final static String MAX_TRIES_EXCEEDED = "max_retries_exceeded";
+ private final static int MAX_RETRIES = 3;
+
+ public final static String ERROR_RETRY = "error_retry";
+ public final static String ERROR_FAIL = "error_fail";
+ public final static String SUCCESS = "success";
+
+ public final String decide(OpenExecution execution) {
+
+ String decisionPathName = null;
+
+ int currentRetries = getCurrentRetries(execution);
+ System.out.println("Current Retries = " + currentRetries);
+ if ((++currentRetries) > MAX_RETRIES) {
+ decisionPathName = MAX_TRIES_EXCEEDED;
+ System.out.println(currentRetries + " > MAX_RETRIES ("
+ + MAX_RETRIES + ")");
+
+ // Reset the retry count again as the manual error handling could
+ // sent it back
+ // there again and the count would still be set !.
+ setCurrentRetries(execution, 0);
+ } else {
+ decisionPathName = ERROR_RETRY;
+ System.out.println(currentRetries + " <= MAX_RETRIES ("
+ + MAX_RETRIES + ")");
+ setCurrentRetries(execution, currentRetries);
+ }
+ System.out
+ .println("Returning decision path [" + decisionPathName +
"]");
+ return decisionPathName;
+ }
+
+ private final int getCurrentRetries(OpenExecution execution) {
+ Integer retries = (Integer) execution.getVariable(RETRY_VARIABLE);
+ if (retries == null) {
+ System.out.println("Process Variable [" + RETRY_VARIABLE
+ + "] Not Found - Setting to 0");
+ retries = new Integer(0);
+ }
+ return retries.intValue();
+ }
+
+ private final void setCurrentRetries(OpenExecution execution, int retries) {
+ System.out.println("Setting Current Retries In Execution = " +
retries);
+ execution.setVariable(RETRY_VARIABLE, new Integer(retries));
+ }
+}
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/SimpleSubflowUsecaseTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/SimpleSubflowUsecaseTest.java
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/subprocess/SimpleSubflowUsecaseTest.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,286 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.examples.subprocess;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+import org.jbpm.internal.log.Log;
+import org.jbpm.test.JbpmTestCase;
+
+public class SimpleSubflowUsecaseTest extends JbpmTestCase {
+ private Log log = Log.getLog(SimpleSubflowUsecaseTest.class.getName());
+
+ public final static String GROUP =
"org.jbpm.examples.subprocess.usecase.GROUP";
+ private final static String USERID =
"org.jbpm.examples.subprocess.usecase.USER";
+ private final static String USER_FIRST = "jbpm-first";
+ private final static String USER_LAST = "jbpm-last";
+
+ private final static String ERROR_ABORT = "end-abort";
+ private final static String SKIP_STEP = "skip-step";
+ private final static String RETRY = "retry";
+
+ private final long THREAD_SLEEP_TIME = 1000 * 20; // 20 Seconds
+
+ private final static String CREATE_ERROR_TASK_NAME = "Create Error Task";
+
+ private String deploymentIdA = null;
+ private String deploymentIdB = null;
+
+ protected void setUp() throws Exception {
+
+ log.info("In Setup !");
+ super.setUp();
+
+ try {
+ identityService.createGroup(GROUP);
+ } catch (Exception e) {
+ log.info("Error creating Group: " + e);
+ }
+ try {
+ identityService.createUser(USERID, USERID, USER_FIRST, USER_LAST);
+ } catch (Exception e) {
+ log.info("Error creating User: " + e);
+ }
+ try {
+ identityService.createMembership(USERID, GROUP);
+ } catch (Exception e) {
+ log.info("Error on User Assignment to Group: " + e);
+ }
+
+ log.info("Process Engine = " + processEngine);
+ log.info("Repo Service = " + repositoryService);
+ log.info("Execution Service = " + executionService);
+
+ deploymentIdA = repositoryService
+ .createDeployment()
+ .addResourceFromClasspath(
+ "org/jbpm/examples/subprocess/ParentProcess.jpdl.xml")
+ .deploy();
+ assertNotNull(deploymentIdA);
+
+ deploymentIdB = repositoryService
+ .createDeployment()
+ .addResourceFromClasspath(
+ "org/jbpm/examples/subprocess/ChildProcess.jpdl.xml")
+ .deploy();
+ assertNotNull(deploymentIdB);
+ }
+
+ protected void tearDown() throws Exception {
+
+ try {
+ repositoryService.deleteDeploymentCascade(deploymentIdA);
+ repositoryService.deleteDeploymentCascade(deploymentIdB);
+ }
+ catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ try {
+ identityService.deleteMembership(USERID, GROUP, null);
+ } catch (Exception e) {
+ log.info("Error on User Removal from Group: " + e);
+ }
+ try {
+ identityService.deleteGroup(GROUP);
+ } catch (Exception e) {
+ log.info("Error deleting Group: " + e);
+ }
+ try {
+ identityService.deleteUser(USERID);
+ } catch (Exception e) {
+ log.info("Error on User: " + e);
+ }
+
+ super.tearDown();
+ }
+
+ public void testSimpleSubflowManualAbort() {
+
+ log.info("Started testSimpleSubflowManualAbort()");
+
+ String businessKey = "jbpmKey-"
+ + new Random(System.currentTimeMillis()).nextInt();
+ ProcessInstance processInstance = executionService
+
.startProcessInstanceByKey("org.jbpm.examples.subprocess.usecase.parent",
businessKey);
+ String processInstanceId = processInstance.getId();
+ log.info("Process ID " + processInstanceId);
+
+ /**
+ * Timer has 3 x 5 seconds sleep so wait for 20 seconds and the task
+ * should be there by then.
+ */
+ //try {
+ // Thread.sleep(THREAD_SLEEP_TIME);
+ //} catch (InterruptedException e) {
+ // e.printStackTrace();
+ //}
+ executeJobs();
+
+ List<Task> tasks = taskService.findGroupTasks(USERID);
+ assertNotNull(tasks);
+ assertContainsTask(tasks,CREATE_ERROR_TASK_NAME);
+
+ if (tasks == null || tasks.size() == 0) {
+ log.info("No Tasks Found");
+ } else {
+ log.info("Found [" + tasks.size() + "] Tasks !");
+ Task task = tasks.get(0);
+ log.info("Taking Task [" + task.getId() + "]");
+ taskService.takeTask(task.getId(), USERID);
+ log.info("Completing Task with Signal: " + ERROR_ABORT);
+ taskService.completeTask(task.getId(), ERROR_ABORT);
+ }
+
+ assertNoOpenTasks(processInstance.getId());
+ assertProcessInstanceEnded(processInstance);
+
+ log.info("Finished testSimpleSubflowManualAbort()");
+ }
+
+ public void testSimpleSubflowSkipStep() {
+
+ log.info("Started testSimpleSubflowSkipStep()");
+
+ String businessKey = "jbpmKey-"
+ + new Random(System.currentTimeMillis()).nextInt();
+ ProcessInstance processInstance = executionService
+
.startProcessInstanceByKey("org.jbpm.examples.subprocess.usecase.parent",
businessKey);
+ String processInstanceId = processInstance.getId();
+ log.info("Process ID " + processInstanceId);
+
+ /**
+ * Timer has 3 x 5 seconds sleep so wait for 20 seconds and the task
+ * should be there by then.
+ */
+ //try {
+ // Thread.sleep(THREAD_SLEEP_TIME);
+ //} catch (InterruptedException e) {
+ // e.printStackTrace();
+ //}
+ executeJobs();
+
+ List<Task> tasks = taskService.findGroupTasks(USERID);
+ assertNotNull(tasks);
+ assertContainsTask(tasks,CREATE_ERROR_TASK_NAME);
+
+ if (tasks == null || tasks.size() == 0) {
+ log.info("No Tasks Found");
+ } else {
+ log.info("Found [" + tasks.size() + "] Tasks !");
+ Task task = tasks.get(0);
+ log.info("Taking Task [" + task.getId() + "]");
+ taskService.takeTask(task.getId(), USERID);
+ log.info("Completing Task with Signal: " + SKIP_STEP);
+ taskService.completeTask(task.getId(), SKIP_STEP);
+ }
+
+ assertNoOpenTasks(processInstance.getId());
+ assertProcessInstanceEnded(processInstance);
+
+ log.info("Finished testSimpleSubflowSkipStep()");
+ }
+
+ public void testSimpleSubflowManualRetry() {
+
+ log.info("Started testSimpleSubflowManualRetry()");
+
+ String businessKey = "jbpmKey-"
+ + new Random(System.currentTimeMillis()).nextInt();
+ ProcessInstance processInstance = executionService
+
.startProcessInstanceByKey("org.jbpm.examples.subprocess.usecase.parent",
businessKey);
+ String processInstanceId = processInstance.getId();
+ log.info("Process ID " + processInstanceId);
+
+ /**
+ * Timer has 3 x 5 seconds sleep so wait for 20 seconds and the task
+ * should be there by then.
+ */
+ //try {
+ // Thread.sleep(THREAD_SLEEP_TIME);
+ //} catch (InterruptedException e) {
+ // e.printStackTrace();
+ //}
+ executeJobs();
+
+ List<Task> tasks = taskService.findGroupTasks(USERID);
+ assertNotNull(tasks);
+ assertContainsTask(tasks,CREATE_ERROR_TASK_NAME);
+
+ if (tasks == null || tasks.size() == 0) {
+ log.info("No Tasks Found");
+ } else {
+ log.info("Found [" + tasks.size() + "] Tasks !");
+ Task task = tasks.get(0);
+ log.info("Taking Task [" + task.getId() + "]");
+ taskService.takeTask(task.getId(), USERID);
+ log.info("Completing Task with Signal: " + RETRY);
+ taskService.completeTask(task.getId(), RETRY);
+ }
+
+ /**
+ * Timer has 3 x 5 seconds sleep so wait for 20 seconds and the task
+ * should be there by then.
+ */
+ //try {
+ // Thread.sleep(THREAD_SLEEP_TIME);
+ //} catch (InterruptedException e) {
+ // e.printStackTrace();
+ //}
+ executeJobs();
+
+ tasks = taskService.findGroupTasks(USERID);
+ assertNotNull(tasks);
+ assertContainsTask(tasks,CREATE_ERROR_TASK_NAME);
+
+ if (tasks == null || tasks.size() == 0) {
+ log.info("No Tasks Found");
+ } else {
+ log.info("Found [" + tasks.size() + "] Tasks !");
+ Task task = tasks.get(0);
+ log.info("Taking Task [" + task.getId() + "]");
+ taskService.takeTask(task.getId(), USERID);
+ log.info("Completing Task with Signal: " + ERROR_ABORT);
+ taskService.completeTask(task.getId(), ERROR_ABORT);
+ }
+
+ assertNoOpenTasks(processInstance.getId());
+ assertProcessInstanceEnded(processInstance);
+
+ log.info("Finished testSimpleSubflowManualRetry()");
+ }
+
+ protected void executeJobs() {
+ List<Job> jobs = Collections.EMPTY_LIST;
+ do {
+ jobs = managementService.createJobQuery().list();
+ for (Job job : jobs) {
+ managementService.executeJob(job.getId());
+ }
+ } while (!jobs.isEmpty());
+ }
+}
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java 2010-08-17
03:38:37 UTC (rev 6599)
+++
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java 2010-08-17
07:43:03 UTC (rev 6600)
@@ -154,7 +154,7 @@
identityService.createUser("johndoe", "John",
"Doe");
fail("shouldn't allow duplicated user");
} catch(JbpmException ex) {
- assertEquals("Cannot create user, error while validating",
ex.getMessage());
+ assertEquals("Cannot create user, userId: [johndoe] has been used",
ex.getMessage());
}
identityService.deleteUser("johndoe");
}
@@ -165,7 +165,7 @@
identityService.createGroup("group");
fail("shouldn't allow duplicated group");
} catch(JbpmException ex) {
- assertEquals("Cannot create group, error while validating",
ex.getMessage());
+ assertEquals("Cannot create group, groupId: [group] has been used",
ex.getMessage());
}
identityService.deleteGroup("group");
}
Added:
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ChildProcess.jpdl.xml
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ChildProcess.jpdl.xml
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ChildProcess.jpdl.xml 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process key="org.jbpm.examples.subprocess.usecase.child"
name="OrgJBPMExamplesSubprocessUsecaseChild">
+ <description>JBPM Examples Subprocess Usecase Child
Workflow</description>
+
+ <on event="start">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Simple Subprocess Started" />
+ </field>
+ </event-listener>
+ </on>
+
+ <on event="start">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Simple Subprocess Started Ended" />
+ </field>
+ </event-listener>
+ </on>
+
+ <start g="43,93,48,48" name="start1">
+ <transition g="-48,-21" name="Start Task" to="Custom
Java" />
+ </start>
+
+ <custom class="org.jbpm.examples.subprocess.CustomJava"
+ continue="async" g="224,92,139,52" name="Custom
Java">
+ <on event="start">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Invoking Custom Java" />
+ </field>
+ </event-listener>
+ </on>
+
+ <on event="end">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Invoked Custom Java" />
+ </field>
+ </event-listener>
+ </on>
+ <transition g="-37,-22" name="check result"
to="check_status" />
+ </custom>
+
+ <decision g="501,93,48,48" name="check_status">
+ <transition g="-33,-17" name="Successful"
to="end-success">
+ <condition expr="#{result=="success"}" />
+ </transition>
+ <transition g="17,-14" name="Retriable Error"
to="retry_decider">
+ <condition expr="#{result=="error_retry"}"
/>
+ </transition>
+ <transition g="525,45:85,-24" name="Fatal Error"
to="end-error">
+ <condition expr="#{result=="error_fail"}"
/>
+ </transition>
+ </decision>
+
+ <decision g="503,239,48,48" name="retry_decider">
+ <handler class="org.jbpm.examples.subprocess.RetryDecisionHandler"
/>
+ <transition g="14,-3" name="max_retries_exceeded"
to="Create Error Task" />
+ <transition g="-20,26" name="error_retry" to="Wait
For Timeout" />
+ </decision>
+
+ <task continue="async" g="431,382,189,52" name="Create
Error Task">
+ <assignment-handler
+ class="org.jbpm.examples.subprocess.ErrorAssignmentHandler" />
+ <on event="start">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Creating Manual Error Task" />
+ </field>
+ </event-listener>
+ </on>
+ <on event="end">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Manual Error Task Was Taken - Is Ended."
/>
+ </field>
+ </event-listener>
+ </on>
+ <transition g="18,-9" name="end-abort"
to="end-abort" />
+ <transition g="295,409:75,-23" name="retry"
to="Custom Java" />
+ <transition g="776,407:-145,10" name="skip-step"
to="end-success" />
+ </task>
+
+ <end-cancel g="503,550,48,48" name="end-abort" />
+ <end-error g="751,19,48,48" name="end-error" />
+ <end g="752,90,48,48" name="end-success"
state="end-success" />
+
+ <state g="333,239,117,52" name="Wait For Timeout">
+ <transition g="9,-13" name="timeout" to="Custom
Java">
+ <timer duedate="5 seconds" />
+ </transition>
+ </state>
+
+</process>
Added:
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ParentProcess.jpdl.xml
===================================================================
---
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ParentProcess.jpdl.xml
(rev 0)
+++
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/subprocess/ParentProcess.jpdl.xml 2010-08-17
07:43:03 UTC (rev 6600)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process key="org.jbpm.examples.subprocess.usecase.parent"
name="OrgJBPMExamplesSubprocessUsecaseParent">
+ <description>JBPM Examples Subprocess Usecase Parent
Workflow</description>
+
+ <on event="start">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Process Started"/>
+ </field>
+ </event-listener>
+ </on>
+
+ <on event="end">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Process Finished"/>
+ </field>
+ </event-listener>
+ </on>
+
+ <start g="52,69,80,40">
+ <transition g="-18,-22" name="start" to="Async
Starter"/>
+ </start>
+
+ <java class="org.jbpm.examples.subprocess.LogListener"
continue="async" g="271,66,100,52" method="logEvent"
name="Async Starter">
+ <arg><string value="Invoked Async Java
Starter..."/></arg>
+ <transition g="-54,-14" name="invoke" to="Invoke Child
Process"/>
+ </java>
+
+ <sub-process continue="async" g="231,211,182,52"
name="Invoke Child Process"
sub-process-key="org.jbpm.examples.subprocess.usecase.child">
+
+ <on event="start">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Invoking Sub Process"/>
+ </field>
+ </event-listener>
+ </on>
+ <on event="end">
+ <event-listener
class="org.jbpm.examples.subprocess.LogListener">
+ <field name="logMessage">
+ <string value="Completed Invoking Sub Process"/>
+ </field>
+ </event-listener>
+ </on>
+ <transition g="10,-7" name="end-error"
to="end-error"/>
+ <transition g="-35,-24" name="end-success"
to="end-success"/>
+ <transition g="501,363:37,-24" name="end-abort"
to="end-abort"/>
+ </sub-process>
+
+ <end g="644,212,80,40" name="end-success"/>
+ <end-error g="298,350,48,48" name="end-error"/>
+ <end-cancel g="644,340,48,48" name="end-abort"/>
+
+</process>