summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Activity.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/Activity.java616
1 files changed, 212 insertions, 404 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
index a8a2016..54df25c 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java
@@ -1,5 +1,6 @@
package com.c2kernel.lifecycle.instance;
import java.util.ArrayList;
+import java.util.Map;
import java.util.Vector;
import com.c2kernel.common.AccessRightsException;
@@ -8,26 +9,27 @@ 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.entity.agent.Job;
import com.c2kernel.events.Event;
import com.c2kernel.events.History;
import com.c2kernel.graph.model.Vertex;
import com.c2kernel.lifecycle.WfCastorHashMap;
+import com.c2kernel.lifecycle.instance.stateMachine.State;
import com.c2kernel.lifecycle.instance.stateMachine.StateMachine;
-import com.c2kernel.lifecycle.instance.stateMachine.States;
-import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
+import com.c2kernel.lifecycle.instance.stateMachine.Transition;
import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.EntityPath;
-import com.c2kernel.lookup.InvalidEntityPathException;
import com.c2kernel.lookup.LDAPRoleManager;
import com.c2kernel.lookup.RolePath;
-import com.c2kernel.persistency.TransactionManager;
+import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Outcome;
+import com.c2kernel.persistency.outcome.Schema;
import com.c2kernel.persistency.outcome.Viewpoint;
import com.c2kernel.process.Gateway;
-import com.c2kernel.scripting.ScriptingEngineException;
import com.c2kernel.utils.DateUtility;
+import com.c2kernel.utils.LocalObjectLoader;
import com.c2kernel.utils.Logger;
+import com.c2kernel.utils.Resource;
/**
* @version $Revision: 1.222 $ $Date: 2005/10/05 07:39:37 $
* @author $Author: abranson $
@@ -40,54 +42,28 @@ public class Activity extends WfVertex
protected Vector<String> mErrors;
/** @associates a State machine engine */
private StateMachine machine;
- /** true is avalaibe to be executed */
+ protected int state = -1;
+ /** true is available to be executed */
public boolean active = false;
/** used in verify() */
private boolean loopTested;
- private GTimeStamp mStartDate;
- private GTimeStamp mActiveDate;
+ private GTimeStamp mStateDate;
private String mType;
- private EntityPath mEntityPath;
+
public Activity()
{
super();
setProperties(new WfCastorHashMap());
+ getProperties().put("StateMachineName", getDefaultSMName());
mErrors = new Vector<String>(0, 1);
- machine = new StateMachine(this);
- mStartDate = new GTimeStamp();
- mActiveDate = new GTimeStamp();
- DateUtility.setToNow(mActiveDate);
- DateUtility.setToNow(mStartDate);
- }
- /** @return the SystemKey of the item that contains the workflow */
- public EntityPath getItemEntityPath()
- {
- if (mEntityPath == null)
- try
- {
- Integer i = (Integer) (getWf().getProperties().get("ItemSystemKey"));
- if (i == null)
- return null; // no item yet
- EntityPath entityPath = new EntityPath(i.intValue());
- mEntityPath = entityPath;
- }
- catch (InvalidEntityPathException ex)
- {
- Logger.error("InvalidEntityPathException::Activity::getItemSystemKey() " + ex.toString());
- return null;
- }
- return mEntityPath;
- }
- /** @return the StateMachine */
- public StateMachine getMachine()
- {
- return machine;
+ mStateDate = new GTimeStamp();
+ DateUtility.setToNow(mStateDate);
}
- /** sets the StateMachine (Only for Serialisation) */
- public void setMachine(StateMachine sm)
- {
- machine = sm;
+
+ protected String getDefaultSMName() {
+ return "Default";
}
+
/** add the activity which id is idNext as next of the current one */
void addNext(String idNext)
{
@@ -101,153 +77,140 @@ public class Activity extends WfVertex
{
return new Next(this, vertex);
}
- /** return the current State of the State machine */
- public int getCurrentState()
- {
- return machine.getCurrentState();
+
+ public StateMachine getStateMachine() throws InvalidDataException {
+ if (machine == null) {
+ String name = (String)getProperties().get("StateMachineName");
+ int version = getVersionNumberProperty("StateMachineVersion");
+ try {
+ machine = LocalObjectLoader.getStateMachine(name, version);
+ } catch (ObjectNotFoundException ex) {
+ if (name.equals(getDefaultSMName()) && version == 0) { // default state machine not imported yet. Fake it.
+ try {
+ String marshalledSM = Resource.getTextResource(null, "boot/SM/"+getDefaultSMName()+".xml");
+ StateMachine bootstrap = (StateMachine)Gateway.getMarshaller().unmarshall(marshalledSM);
+ bootstrap.validate();
+ machine = bootstrap;
+ return bootstrap;
+ } catch (Exception ex2) {
+ Logger.error(ex2);
+ throw new InvalidDataException("Could not bootstrap default state machine from resources.", "");
+ }
+ }
+ Logger.error(ex);
+ throw new InvalidDataException("Error loading state machine '"+name+"' v"+version, "");
+ }
+ }
+ return machine;
}
+
/** return the current State of the State machine (Used in Serialisation) */
- public int getState()
- {
- if (machine == null)
- machine = new StateMachine(this);
- return getCurrentState();
- }
- /** Sets a new State in a State machine */
- public void setState(int stat)
+ public int getState() throws InvalidDataException
{
- if (machine == null)
- machine = new StateMachine(this);
- machine.state = stat;
+ if (state == -1)
+ state = getStateMachine().getInitialStateCode();
+ return state;
}
- /** check the abiltity of the agent passed in param to act on the activity */
- //return's the agentName
- public String checkAccessRights(AgentPath agent) throws AccessRightsException
+ public String getStateName() throws InvalidDataException
{
- String agentID = getCurrentAgentName();
- boolean authorised = agentID.equals(agent.getAgentName());
- String actRole = getCurrentAgentRole();
- if (!authorised)
- {
- authorised = actRole == null || actRole.equals("") || actRole.equals("all");
- }
- if (!authorised)
- {
- RolePath[] roles = agent.getRoles();
- for (int i = 0; !authorised && i < roles.length; i++)
- {
- if (roles[i].getName().equalsIgnoreCase("Admin"))
- authorised = true;
- if (roles[i].getName().equalsIgnoreCase(actRole))
- authorised = true;
- if (roles[i].getName().equalsIgnoreCase("Guest"))
- throw new AccessRightsException("Guest execution forbidden");
- }
- }
- if (!authorised)
- throw new AccessRightsException("Activity::checkAccessRights() - Agent does not hold the correct role.");
- return agent.getAgentName();
+ return getStateMachine().getState(getState()).getName();
}
- /** cf Item request */
- public void request(AgentPath agent, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException
+
+ /** Sets a new State */
+ public void setState(int state)
{
- int state = getState();
- String agentName = checkAccessRights(agent);
- if (machine.traverse(transitionID))
- {
- setReservation(transitionID, agentName);
- sendEventStoreOutcome(transitionID, requestData, agent);
- if (transitionID == Transitions.REPEAT)
- {
- setActive(true);
- if (getIsComposite())
- {
- WfVertex v = (WfVertex) ((CompositeActivity) this).search(getPath() + "/" + ((CompositeActivity) this).getChildGraphModel().getStartVertexId());
- v.reinit(getID());
- try
- {
- runfirst(agent);
- }
- catch (ScriptingEngineException e)
- {
- Logger.error(e);
- }
- }
- }
- if ((transitionID == Transitions.COMPLETE || transitionID == Transitions.DONE) &&
- (state == States.RSTARTED || getProperties().get("Breakpoint").equals(Boolean.TRUE)))
- setActive(false);
- else if (transitionID == Transitions.START)
- start();
- else if ((transitionID == Transitions.SKIP && getActive())
- || transitionID == Transitions.DONE
- || transitionID == Transitions.COMPLETE
- || transitionID == Transitions.PROCEED)
- try
- {
- runNext(agent);
- }
- catch (ScriptingEngineException e)
- {
- Logger.error(e);
- }
- // run post execution script now
- try
- {
- String postSubmitScr = (String) getProperties().get("PostExecScriptName");
- String postSubmitVer = (String) getProperties().get("PostExecScriptVersion");
- if (postSubmitScr != null && (transitionID == Transitions.COMPLETE || transitionID == Transitions.DONE))
- evaluateScript(postSubmitScr, postSubmitVer);
- }
- catch (ScriptingEngineException ex)
- {
- Logger.error(ex);
- }
- //refresh all the job lists
- pushJobsToAgents();
- }
- else
- throw new InvalidTransitionException("Activity is in the wrong state.");
+ this.state = state;
}
- public void setReservation(int transitionID, String agentName)
- {
- String actAgentName = (String) getProperties().get("Agent Name");
- switch (transitionID)
- {
- // these transition reserve the activity
- case Transitions.REASSIGN :
- case Transitions.RESERVE :
- case Transitions.START :
- actAgentName = agentName;
- break;
- // these clear any current reservation
- case Transitions.COMPLETE :
- case Transitions.DONE :
- case Transitions.IGNORE :
- case Transitions.SKIP :
- actAgentName = "";
- // other transitions have no effect on the reservations
- default :
- }
- getProperties().put("Agent Name", actAgentName);
+
+ public boolean isFinished() throws InvalidDataException {
+ return getStateMachine().getState(getState()).isFinished();
}
- public String getTransitions()
+
+
+ /** cf Item request
+ * @throws ObjectNotFoundException
+ * @throws PersistencyException */
+ public void request(AgentPath agent, int itemSysKey, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
{
- String result = "<PossibleTransitions>";
- int i;
- for (i = 0; i < machine.possibleTransition().length; i++)
- {
- result += machine.possibleTransition()[i] + ",";
+
+ // Find requested transition
+ Transition transition = getStateMachine().getTransition(transitionID);
+
+ // Check if the transition is possible
+ String usedRole = transition.getPerformingRole(this, agent);
+
+ // Verify outcome
+ Schema schema = null;
+ String viewName = null;
+ boolean storeOutcome = false;
+ if (transition.hasOutcome()) {
+ schema = transition.getSchema(getProperties());
+ viewName = (String)getProperties().get("Viewpoint");
+ if (requestData != null && requestData.length()>0)
+ storeOutcome = true;
+ else if (transition.getOutcome().isRequired())
+ throw new InvalidDataException("Transition requires outcome data, but none was given", null);
}
- //cuts out the last comma(',') if required
- if (i > 0)
- {
- result = result.substring(0, result.length() - 1);
+
+ // Get new state
+ State newState = getStateMachine().traverse(this, transition, agent);
+
+ // Run extra logic in predefined steps here
+ runActivityLogic(agent, itemSysKey, transitionID, requestData);
+
+ // set new state and reservation
+ setState(newState.getId());
+ getProperties().put("Agent Name", transition.getReservation(this, agent));
+
+ // store new event
+ Event newEvent = null;
+ try {
+ History hist = getWf().getHistory();
+ if (storeOutcome)
+ newEvent = hist.addEvent(agent.getAgentName(), usedRole, getName(), getPath(), getType(), schema.docType, schema.docVersion,
+ getStateMachine().getName(), getStateMachine().getVersion(), transition, viewName);
+ else
+ newEvent = hist.addEvent(agent.getAgentName(), usedRole, getName(), getPath(), getType(),
+ getStateMachine().getName(), getStateMachine().getVersion(), transition);
+
+ Logger.msg(7, "Activity::auditEvent() - Event:" + newEvent.getName() + " was added to the AuditTrail");
+
+ if (storeOutcome) {
+ Outcome newOutcome = new Outcome(newEvent.getID(), requestData, schema.docType, schema.docVersion);
+ Gateway.getStorage().put(itemSysKey, newOutcome, this);
+
+ // update specific view if defined
+ if (viewName != null && !viewName.equals("")) {
+ Viewpoint currentView = new Viewpoint(itemSysKey, schema.docType, viewName, schema.docVersion, newEvent.getID());
+ Gateway.getStorage().put(itemSysKey, currentView, this);
+ }
+ // update last view
+ Viewpoint currentView = new Viewpoint(itemSysKey, schema.docType, "last", schema.docVersion, newEvent.getID());
+ Gateway.getStorage().put(itemSysKey, currentView, this);
+ }
+ Gateway.getStorage().commit(this);
+ } catch (ClusterStorageException ex) {
+ Logger.error(ex);
+ throw new PersistencyException("Exception storing event data");
}
- result += "</PossibleTransitions>";
- return result;
+
+ if (newState.isFinished()) {
+ if (!getProperties().get("Breakpoint").equals(Boolean.TRUE))
+ runNext(agent, itemSysKey);
+ }
+
+ DateUtility.setToNow(mStateDate);
+
+ //refresh all the job lists
+ pushJobsToAgents(itemSysKey);
}
- /** launch the verification of the activity */
+
+ protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ int transitionID, String requestData) throws InvalidDataException {
+ // Overriden in predefined steps
+ return requestData;
+ }
+
@Override
public boolean verify()
{
@@ -310,9 +273,14 @@ public class Activity extends WfVertex
loopTested = false;
return loop2;
}
- /** sets the next activity available if possible */
+ /** sets the next activity available if possible
+ * @throws ObjectNotFoundException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws PersistencyException
+ * @throws ObjectAlreadyExistsException */
@Override
- public void runNext(AgentPath agent) throws ScriptingEngineException
+ public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
setActive(false);
try
@@ -336,7 +304,7 @@ public class Activity extends WfVertex
}
Logger.debug(8, outVertices + " " + outVertices2);
if (!hasNoNext)
- ((WfVertex) outVertices[0]).run(agent);
+ ((WfVertex) outVertices[0]).run(agent, itemSysKey);
else
{
if (getParent() != null && getParent().getName().equals("domain")) // workflow
@@ -346,11 +314,11 @@ public class Activity extends WfVertex
{
CompositeActivity parent = (CompositeActivity) getParent();
if (parent != null)
- parent.runNext(agent);
+ parent.runNext(agent, itemSysKey);
}
}
}
- catch (ScriptingEngineException s)
+ catch (InvalidDataException s)
{
setActive(true);
throw s;
@@ -364,13 +332,14 @@ public class Activity extends WfVertex
else
return null;
}
- /** reinitialises the Activity and propagate (for Loop) */
+ /** reinitialises the Activity and propagate (for Loop)
+ * @throws InvalidDataException
+ * @throws ObjectNotFoundException */
@Override
- public void reinit(int idLoop)
+ public void reinit(int idLoop) throws InvalidDataException
{
- Logger.debug(7, "reinit " + getItemEntityPath().getSysKey() + " " + getPath());
Vertex[] outVertices = getOutGraphables();
- machine.state = States.WAITING;
+ setState(getStateMachine().getInitialState().getId());
if (outVertices.length > 0)
{
WfVertex nextAct = (WfVertex) outVertices[0];
@@ -387,32 +356,44 @@ public class Activity extends WfVertex
}
/**
* called by precedent Activity runNext() for setting the activity able to be executed
+ * @throws InvalidDataException
+ * @throws ObjectAlreadyExistsException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws ObjectNotFoundException
+ * @throws PersistencyException
*/
@Override
- public void run(AgentPath agent) throws ScriptingEngineException
+ public void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
- Logger.debug(8, getPath() + " run " + getCurrentState());
- if (!getActive())
- setActive(true);
-
- if (getMachine().getCurrentState() == States.FINISHED)
+ Logger.debug(8, getPath() + " run " + getState());
+
+ if (!getActive()) setActive(true);
+ boolean finished = getStateMachine().getState(getState()).isFinished();
+ if (finished)
{
- runNext(agent);
+ runNext(agent, itemSysKey);
}
else
{
- DateUtility.setToNow(mActiveDate);
- pushJobsToAgents();
+ DateUtility.setToNow(mStateDate);
+ pushJobsToAgents(itemSysKey);
}
}
/**
* sets the activity available to be executed on start of Workflow or composite activity (when it is the first one of the (sub)process
+ * @throws InvalidDataException
+ * @throws ObjectAlreadyExistsException
+ * @throws ObjectNotFoundException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws PersistencyException
*/
@Override
- public void runfirst(AgentPath agent) throws ScriptingEngineException
+ public void runFirst(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
Logger.debug(8, getPath() + " runfirst");
- run(agent);
+ run(agent, itemSysKey);
}
/** @return the current ability to be executed */
public boolean getActive()
@@ -439,191 +420,35 @@ public class Activity extends WfVertex
{
return (String) getProperties().get("Agent Role");
}
- /**
- * @return an array of Steps that matches the querry
- * @param agentID
- * Agent concerned by the query
- * @param agentRole
- * Agent concerned by the query @int stateID state to test in the query, use -1 for all
- * @param filter
- * if tru will be filtered by agent, else won't
- */
- public Activity[] query(AgentPath agent, int stateID, boolean filter)
- {
- if (getCurrentState() == stateID || stateID == -1)
- {
- Activity[] steps = { this };
- if (!filter)
- return steps;
- else
- {
- try
- {
- checkAccessRights(agent);
- return steps;
- }
- catch (AccessRightsException e)
- {
- //case that agent is not allowed
- Logger.msg(7, "Activity :: AccessRightsException in " + this.getItemEntityPath() + "/" + this.getPath());
- }
- }
- }
- return new Activity[0];
- }
+
/**
* returns the lists of jobs for the activity and children (cf com.c2kernel.entity.Job)
*/
- public ArrayList<Job> calculateJobs(AgentPath agent, boolean recurse)
+ public ArrayList<Job> calculateJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
{
- return calculateJobsBase(agent, false);
+ return calculateJobsBase(agent, itemSysKey, false);
} //
- public ArrayList<Job> calculateAllJobs(AgentPath agent, boolean recurse)
+ public ArrayList<Job> calculateAllJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
{
- return calculateJobsBase(agent, true);
+ return calculateJobsBase(agent, itemSysKey, true);
}
- private ArrayList<Job> calculateJobsBase(AgentPath agent, boolean all)
+ private ArrayList<Job> calculateJobsBase(AgentPath agent, int itemSysKey, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException
{
Logger.msg(7, "calculateJobs - " + getPath());
- int[] transitions = {
- };
ArrayList<Job> jobs = new ArrayList<Job>();
- try
- {
- String agentName = checkAccessRights(agent);
- String currentAgentName = getCurrentAgentName();
- boolean isCurrent = currentAgentName == null || currentAgentName.equals("") || agentName.equals(currentAgentName);
- if ((all || getActive()) && !getName().equals("domain"))
- transitions = machine.possibleTransition();
- Logger.msg(7, "Activity.calculateJobs() - Got " + transitions.length + " transitions.");
- for (int i = 0; i < transitions.length; i++)
- {
- Logger.msg(7, "Creating Job object for transition " + transitions[i]);
- if ((isCurrent && !(transitions[i] == Transitions.REASSIGN && agentName.equals(currentAgentName))) || (transitions[i] == Transitions.REASSIGN && !agentName.equals(currentAgentName)))
- jobs.add(new Job(getItemEntityPath().getSysKey(), getPath(), transitions[i], getCurrentState(), machine.simulate(transitions[i]), getName(), getProperties(), getType(), agentName));
+ Map<Transition, String> transitions;
+ if ((includeInactive || getActive()) && !getName().equals("domain")) {
+ transitions = getStateMachine().getPossibleTransitions(this, agent);
+ Logger.msg(7, "Activity.calculateJobs() - Got " + transitions.size() + " transitions.");
+ for (Transition transition : transitions.keySet()) {
+ Logger.msg(7, "Creating Job object for transition " + transition);
+ jobs.add(new Job(this, itemSysKey, transition, agent, transitions.get(transition)));
}
}
- catch (AccessRightsException ex)
- {
- Logger.msg(6, "Agent "+ agent.getAgentName() +" is not allowed to interact with "+getItemEntityPath().getSysKey()+":"+getPath());
- } // empty joblist then
return jobs;
}
-
-
- /** Adds an event to the AuditTrail of the Item if any */
- private Event auditEvent(int transitionID, AgentPath agent, boolean hasOutcome, boolean isError)
- {
- EntityPath entityPath = getItemEntityPath();
- if (entityPath != null)
- {
- Event event = null;
- History hist = null;
- String viewName = hasOutcome?(String)getProperties().get("Viewpoint"):null;
- try
- {
- hist = getWf().getHistory();
- if (hasOutcome) {
- String schemaName = isError?"Errors":(String)getProperties().get("SchemaType");
- String schemaVersion = isError?"0":(String)getProperties().get("SchemaVersion");
- event = hist.addEvent(agent.getAgentName(), getCurrentAgentRole(), transitionID, getName(), getPath(), getType(), schemaName, Integer.valueOf(schemaVersion), viewName, getCurrentState());
- }
- else
- event = hist.addEvent(agent.getAgentName(), getCurrentAgentRole(), transitionID, getName(), getPath(), getType(), getCurrentState());
- Logger.msg(7, "Activity::auditEvent() - Event:" + event.getName() + " was added to the AuditTrail");
- }
- catch (Exception ex)
- {
- Logger.error("Activity::auditEvent() - Item '" + entityPath.toString() + "'!");
- Logger.error(ex);
- }
- return event;
- }
- else
- return null;
- }
-
- /**
- * Stores the request data as an outcome of the Item It does a great deal of storing outcomes in different configuration
- */ //requestdata is xmlstring
-
- private String storeOutcome(int eventID, String requestData, boolean isError) throws InvalidDataException
- {
- EntityPath entityPath = getItemEntityPath();
- if (requestData == null || requestData.length() == 0)
- throw new InvalidDataException("Empty outcome", "");
- if (entityPath != null)
- {
- String schemaType;
- int schemaVersion;
-
- if (isError) {
- schemaType="Errors";
- schemaVersion=0;
- }
- else {
- schemaType = (String) getProperties().get("SchemaType");
- if (schemaType == null || schemaType.length() == 0) return null;
- String versionString = (String) getProperties().get("SchemaVersion");
- try
- {
- schemaVersion = Integer.parseInt(versionString);
- } catch (Exception e) {
- throw new InvalidDataException("Activity.storeOutcome() - invalid schemaVersion " + versionString, "");
- }
- }
-
- Logger.msg(5, "Activity::storeOutcome() - type:" + schemaType + " version:" + schemaVersion);
- try
- {
- Object locker = getWf();
- Outcome newOutcome = new Outcome(eventID, requestData, schemaType, schemaVersion);
- Gateway.getStorage().put(entityPath.getSysKey(), newOutcome, locker);
- // update specific view if defined
- String specificView = (String) getProperties().get("Viewpoint");
- if (specificView != null && !specificView.equals(""))
- {
- Viewpoint currentView = new Viewpoint(entityPath.getSysKey(), schemaType, specificView, schemaVersion, eventID);
- Gateway.getStorage().put(entityPath.getSysKey(), currentView, locker);
- } // update last view
- Viewpoint currentView = new Viewpoint(entityPath.getSysKey(), schemaType, "last", schemaVersion, eventID);
- Gateway.getStorage().put(entityPath.getSysKey(), currentView, locker);
- return schemaType + "/" + schemaVersion + "/" + eventID;
- }
- catch (Exception ex)
- {
- Logger.error("ActivityBase::storeOutcome() - Item '" + entityPath.toString() + "'!");
- Logger.error(ex);
- }
- return null;
- }
- else
- return null;
- }
-
- /** the method to be called by the requestAction() method
- * @throws InvalidDataException */
- public void sendEventStoreOutcome(int transitionID, String requestData, AgentPath agent) throws InvalidDataException
- {
- int eventID = -1;
- String schemaType = (String) getProperties().get("SchemaType");
- boolean hasOutcome = (transitionID == Transitions.DONE || transitionID == Transitions.COMPLETE) && (schemaType != null && schemaType.length() > 0);
- boolean hasErrorOutcome = transitionID == Transitions.SUSPEND && requestData != null && requestData.length()>0;
- Object locker = getWf();
- Event event = auditEvent(transitionID, agent, hasOutcome, hasErrorOutcome);
- if (event != null)
- eventID = event.getID();
- if (hasOutcome || hasErrorOutcome)
- storeOutcome(eventID, requestData, hasErrorOutcome);
- EntityPath entityPath = getItemEntityPath();
- TransactionManager storage = Gateway.getStorage();
- if (entityPath != null)
- {
- storage.commit(locker);
- }
- }
- public void pushJobsToAgents()
+ public void pushJobsToAgents(int itemSysKey)
{
String agentRole = getCurrentAgentRole();
if (agentRole == null || agentRole.length()==0) return;
@@ -638,45 +463,33 @@ public class Activity extends WfVertex
}
if (myRole.hasJobList())
- new JobPusher(this, myRole).start();
+ new JobPusher(this, itemSysKey, myRole).start();
}
-
-
- /**
- * Returns the activeDate.
- *
- * @return GTimeStamp
- */
- public GTimeStamp getActiveDate()
- {
- return mActiveDate;
- } /**
+
+ /**
* Returns the startDate.
*
* @return GTimeStamp
*/
- public GTimeStamp getStartDate()
- {
- return mStartDate;
- } /**
- * Sets the activeDate.
- *
- * @param activeDate
- * The activeDate to set
- */
- public void setActiveDate(GTimeStamp activeDate)
+ public GTimeStamp getStateDate()
{
- mActiveDate = activeDate;
- } /**
- * Sets the startDate.
- *
- * @param startDate
- * The startDate to set
- */
- public void setStartDate(GTimeStamp startDate)
+ return mStateDate;
+ }
+ public void setStateDate(GTimeStamp startDate)
{
- mStartDate = startDate;
- } /**
+ mStateDate = startDate;
+ }
+
+ @Deprecated
+ public void setActiveDate(GTimeStamp date)
+ { }
+ @Deprecated
+ public void setStartDate(GTimeStamp date)
+ {
+ setStateDate(date);
+ }
+
+ /**
* Returns the type.
*
* @return String
@@ -694,10 +507,5 @@ public class Activity extends WfVertex
{
mType = type;
}
- private void start()
- {
- Logger.debug(8, getPath() + " start");
- DateUtility.setToNow(mStartDate);
- }
}