summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java64
1 files changed, 40 insertions, 24 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java
index b74aac8..de5f56f 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java
@@ -4,10 +4,13 @@ package com.c2kernel.lifecycle.instance;
import java.util.HashMap;
+import com.c2kernel.common.AccessRightsException;
import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.graph.model.GraphableVertex;
-import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
import com.c2kernel.lifecycle.routingHelpers.ViewpointDataHelper;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.EntityPath;
@@ -25,8 +28,14 @@ import com.c2kernel.utils.Logger;
public abstract class WfVertex extends GraphableVertex
{
/**sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the
- * (sub)process*/
- public abstract void runfirst(AgentPath agent) throws ScriptingEngineException;
+ * (sub)process
+ * @throws InvalidDataException
+ * @throws ObjectAlreadyExistsException
+ * @throws ObjectNotFoundException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws PersistencyException */
+ public abstract void runFirst(AgentPath agent, int itemSysKey) throws ScriptingEngineException, InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, ObjectAlreadyExistsException, PersistencyException;
/**
* @see java.lang.Object#Object()
@@ -40,12 +49,18 @@ public abstract class WfVertex extends GraphableVertex
/**
* Method runNext.
+ * @throws InvalidDataException
+ * @throws ObjectNotFoundException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws PersistencyException
+ * @throws ObjectAlreadyExistsException
*/
- public void runNext(AgentPath agent) throws ScriptingEngineException
+ public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
try
{
- ((CompositeActivity)getParent()).request(agent, Transitions.COMPLETE, null);
+ ((CompositeActivity)getParent()).request(agent, itemSysKey, CompositeActivity.COMPLETE, null);
}
catch (Exception e)
{
@@ -57,8 +72,10 @@ public abstract class WfVertex extends GraphableVertex
/**
* Method reinit.
* @param idLoop
+ * @throws InvalidDataException
+ * @throws ObjectNotFoundException
*/
- public abstract void reinit( int idLoop );
+ public abstract void reinit( int idLoop ) throws InvalidDataException;
/**
* Method verify.
@@ -74,8 +91,14 @@ public abstract class WfVertex extends GraphableVertex
/**
* Method run.
+ * @throws InvalidDataException
+ * @throws ObjectAlreadyExistsException
+ * @throws ObjectNotFoundException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws PersistencyException
*/
- public abstract void run(AgentPath agent) throws ScriptingEngineException;
+ public abstract void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException;
/**
* Method loop.
@@ -89,12 +112,11 @@ public abstract class WfVertex extends GraphableVertex
*/
public abstract Next addNext(WfVertex vertex);
- protected Object evaluateScript(String scriptName, String scriptVersion) throws ScriptingEngineException
+ protected Object evaluateScript(String scriptName, Integer scriptVersion, int itemSysKey) throws ScriptingEngineException
{
try
{
- EntityPath entity = ((CompositeActivity) getParent()).getWf().getItemEntityPath();
Script script = getScript(scriptName, scriptVersion);
KeyValuePair[] k = getProperties().getKeyValuePairs();
@@ -109,7 +131,7 @@ public abstract class WfVertex extends GraphableVertex
{
value = value.substring(11);
if (value.startsWith("."))
- value = entity.getSysKey() + value.substring(1);
+ value = itemSysKey + value.substring(1);
try {
inputParam = ViewpointDataHelper.get(value)[0];
} catch (ArrayIndexOutOfBoundsException ex) {
@@ -120,7 +142,7 @@ public abstract class WfVertex extends GraphableVertex
{
value = value.substring(10);
try {
- inputParam = Gateway.getStorage().get(entity.getSysKey(), ClusterStorage.PROPERTY+"/"+value, null);
+ inputParam = Gateway.getStorage().get(itemSysKey, ClusterStorage.PROPERTY+"/"+value, null);
} catch (ObjectNotFoundException ex) {
inputParam = null;
}
@@ -131,7 +153,7 @@ public abstract class WfVertex extends GraphableVertex
}
if (requiredInput.containsKey("item")) {
- script.setInputParamValue("item", Gateway.getProxyManager().getProxy(entity));
+ script.setInputParamValue("item", Gateway.getProxyManager().getProxy(new EntityPath(itemSysKey)));
}
if (requiredInput.containsKey("agent")) {
AgentPath systemAgent = Gateway.getLDAPLookup().getRoleManager().getAgentPath("system");
@@ -150,24 +172,18 @@ public abstract class WfVertex extends GraphableVertex
}
}
- private static Script getScript(String name, String version) throws ScriptingEngineException
+ private static Script getScript(String name, Integer version) throws ScriptingEngineException
{
if (name == null || name.length() == 0)
throw new ScriptingEngineException("Script name is empty");
Script script;
- try
- {
- script = new Script(name, Integer.parseInt(version));
+ if (version!=null) {
+ Logger.debug(version.toString());
+ script = new Script(name, version);
}
- catch (NumberFormatException e)
- { // version not valid
+ else { // empty version: try expression
int split = name.indexOf(":");
- if (split > -1)
- {
- script = new Script(name.substring(0, split), name.substring(split + 1));
- }
- else
- throw new ScriptingEngineException("Script version is invalid");
+ script = new Script(name.substring(0, split), name.substring(split + 1));
}
return script;