diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-09-09 12:13:21 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-09-09 12:13:21 +0200 |
| commit | da731d2bb81666b9c697d9099da632e7dfcdc0f7 (patch) | |
| tree | 567693c3c48f3d15ecbb2dac4f9db03bb6e58c72 /src/main/java/com/c2kernel/lifecycle/instance/Activity.java | |
| parent | ae1e79e33fd30e3d8bcedbef8891a14a048276d7 (diff) | |
Replaced int sysKey Item identifier with UUID, which is now portable.
ItemPath objects are now used to identify Items throughout the kernel,
replacing ints and Integers.
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Activity.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/instance/Activity.java | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index 88cbeb6..95e0ede 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -19,6 +19,8 @@ import com.c2kernel.lifecycle.instance.stateMachine.State; import com.c2kernel.lifecycle.instance.stateMachine.StateMachine;
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Outcome;
@@ -128,7 +130,7 @@ public class Activity extends WfVertex /** cf Item request
* @throws ObjectNotFoundException
* @throws PersistencyException */
- public String request(AgentPath agent, int itemSysKey, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
+ public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
{
// Find requested transition
@@ -154,7 +156,7 @@ public class Activity extends WfVertex State newState = getStateMachine().traverse(this, transition, agent);
// Run extra logic in predefined steps here
- String outcome = runActivityLogic(agent, itemSysKey, transitionID, requestData);
+ String outcome = runActivityLogic(agent, itemPath, transitionID, requestData);
// set new state and reservation
setState(newState.getId());
@@ -165,26 +167,26 @@ public class Activity extends WfVertex try {
History hist = getWf().getHistory();
if (storeOutcome)
- newEvent = hist.addEvent(agent.getAgentName(), usedRole, getName(), getPath(), getType(), schema.docType, schema.docVersion,
+ newEvent = hist.addEvent(agent, usedRole, getName(), getPath(), getType(), schema.docType, schema.docVersion,
getStateMachine().getName(), getStateMachine().getVersion(), transition, viewName);
else
- newEvent = hist.addEvent(agent.getAgentName(), usedRole, getName(), getPath(), getType(),
+ newEvent = hist.addEvent(agent, 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(), outcome, schema.docType, schema.docVersion);
- Gateway.getStorage().put(itemSysKey, newOutcome, getWf());
+ Gateway.getStorage().put(itemPath, newOutcome, getWf());
// 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, getWf());
+ Viewpoint currentView = new Viewpoint(itemPath, schema.docType, viewName, schema.docVersion, newEvent.getID());
+ Gateway.getStorage().put(itemPath, currentView, getWf());
}
// update last view
- Viewpoint currentView = new Viewpoint(itemSysKey, schema.docType, "last", schema.docVersion, newEvent.getID());
- Gateway.getStorage().put(itemSysKey, currentView, getWf());
+ Viewpoint currentView = new Viewpoint(itemPath, schema.docType, "last", schema.docVersion, newEvent.getID());
+ Gateway.getStorage().put(itemPath, currentView, getWf());
}
Gateway.getStorage().commit(getWf());
} catch (ClusterStorageException ex) {
@@ -195,18 +197,18 @@ public class Activity extends WfVertex if (newState.isFinished()) {
if (!getProperties().get("Breakpoint").equals(Boolean.TRUE))
- runNext(agent, itemSysKey);
+ runNext(agent, itemPath);
}
DateUtility.setToNow(mStateDate);
//refresh all the job lists
- pushJobsToAgents(itemSysKey);
+ pushJobsToAgents(itemPath);
return outcome;
}
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
int transitionID, String requestData) throws InvalidDataException {
// Overriden in predefined steps
return requestData;
@@ -281,7 +283,7 @@ public class Activity extends WfVertex * @throws PersistencyException
* @throws ObjectAlreadyExistsException */
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
setActive(false);
try
@@ -305,7 +307,7 @@ public class Activity extends WfVertex }
Logger.debug(8, outVertices + " " + outVertices2);
if (!hasNoNext)
- ((WfVertex) outVertices[0]).run(agent, itemSysKey);
+ ((WfVertex) outVertices[0]).run(agent, itemPath);
else
{
if (getParent() != null && getParent().getName().equals("domain")) // workflow
@@ -315,7 +317,7 @@ public class Activity extends WfVertex {
CompositeActivity parent = (CompositeActivity) getParent();
if (parent != null)
- parent.runNext(agent, itemSysKey);
+ parent.runNext(agent, itemPath);
}
}
}
@@ -365,7 +367,7 @@ public class Activity extends WfVertex * @throws PersistencyException
*/
@Override
- public void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
Logger.debug(8, getPath() + " run " + getState());
@@ -373,12 +375,12 @@ public class Activity extends WfVertex boolean finished = getStateMachine().getState(getState()).isFinished();
if (finished)
{
- runNext(agent, itemSysKey);
+ runNext(agent, itemPath);
}
else
{
DateUtility.setToNow(mStateDate);
- pushJobsToAgents(itemSysKey);
+ pushJobsToAgents(itemPath);
}
}
/**
@@ -391,10 +393,10 @@ public class Activity extends WfVertex * @throws PersistencyException
*/
@Override
- public void runFirst(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
Logger.debug(8, getPath() + " runfirst");
- run(agent, itemSysKey);
+ run(agent, itemPath);
}
/** @return the current ability to be executed */
public boolean getActive()
@@ -424,16 +426,17 @@ public class Activity extends WfVertex /**
* returns the lists of jobs for the activity and children (cf com.c2kernel.entity.Job)
+ * @throws InvalidAgentPathException
*/
- public ArrayList<Job> calculateJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
- return calculateJobsBase(agent, itemSysKey, false);
+ return calculateJobsBase(agent, itemPath, false);
} //
- public ArrayList<Job> calculateAllJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
- return calculateJobsBase(agent, itemSysKey, true);
+ return calculateJobsBase(agent, itemPath, true);
}
- private ArrayList<Job> calculateJobsBase(AgentPath agent, int itemSysKey, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException
+ private ArrayList<Job> calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
Logger.msg(7, "calculateJobs - " + getPath());
ArrayList<Job> jobs = new ArrayList<Job>();
@@ -443,13 +446,13 @@ public class Activity extends WfVertex 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)));
+ jobs.add(new Job(this, itemPath, transition, agent, transitions.get(transition)));
}
}
return jobs;
}
- public void pushJobsToAgents(int itemSysKey)
+ public void pushJobsToAgents(ItemPath itemPath)
{
String agentRole = getCurrentAgentRole();
if (agentRole == null || agentRole.length()==0) return;
@@ -463,7 +466,7 @@ public class Activity extends WfVertex }
if (myRole.hasJobList())
- new JobPusher(this, itemSysKey, myRole).start();
+ new JobPusher(this, itemPath, myRole).start();
}
/**
|
