[jbpm-commits] JBoss JBPM SVN: r6821 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/parser and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Nov 14 11:09:16 EST 2010
Author: rebody
Date: 2010-11-14 11:09:15 -0500 (Sun, 14 Nov 2010)
New Revision: 6821
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryEscalationEvent.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/escalation/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/escalation/BoundaryEscalationEventTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/escalation/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/escalation/boundary_escalation_event.bpmn.xml
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
Log:
JBPM-2732 interrupting boundary escalation event
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryEscalationEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryEscalationEvent.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryEscalationEvent.java 2010-11-14 16:09:15 UTC (rev 6821)
@@ -0,0 +1,83 @@
+/*
+ * 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.bpmn.flownodes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.api.model.Transition;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.op.AtomicOperation;
+
+/**
+ * boundary escalation event.
+ *
+ * @author Huisheng Xu
+ */
+public class BoundaryEscalationEvent extends BpmnActivity implements EventListener, BpmnEvent {
+
+ protected String boundaryEscalationEventActivityName;
+ protected boolean interrupting;
+
+ @SuppressWarnings("unchecked")
+ public void execute(ExecutionImpl execution) {
+ if (interrupting) {
+ ExecutionImpl parent = execution.destroyScope(execution.getActivity());
+ this.executeBoundaryEventBranch(parent);
+ } else {
+ ExecutionImpl parent = execution.getParent();
+ ExecutionImpl childExecution = parent.createExecution();
+ childExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+ this.executeBoundaryEventBranch(childExecution);
+ this.proceed(execution, this.findOutgoingSequenceFlow(execution, true));
+ }
+ }
+
+ protected void executeBoundaryEventBranch(ExecutionImpl execution) {
+ ProcessDefinitionImpl processDefinitionImpl = execution.getProcessDefinition();
+ ActivityImpl activityImpl = processDefinitionImpl.getActivity(boundaryEscalationEventActivityName);
+ execution.moveTo(activityImpl);
+ execution.take(activityImpl.getOutgoingTransitions().get(0));
+ }
+
+ public void notify(EventListenerExecution execution) {
+ this.execute((ExecutionImpl) execution);
+ }
+
+ public void setBoundaryEscalationEventActivityName(String boundaryEscalationEventActivityName) {
+ this.boundaryEscalationEventActivityName = boundaryEscalationEventActivityName;
+ }
+
+ public boolean isInterrupting() {
+ return interrupting;
+ }
+
+ public void setInterrupting(boolean interrupting) {
+ this.interrupting = interrupting;
+ }
+
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java 2010-11-12 22:32:13 UTC (rev 6820)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java 2010-11-14 16:09:15 UTC (rev 6821)
@@ -68,6 +68,10 @@
this.execute((ExecutionImpl) execution);
}
+ public void setBoundaryTimerEventActivityName(String boundaryTimerEventActivityName) {
+ this.boundaryTimerEventActivityName = boundaryTimerEventActivityName;
+ }
+
public boolean isInterrupting() {
return interrupting;
}
@@ -76,8 +80,4 @@
this.interrupting = interrupting;
}
- public void setBoundaryTimerEventActivityName(String boundaryTimerEventActivityName) {
- this.boundaryTimerEventActivityName = boundaryTimerEventActivityName;
- }
-
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-11-12 22:32:13 UTC (rev 6820)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-11-14 16:09:15 UTC (rev 6821)
@@ -39,6 +39,7 @@
import org.jbpm.bpmn.common.Resource;
import org.jbpm.bpmn.common.ResourceParameter;
import org.jbpm.bpmn.flownodes.BpmnActivity;
+import org.jbpm.bpmn.flownodes.BoundaryEscalationEvent;
import org.jbpm.bpmn.flownodes.BoundaryErrorEvent;
import org.jbpm.bpmn.flownodes.BoundaryTimerEvent;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
@@ -277,10 +278,13 @@
Element timerEventDefinition = XmlUtil.element(boundaryEventElement, "timerEventDefinition");
Element errorEventDefinition = XmlUtil.element(boundaryEventElement, "errorEventDefinition");
+ Element escalationEventDefinition = XmlUtil.element(boundaryEventElement, "escalationEventDefinition");
if (timerEventDefinition != null) {
this.parseBoundaryTimerEventDefinition(timerEventDefinition, interrupting, nestedActivity, refActivity, parse);
} else if (errorEventDefinition != null) {
this.parseBoundaryErrorEventDefinition(errorEventDefinition, nestedActivity, refActivity, parse);
+ } else if (escalationEventDefinition != null) {
+ this.parseBoundaryEscalationEventDefinition(escalationEventDefinition, interrupting, nestedActivity, refActivity, parse);
} else {
parse.addProblem("Unsupported boundary event type : " + boundaryEventElement);
}
@@ -316,6 +320,27 @@
timerActivity.setActivityBehaviour(boundaryTimerEvent);
}
+ public void parseBoundaryEscalationEventDefinition(Element escalationEventDefinition,
+ boolean interrupting,
+ ActivityImpl escalationActivity,
+ ActivityImpl refActivity,
+ Parse parse) {
+
+ BoundaryEscalationEvent boundaryEscalationEvent = new BoundaryEscalationEvent();
+ boundaryEscalationEvent.setInterrupting(interrupting);
+ boundaryEscalationEvent.setBoundaryEscalationEventActivityName(escalationActivity.getName());
+
+ String eventName = XmlUtil.attribute(escalationEventDefinition, "escalationRef");
+
+ EventImpl event = refActivity.getEvent(eventName);
+ if (event == null) {
+ event = refActivity.createEvent(eventName);
+ }
+ EventListenerReference eventListenerReference = event.createEventListenerReference(boundaryEscalationEvent);
+
+ escalationActivity.setActivityBehaviour(boundaryEscalationEvent);
+ }
+
public void parseBoundaryErrorEventDefinition(Element errorEventDefinition,
ActivityImpl errorActivity,
ActivityImpl refActivity,
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/escalation/BoundaryEscalationEventTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/escalation/BoundaryEscalationEventTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/escalation/BoundaryEscalationEventTest.java 2010-11-14 16:09:15 UTC (rev 6821)
@@ -0,0 +1,51 @@
+/*
+ * 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.bpmn.event.error;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * @author Huisheng Xu
+ */
+public class BoundaryEscalationEventTest extends JbpmTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/escalation/boundary_escalation_event.bpmn.xml");
+ registerDeployment(deployment.deploy());
+ }
+
+ public void testProcessStartToEnd() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_escalation_event");
+ assertProcessInstanceEnded(processInstance);
+
+ HistoryProcessInstance hip = historyService.createHistoryProcessInstanceQuery().uniqueResult();
+ assertNotNull(hip);
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/escalation/boundary_escalation_event.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/escalation/boundary_escalation_event.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/escalation/boundary_escalation_event.bpmn.xml 2010-11-14 16:09:15 UTC (rev 6821)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
+ xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
+ typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath"
+ targetNamespace="http://jbpm.org/example/bpmn2/boundary_escalation_event"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <escalation id="MyEscalation" escalationCode="MyEscalation" />
+
+ <process id="boundary_escalation_event" name="Error Boundary Escalation Process">
+ <startEvent id="startEvent" name="StartProcess"/>
+ <sequenceFlow id="flow1" sourceRef="startEvent" targetRef="subProcess"/>
+ <subProcess id="subProcess" name="Hello" >
+ <startEvent id="sub-start" name="StartSubProcess"/>
+ <sequenceFlow id="flow2" sourceRef="sub-start" targetRef="sub-parallel"/>
+ <parallelGateway id="sub-parallel" gatewayDirection="Diverging"/>
+ <sequenceFlow id="flow3" sourceRef="sub-parallel" targetRef="sub-error"/>
+ <endEvent id="sub-error" name="EscalationEvent">
+ <escalationEventDefinition escalationRef="MyEscalation"/>
+ </endEvent>
+ <sequenceFlow id="flow4" sourceRef="sub-parallel" targetRef="sub-task"/>
+ <userTask id="sub-task" name="Task" />
+ <sequenceFlow id="flow5" sourceRef="sub-task" targetRef="sub-end"/>
+ <endEvent id="sub-end" name="EndEvent"/>
+ </subProcess>
+ <sequenceFlow id="flow6" sourceRef="subProcess" targetRef="terminateEnd"/>
+ <endEvent id="terminateEnd" name="EndProcess">
+ <terminateEventDefinition/>
+ </endEvent>
+ <boundaryEvent id="escalationEvent" name="EscalationEvent" attachedToRef="subProcess" >
+ <escalationEventDefinition escalationRef="MyEscalation" />
+ </boundaryEvent>
+ <sequenceFlow id="flow7" sourceRef="escalationEvent" targetRef="task"/>
+ <scriptTask id="task" name="Goodbye">
+ <script>System.out.println("Escalation handled");</script>
+ </scriptTask>
+ <sequenceFlow id="flow8" sourceRef="task" targetRef="endEvent"/>
+ <endEvent id="endEvent" name="EndProcess"/>
+ </process>
+</definitions>
More information about the jbpm-commits
mailing list