- fix for XOR type joins where forked path were not ended properly and tasks on those paths were not removed

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4919 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-01-24 15:36:53 +00:00
parent deff5103ae
commit 211da07059
7 changed files with 267 additions and 2 deletions

View File

@@ -72,7 +72,7 @@
<value>org/jbpm/graph/node/ProcessState.hbm.xml</value> <value>org/jbpm/graph/node/ProcessState.hbm.xml</value>
<value>org/jbpm/graph/node/Decision.hbm.xml</value> <value>org/jbpm/graph/node/Decision.hbm.xml</value>
<value>org/jbpm/graph/node/Fork.hbm.xml</value> <value>org/jbpm/graph/node/Fork.hbm.xml</value>
<value>org/jbpm/graph/node/Join.hbm.xml</value> <value>org/alfresco/repo/workflow/jbpm/Join.hbm.xml</value>
<value>org/jbpm/graph/node/State.hbm.xml</value> <value>org/jbpm/graph/node/State.hbm.xml</value>
<value>org/jbpm/graph/node/TaskNode.hbm.xml</value> <value>org/jbpm/graph/node/TaskNode.hbm.xml</value>
<value>org/jbpm/context/def/ContextDefinition.hbm.xml</value> <value>org/jbpm/context/def/ContextDefinition.hbm.xml</value>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field" >
<subclass name="org.alfresco.repo.workflow.jbpm.Join"
discriminator-value="J"
extends="org.jbpm.graph.def.Node" />
</hibernate-mapping>

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.workflow.jbpm;
import org.dom4j.Element;
import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.Event;
import org.jbpm.instantiation.Delegation;
import org.jbpm.jpdl.xml.JpdlXmlReader;
/**
* Implementation of Join which ends child tokens / tasks for nOutM cases.
*
* @author davidc
*
*/
public class Join extends org.jbpm.graph.node.Join
{
private static final long serialVersionUID = 6417483503439714897L;
/**
* Constructor
*/
public Join()
{
}
/**
* Constructor
*/
public Join(String name)
{
super(name);
}
/* (non-Javadoc)
* @see org.jbpm.jpdl.xml.Parsable#read(org.dom4j.Element, org.jbpm.jpdl.xml.JpdlXmlReader)
*/
public void read(Element element, JpdlXmlReader jpdlReader)
{
// Add "on node leave" event handler which ends child tokens / tasks
Delegation delegation = new Delegation(JoinEndForkedTokens.class.getName());
Action action = new Action(delegation);
Event event = new Event(Event.EVENTTYPE_NODE_LEAVE);
event.addAction(action);
addEvent(event);
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.workflow.jbpm;
import java.util.Collection;
import java.util.Map;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
/**
* Action Handler for ending child tokens / tasks
*
* @author davidc
*/
public class JoinEndForkedTokens implements ActionHandler
{
private static final long serialVersionUID = 8679390550752208189L;
/**
* Constructor
*/
public JoinEndForkedTokens()
{
}
/* (non-Javadoc)
* @see org.jbpm.graph.def.ActionHandler#execute(org.jbpm.graph.exe.ExecutionContext)
*/
public void execute(ExecutionContext executionContext)
{
Token token = executionContext.getToken();
Map childTokens = token.getActiveChildren();
for (Object childToken : childTokens.values())
{
cancelToken(executionContext, (Token)childToken);
}
}
/**
* Cancel token
*
* @param executionContext
* @param token
*/
protected void cancelToken(ExecutionContext executionContext, Token token)
{
// visit child tokens
Map childTokens = token.getActiveChildren();
for (Object childToken : childTokens.values())
{
cancelToken(executionContext, (Token)childToken);
}
// end token
if (!token.hasEnded())
{
token.end(false);
}
// end any associated tasks
cancelTokenTasks(executionContext, token);
}
/**
* Cancel tasks associated with a token
*
* @param executionContext
* @param token
*/
protected void cancelTokenTasks(ExecutionContext executionContext, Token token)
{
TaskMgmtInstance tms = executionContext.getTaskMgmtInstance();
Collection tasks = tms.getUnfinishedTasks(token);
for (Object task : tasks)
{
TaskInstance taskInstance = (TaskInstance)task;
if (taskInstance.isBlocking())
{
taskInstance.setBlocking(false);
}
if (taskInstance.isSignalling())
{
taskInstance.setSignalling(false);
}
if (!taskInstance.hasEnded())
{
taskInstance.cancel();
}
}
}
}

View File

@@ -14,7 +14,7 @@
<string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" /> <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
<string name='resource.converter' value='org/alfresco/repo/workflow/jbpm/jbpm.converter.properties' /> <string name='resource.converter' value='org/alfresco/repo/workflow/jbpm/jbpm.converter.properties' />
<string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" /> <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
<string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" /> <string name="resource.node.types" value="org/alfresco/repo/workflow/jbpm/jbpm.node.types.xml" />
<string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" /> <string name="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
<string name="resource.varmapping" value="org/alfresco/repo/workflow/jbpm/jbpm.varmapping.xml" /> <string name="resource.varmapping" value="org/alfresco/repo/workflow/jbpm/jbpm.varmapping.xml" />

View File

@@ -0,0 +1,18 @@
<node-types>
<node-type element="start-state" class="org.jbpm.graph.node.StartState" />
<node-type element="end-state" class="org.jbpm.graph.node.EndState" />
<node-type element="node" class="org.jbpm.graph.def.Node" />
<node-type element="state" class="org.jbpm.graph.node.State" />
<node-type element="task-node" class="org.jbpm.graph.node.TaskNode" />
<node-type element="fork" class="org.jbpm.graph.node.Fork" />
<node-type element="join" class="org.alfresco.repo.workflow.jbpm.Join" />
<node-type element="decision" class="org.jbpm.graph.node.Decision" />
<node-type element="process-state" class="org.jbpm.graph.node.ProcessState" />
<node-type element="super-state" class="org.jbpm.graph.def.SuperState" />
<node-type element="merge" class="org.jbpm.graph.node.Merge" />
<node-type element="milestone-node" class="org.jbpm.graph.node.MilestoneNode" />
<node-type element="interleave-start" class="org.jbpm.graph.node.InterleaveStart" />
<node-type element="interleave-end" class="org.jbpm.graph.node.InterleaveEnd" />
<node-type element="page" class="org.jboss.seam.pageflow.Page" />
<node-type element="start-page" class="org.jboss.seam.pageflow.Page" />
</node-types>

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:xor">
<swimlane name="initiator" />
<start-state name="start">
<task name="submit" swimlane="initiator" />
<transition name="" to="orsplit" />
</start-state>
<fork name="orsplit">
<transition name="a" to="a" />
<transition name="bc" to="bc" />
</fork>
<task-node name="a">
<task name="a">
<assignment actor-id="usera" />
</task>
<transition name="" to="orjoin" />
</task-node>
<fork name="bc">
<transition name="b" to="b" />
<transition name="c" to="c" />
</fork>
<task-node name="b">
<task name="b">
<assignment actor-id="userb" />
</task>
<transition name="" to="bcjoin" />
</task-node>
<task-node name="c">
<task name="c">
<assignment actor-id="userc" />
</task>
<transition name="" to="bcjoin" />
</task-node>
<join name="bcjoin">
<transition name="" to="orjoin" />
</join>
<join name="orjoin">
<event type="node-enter">
<script>
node.nOutOfM = 1;
</script>
</event>
<transition name="" to="wait" />
</join>
<state name="wait">
<transition name="" to="end" />
</state>
<end-state name="end" />
</process-definition>