diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2013-10-25 17:27:29 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2013-10-25 17:27:29 +0200 |
| commit | 0f892332b19ba8741a7db66a5c4daa386b2b5c1e (patch) | |
| tree | ed0733ed83862bf3bae1aa1c2cccec4d266e4813 /src/main/java/com/c2kernel/process | |
| parent | cf28baaf82d0941f938444bda5b39440b944ddfb (diff) | |
Changes and refactoring to gui requirements
Used descriptions must use an integer version.
Diffstat (limited to 'src/main/java/com/c2kernel/process')
| -rw-r--r-- | src/main/java/com/c2kernel/process/Bootstrap.java | 9 | ||||
| -rw-r--r-- | src/main/java/com/c2kernel/process/UserCodeProcess.java | 30 |
2 files changed, 13 insertions, 26 deletions
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index 93698e8..b334d59 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -15,9 +15,9 @@ import com.c2kernel.events.History; import com.c2kernel.lifecycle.CompositeActivityDef;
import com.c2kernel.lifecycle.instance.CompositeActivity;
import com.c2kernel.lifecycle.instance.Workflow;
-import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
import com.c2kernel.lifecycle.instance.predefined.ServerPredefinedStepContainer;
+import com.c2kernel.lifecycle.instance.stateMachine.Transition;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.EntityPath;
@@ -151,7 +151,8 @@ public class Bootstrap // data was missing or doesn't match
Logger.msg("Bootstrap.verifyResource() - Writing new version "+version+" to "+getDataType(itemType)+" "+itemName);
History hist = new History(thisProxy.getSystemKey(), thisProxy);
- Event newEvent = hist.addEvent("system", "Admin", PredefinedStep.DONE, "Bootstrap", "Bootstrap", "Bootstrap", getDataType(itemType), 0, String.valueOf(version), PredefinedStep.AVAILABLE);
+ Transition predefDone = new Transition(0, "Done", 0, 0);
+ Event newEvent = hist.addEvent("system", "Admin", "Bootstrap", "Bootstrap", "Bootstrap", getDataType(itemType), 0, "PredefinedStep", 0, predefDone, String.valueOf(version));
newOutcome.setID(newEvent.getID());
Viewpoint newLastView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), "last", 0, newEvent.getID());
Viewpoint newZeroView = new Viewpoint(thisProxy.getSystemKey(), getDataType(itemType), String.valueOf(version), 0, newEvent.getID());
@@ -185,7 +186,7 @@ public class Bootstrap else if (itemType.equals("OD")) wf = "ManageSchema";
else if (itemType.equals("SC")) wf = "ManageScript";
else throw new Exception("Unknown bootstrap item type: "+itemType);
- ca = (CompositeActivity) ((CompositeActivityDef)LocalObjectLoader.getActDef(wf, "last")).instantiate();
+ ca = (CompositeActivity) ((CompositeActivityDef)LocalObjectLoader.getActDef(wf, 0)).instantiate();
}
EntityPath entityPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey();
@@ -306,7 +307,7 @@ public class Bootstrap }
public static void initServerItemWf() throws Exception {
- CompositeActivityDef serverWfCa = (CompositeActivityDef)LocalObjectLoader.getActDef("ServerItemWorkflow", "last");
+ CompositeActivityDef serverWfCa = (CompositeActivityDef)LocalObjectLoader.getActDef("ServerItemWorkflow", 0);
Workflow wf = new Workflow((CompositeActivity)serverWfCa.instantiate());
PredefinedStepContainer predef = (PredefinedStepContainer)wf.search("workflow/predefined");
wf.getChildGraphModel().removeVertex(predef);
diff --git a/src/main/java/com/c2kernel/process/UserCodeProcess.java b/src/main/java/com/c2kernel/process/UserCodeProcess.java index f58da51..f7bbe74 100644 --- a/src/main/java/com/c2kernel/process/UserCodeProcess.java +++ b/src/main/java/com/c2kernel/process/UserCodeProcess.java @@ -85,8 +85,9 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv if (thisJob != null) {
String jobKey = thisJob.getItemSysKey()+":"+thisJob.getStepPath();
+ int transitionId = thisJob.getTransition().getId();
try {
- if (thisJob.getTransitionId()==START) {
+ if (transitionId==START) {
Logger.msg(5, "Testing start conditions");
boolean start = assessStartConditions(thisJob);
if (start) {
@@ -97,13 +98,13 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv Logger.msg(5, "Start conditions failed "+thisJob.getStepName()+" in "+thisJob.getItemSysKey());
}
}
- else if (thisJob.getTransitionId()==COMPLETE) {
+ else if (transitionId==COMPLETE) {
Logger.msg(5, "Executing logic");
runUCLogic(thisJob);
if (ignoredPaths.contains(jobKey))
ignoredPaths.remove(jobKey);
}
- else if (thisJob.getTransitionId()==SUSPEND) {
+ else if (transitionId==SUSPEND) {
if (ignoredPaths.contains(jobKey)) {
if (errors.containsKey(jobKey)) {
thisJob.setOutcome(Gateway.getMarshaller().marshall(errors.get(jobKey)));
@@ -112,7 +113,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv agent.execute(thisJob);
}
}
- else if (thisJob.getTransitionId()==RESUME) {
+ else if (transitionId==RESUME) {
if (!ignoredPaths.contains(jobKey))
agent.execute(thisJob);
}
@@ -122,7 +123,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv } catch (InvalidTransitionException ex) {
// must have already been done by someone else - ignore
} catch (Throwable ex) {
- Logger.error("Error executing "+getTransitionName(thisJob.getTransitionId())+" job:");
+ Logger.error("Error executing "+thisJob.getTransition().getName()+" job:");
Logger.error(ex);
ErrorInfo ei = new ErrorInfo();
ei.setFatal();
@@ -154,27 +155,12 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv }
}
- private static String getTransitionName(int transitionId) {
- switch (transitionId) {
- case 1:
- return "Start";
- case 2:
- return "Complete";
- case 3:
- return "Suspend";
- case 4:
- return "Resume";
- default:
- return "Unknown";
- }
- }
-
private static Job getJob(HashMap<String, C2KLocalObject> jobs, int transition) {
for (C2KLocalObject c2kLocalObject : jobs.values()) {
Job thisJob = (Job)c2kLocalObject;
- if (thisJob.getTransitionId() == transition) {
+ if (thisJob.getTransition().getId() == transition) {
Logger.msg(1,"=================================================================");
- Logger.msg(1, "Got "+getTransitionName(transition)+" job for "+thisJob.getStepName()+" in "+thisJob.getItemSysKey());
+ Logger.msg(1, "Got "+thisJob.getTransition().getName()+" job for "+thisJob.getStepName()+" in "+thisJob.getItemSysKey());
return thisJob;
}
}
|
