[jbpm-commits] JBoss JBPM SVN: r2491 - in projects/spec/trunk/modules: api/src/main/java/org/jbpm/api/model/builder and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Oct 6 13:59:38 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-10-06 13:59:38 -0400 (Mon, 06 Oct 2008)
New Revision: 2491
Added:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java
projects/spec/trunk/modules/cts/pom.xml
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
Log:
No excludes - all pass
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,34 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Jul-2008
+ */
+public interface InputSet extends PropertySupport
+{
+}
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,34 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * An OuputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Jul-2008
+ */
+public interface OutputSet extends PropertySupport
+{
+}
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,7 @@
//$Id$
+import java.io.Serializable;
import java.util.Set;
/**
@@ -31,7 +32,7 @@
* @author thomas.diesler at jboss.com
* @since 21-Jul-2008
*/
-public interface PropertySupport
+public interface PropertySupport extends Serializable
{
/**
* Get a Property with a given name.
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,8 @@
//$Id$
+import java.util.List;
+
/**
* A Task is an Atomic Activity that is included within a Process.
*
@@ -57,4 +59,30 @@
* Get the outgoing SequenceFlow
*/
SequenceFlow getOutFlow();
+
+ /**
+ * The InputSets attribute defines the data requirements for input to the Activity.
+ * Zero or more InputSets MAY be defined. Each Input set is sufficient to allow the
+ * Activity to be performed (if it has first been instantiated by the appropriate signal
+ * arriving from an incoming Sequence Flow)
+ */
+ List<InputSet> getInputSets();
+
+ /**
+ * The OutputSets attribute defines the data requirements for output from the
+ * activity. Zero or more OutputSets MAY be defined. At the completion of the
+ * activity, only one of the OutputSets may be produced--It is up to the
+ * implementation of the activity to determine which set will be produced. However,
+ * the IORules attribute MAY indicate a relationship between an OutputSet and an
+ * InputSet that started the activity.
+ */
+ List<OutputSet> getOutputSets();
+
+ /**
+ * The IORules attribute is a collection of expressions, each of which specifies the
+ * required relationship between one input and one output. That is, if the activity is
+ * instantiated with a specified input, that activity shall complete with the specified
+ * output.
+ */
+ List<Expression> getIORules();
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -21,9 +21,11 @@
*/
package org.jbpm.api.model.builder;
-
//$Id$
+import org.jbpm.api.model.Message;
+import org.jbpm.api.model.Expression.ExpressionLanguage;
+
/**
* The TaskBuilder can be used to build a Task dynamically.
*
@@ -38,4 +40,29 @@
* The {@link Message} must be defined at {@link Process} level
*/
TaskBuilder addMessageRef(String msgName);
+
+ /**
+ * Add an InputSet
+ */
+ TaskBuilder addInputSet();
+
+ /**
+ * Add an Property Input
+ */
+ TaskBuilder addPropertyInput(String name);
+
+ /**
+ * Add an OutputSet
+ */
+ TaskBuilder addOutputSet();
+
+ /**
+ * Add an Property Output
+ */
+ TaskBuilder addPropertyOutput(String name, String value);
+
+ /**
+ * Add an IORule Expression
+ */
+ TaskBuilder addIORule(String body, ExpressionLanguage lang);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,8 @@
// $Id$
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
/**
@@ -65,6 +67,18 @@
SequenceFlow getFlow();
/**
+ * Get the active {@link InputSet}
+ * @return null if the Activity does not define one
+ */
+ InputSet getInputSet();
+
+ /**
+ * Get the active {@link OutputSet}
+ * @return null if the Activity does not define one
+ */
+ OutputSet getOutputSet();
+
+ /**
* Create a schallow copy of this Token.
* <p/>
* The content in the ExecutionContext will be copied by reference.
Modified: projects/spec/trunk/modules/cts/pom.xml
===================================================================
--- projects/spec/trunk/modules/cts/pom.xml 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/pom.xml 2008-10-06 17:59:38 UTC (rev 2491)
@@ -70,8 +70,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
- <exclude>org/jbpm/test/cts/node/NodeInputSetTest.java</exclude>
- <exclude>org/jbpm/test/cts/node/NodeOutputSetTest.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -32,6 +32,7 @@
import org.jbpm.api.model.builder.MessageBuilder;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
+import org.jbpm.api.model.builder.TaskBuilder;
import org.jbpm.api.runtime.BasicAttachments;
import org.jbpm.api.test.CTSTestCase;
@@ -85,8 +86,8 @@
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
procBuilder.addProcess("ActivityInputSet").addStartEvent("Start").addSequenceFlow("TaskA");
- //TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
- //taskBuilder.addInputSet().addPropertyInput("frog").addSequenceFlow("End");
+ TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
+ taskBuilder.addInputSet().addPropertyInput("frog").addSequenceFlow("End");
procBuilder.addEndEvent("End", EventDetailType.Message).addMessageRef("EndMessage");
MessageBuilder msgBuilder = procBuilder.addProcessMessage("EndMessage");
msgBuilder.addToRef(getTestID()).addProperty("frog", null, true);
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -32,6 +32,7 @@
import org.jbpm.api.model.builder.MessageBuilder;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
+import org.jbpm.api.model.builder.TaskBuilder;
import org.jbpm.api.test.CTSTestCase;
/**
@@ -64,8 +65,8 @@
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
procBuilder.addProcess("ActivityInputSet").addStartEvent("Start").addSequenceFlow("TaskA");
- //TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
- //taskBuilder.addOutputSet().addPropertyOutput("frog", "kermit").addSequenceFlow("End");
+ TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
+ taskBuilder.addOutputSet().addPropertyOutput("frog", "kermit").addSequenceFlow("End");
procBuilder.addEndEvent("End", EventDetailType.Message).addMessageRef("EndMessage");
MessageBuilder msgBuilder = procBuilder.addProcessMessage("EndMessage");
msgBuilder.addToRef(getTestID()).addProperty("frog", null, true);
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -87,7 +87,7 @@
try
{
proc.waitForEnd();
- fail("No gate defained for foo==10");
+ fail("No gate defined for foo==10");
}
catch (RuntimeException rte)
{
Added: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java (rev 0)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,87 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Transient;
+
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.Property;
+
+
+/**
+ * An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class InputSetImpl implements InputSet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Transient
+ private Set<Property> properties = new HashSet<Property>();
+
+ @Override
+ public Property getProperty(String name)
+ {
+ for (Property prop : properties)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ @Override
+ public Set<String> getPropertyNames()
+ {
+ Set<String> names = new HashSet<String>();
+ for (Property prop : properties)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ @Override
+ public boolean removeProperty(String name)
+ {
+ return properties.remove(name);
+ }
+
+ @Override
+ public void addProperty(Property prop)
+ {
+ properties.add(prop);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "InputSet" + getPropertyNames();
+ }
+}
Property changes on: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java (rev 0)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,87 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Transient;
+
+import org.jbpm.api.model.OutputSet;
+import org.jbpm.api.model.Property;
+
+
+/**
+ * An OutputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class OutputSetImpl implements OutputSet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Transient
+ private Set<Property> properties = new HashSet<Property>();
+
+ @Override
+ public Property getProperty(String name)
+ {
+ for (Property prop : properties)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ @Override
+ public Set<String> getPropertyNames()
+ {
+ Set<String> names = new HashSet<String>();
+ for (Property prop : properties)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ @Override
+ public boolean removeProperty(String name)
+ {
+ return properties.remove(name);
+ }
+
+ @Override
+ public void addProperty(Property prop)
+ {
+ properties.add(prop);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OutputSet" + getPropertyNames();
+ }
+}
Property changes on: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,10 @@
//$Id$
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import javax.management.ObjectName;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -31,18 +35,26 @@
import org.jbpm.api.Constants;
import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.InputSet;
import org.jbpm.api.model.Node;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.ProcessStructure;
+import org.jbpm.api.model.Property;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.Signal;
import org.jbpm.api.model.Task;
import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.runtime.ExecutionContext;
+import org.jbpm.api.runtime.ExecutionHandler;
import org.jbpm.api.runtime.SignalHandler;
import org.jbpm.api.runtime.Token;
import org.jbpm.api.service.SignalService;
import org.jbpm.ri.model.builder.SingleInFlowSupport;
import org.jbpm.ri.model.builder.SingleOutFlowSupport;
+import org.jbpm.ri.runtime.MutableToken;
/**
* A Task is an Atomic Activity that is included within a Process.
@@ -62,6 +74,15 @@
@Enumerated(EnumType.STRING)
protected TaskType taskType;
+ @Transient
+ private List<InputSet> inputSets = new ArrayList<InputSet>();
+
+ @Transient
+ private List<OutputSet> outputSets = new ArrayList<OutputSet>();
+
+ @Transient
+ private List<Expression> ioRules = new ArrayList<Expression>();
+
public TaskImpl(ProcessStructure procStruct, String name, TaskType taskType)
{
super(procStruct, name);
@@ -117,6 +138,176 @@
}
@Override
+ public List<InputSet> getInputSets()
+ {
+ return Collections.unmodifiableList(inputSets);
+ }
+
+ public void addInputSet(InputSet inputSet)
+ {
+ inputSets.add(inputSet);
+ }
+
+ @Override
+ public List<OutputSet> getOutputSets()
+ {
+ return Collections.unmodifiableList(outputSets);
+ }
+
+ public void addOutputSet(OutputSet outputSet)
+ {
+ outputSets.add(outputSet);
+ }
+
+ public List<Expression> getIORules()
+ {
+ return Collections.unmodifiableList(ioRules);
+ }
+
+ public void addIORule(Expression expr)
+ {
+ ioRules.add(expr);
+ }
+
+ @Override
+ protected ExecutionHandler getDefaultExecutionHandler()
+ {
+ final Node thisNode = this;
+ final ExecutionHandler superExecHandler = super.getDefaultExecutionHandler();
+ return new ExecutionHandler()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(Token token)
+ {
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setOutputSet(getActiveOutputSet());
+ mutableToken.setInputSet(getActiveInputSet(token));
+ superExecHandler.execute(token);
+ processOutputSet(token);
+ postProcessInputSet(token);
+ }
+
+ @Override
+ public Node getNode()
+ {
+ return thisNode;
+ }
+
+ @Override
+ public void setNode(Node node)
+ {
+ }
+ };
+ }
+
+ /**
+ * Select and validate active inputSet
+ */
+ protected InputSet getActiveInputSet(Token token)
+ {
+ InputSetImpl inputSet = null;
+ ExecutionContext exContext = token.getExecutionContext();
+
+ // Find the InputSet that matches the data in the Token
+ if (inputSets.size() > 0)
+ {
+ for (InputSet auxSet : inputSets)
+ {
+ boolean allInputPropsInContext = true;
+ for (String propName : auxSet.getPropertyNames())
+ {
+ Object att = exContext.getAttachment(propName);
+ allInputPropsInContext &= (att != null);
+ }
+ if (allInputPropsInContext == true)
+ {
+ inputSet = new InputSetImpl();
+ for (String propName : auxSet.getPropertyNames())
+ {
+ Object value = exContext.getAttachment(propName);
+ inputSet.addProperty(new PropertyImpl(propName, value));
+ }
+ break;
+ }
+ }
+ if (inputSet == null)
+ {
+ log.warn("InputSets: " + inputSets);
+ throw new IllegalStateException("Cannot find matching inputSet for " + exContext + " in Activity: " + getName());
+ }
+ }
+
+ // Create an empty input set
+ if (inputSet == null)
+ inputSet = new InputSetImpl();
+
+ return inputSet;
+ }
+
+ /**
+ * Select the active outputSet
+ */
+ protected OutputSet getActiveOutputSet()
+ {
+ OutputSet outputSet = null;
+ if (outputSets.size() > 0)
+ {
+ if (outputSets.size() > 1)
+ throw new NotImplementedException("JBPM-1635", "IORules and multiple outputSets");
+
+ outputSet = new OutputSetImpl();
+ OutputSet firstOutputSet = outputSets.get(0);
+ for (String propName : firstOutputSet.getPropertyNames())
+ {
+ Property prop = firstOutputSet.getProperty(propName);
+ outputSet.addProperty(prop);
+ }
+ }
+
+ // Create an empty output set
+ if (outputSet == null)
+ outputSet = new OutputSetImpl();
+
+ return outputSet;
+ }
+
+ /**
+ * Transfer data from outputSet to Token
+ */
+ protected void processOutputSet(Token token)
+ {
+ ExecutionContext exContext = token.getExecutionContext();
+
+ // Add the outputSet properties to the Token
+ OutputSet outputSet = token.getOutputSet();
+ for (String propName : getActiveOutputSet().getPropertyNames())
+ {
+ Property outProp = outputSet.getProperty(propName);
+ if (outProp == null)
+ throw new IllegalStateException("Cannot find outputSet property '" + propName + "' in: " + this);
+
+ String name = outProp.getName();
+ Object value = outProp.getValue();
+ exContext.addAttachment(name, value);
+ }
+ }
+
+ /**
+ * Remove the inputSet properties
+ */
+ protected void postProcessInputSet(Token token)
+ {
+ // InputSet inputSet = token.getInputSet();
+ // ExecutionContext exContext = token.getExecutionContext();
+ // for (Property prop : inputSet.getProperties())
+ // {
+ // // TODO: define proper scope for token data
+ // exContext.removeAttachment(prop.getName());
+ // }
+ }
+
+ @Override
protected SignalHandler getDefaultSignalHandler()
{
final Node thisNode = this;
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,9 +23,15 @@
//$Id$
+import org.jbpm.api.model.Property;
import org.jbpm.api.model.Task;
+import org.jbpm.api.model.Expression.ExpressionLanguage;
import org.jbpm.api.model.builder.TaskBuilder;
+import org.jbpm.ri.model.ExpressionImpl;
+import org.jbpm.ri.model.InputSetImpl;
import org.jbpm.ri.model.MessageImpl;
+import org.jbpm.ri.model.OutputSetImpl;
+import org.jbpm.ri.model.PropertyImpl;
import org.jbpm.ri.model.ReceiveTaskImpl;
import org.jbpm.ri.model.SendTaskImpl;
import org.jbpm.ri.model.TaskImpl;
@@ -38,11 +44,15 @@
*/
public class TaskBuilderImpl extends ProcessBuilderImpl implements TaskBuilder
{
+ private InputSetImpl inputSet;
+ private OutputSetImpl outputSet;
+
public TaskBuilderImpl(ProcessBuilderImpl procBuilder)
{
super(procBuilder);
}
+ @Override
public TaskBuilder addMessageRef(String msgName)
{
TaskImpl taskImpl = getTask();
@@ -63,6 +73,46 @@
return this;
}
+ @Override
+ public TaskBuilder addInputSet()
+ {
+ inputSet = new InputSetImpl();
+ getTask().addInputSet(inputSet);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addPropertyInput(String name)
+ {
+ Property prop = new PropertyImpl(name, null);
+ inputSet.addProperty(prop);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addOutputSet()
+ {
+ outputSet = new OutputSetImpl();
+ getTask().addOutputSet(outputSet);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addPropertyOutput(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, value);
+ outputSet.addProperty(prop);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addIORule(String body, ExpressionLanguage lang)
+ {
+ ExpressionImpl expr = new ExpressionImpl(lang, body);
+ getTask().addIORule(expr);
+ return this;
+ }
+
private TaskImpl getTask()
{
if (node instanceof TaskImpl == false)
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,7 +23,9 @@
//$Id$
+import org.jbpm.api.model.InputSet;
import org.jbpm.api.model.Node;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.ExecutionContext;
import org.jbpm.api.runtime.Token;
@@ -68,6 +70,16 @@
return delegateToken.getTokenID();
}
+ public InputSet getInputSet()
+ {
+ return delegateToken.getInputSet();
+ }
+
+ public OutputSet getOutputSet()
+ {
+ return delegateToken.getOutputSet();
+ }
+
public TokenStatus getTokenStatus()
{
return delegateToken.getTokenStatus();
@@ -88,6 +100,16 @@
delegateToken.setTokenStatus(status);
}
+ public void setInputSet(InputSet inputSet)
+ {
+ delegateToken.setInputSet(inputSet);
+ }
+
+ public void setOutputSet(OutputSet outputSet)
+ {
+ delegateToken.setOutputSet(outputSet);
+ }
+
public String toString()
{
Node node = getFlow().getTargetRef();
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,8 @@
//$Id$
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.Token;
@@ -37,4 +39,8 @@
void setTokenStatus(TokenStatus status);
void setFlow(SequenceFlow flow);
+
+ void setOutputSet(OutputSet activeOutputSet);
+
+ void setInputSet(InputSet activeInputSet);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -24,6 +24,8 @@
//$Id$
import org.jboss.util.id.UID;
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.Attachments;
import org.jbpm.api.runtime.BasicExecutionContext;
@@ -48,6 +50,8 @@
private String id;
private SequenceFlow flow;
private ExecutionContext context;
+ private InputSet inputSet;
+ private OutputSet outputSet;
private TokenStatus status;
/**
@@ -65,6 +69,28 @@
return id;
}
+ @Override
+ public InputSet getInputSet()
+ {
+ return inputSet;
+ }
+
+ public void setInputSet(InputSet inputSet)
+ {
+ this.inputSet = inputSet;
+ }
+
+ @Override
+ public OutputSet getOutputSet()
+ {
+ return outputSet;
+ }
+
+ public void setOutputSet(OutputSet outputSet)
+ {
+ this.outputSet = outputSet;
+ }
+
public TokenStatus getTokenStatus()
{
return status;
More information about the jbpm-commits
mailing list