summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/entity/agent
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/entity/agent')
-rw-r--r--src/main/java/com/c2kernel/entity/agent/ActiveEntity.java2
-rw-r--r--src/main/java/com/c2kernel/entity/agent/Job.java177
2 files changed, 56 insertions, 123 deletions
diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java
index 4c14cff..8d4dbfd 100644
--- a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java
+++ b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java
@@ -247,7 +247,7 @@ public class ActiveEntity extends AgentPOA
// merge new jobs in
for (Object name : newJobList.list) {
Job newJob = (Job)name;
- Logger.msg(6, "Adding job for "+newJob.getItemSysKey()+"/"+newJob.getStepPath()+":"+newJob.getTransitionId());
+ Logger.msg(6, "Adding job for "+newJob.getItemSysKey()+"/"+newJob.getStepPath()+":"+newJob.getTransition().getId());
currentJobs.addJob(newJob);
}
diff --git a/src/main/java/com/c2kernel/entity/agent/Job.java b/src/main/java/com/c2kernel/entity/agent/Job.java
index 715ee9c..5f9e6dc 100644
--- a/src/main/java/com/c2kernel/entity/agent/Job.java
+++ b/src/main/java/com/c2kernel/entity/agent/Job.java
@@ -39,26 +39,16 @@ public class Job implements C2KLocalObject
private String stepType;
- private int transitionId;
-
- private int currentStateId;
-
- private int targetStateId;
+ private Transition transition;
+
+ private String originStateName;
+
+ private String targetStateName;
private int agentId = -1;
private String agentRole;
- private String schemaName;
-
- private int schemaVersion;
-
- private boolean outcomeRequired;
-
- private String scriptName;
-
- private int scriptVersion;
-
private CastorHashMap actProps = new CastorHashMap();
// non-persistent
@@ -88,32 +78,36 @@ public class Job implements C2KLocalObject
setItemSysKey(itemSysKey);
setStepPath(act.getPath());
- setTransitionId(transition.getId());
- setCurrentStateId(transition.getOriginStateId());
- setTargetStateId(transition.getTargetStateId());
+ setTransition(transition);
+ setOriginStateName(act.getStateMachine().getState(transition.getOriginStateId()).getName());
+ setTargetStateName(act.getStateMachine().getState(transition.getTargetStateId()).getName());
setStepName(act.getName());
setActProps(act.getProperties());
setStepType(act.getType());
setAgentName(agent.getAgentName());
setAgentRole(role);
-
- if (transition.hasOutcome()) {
- Schema schema = transition.getSchema(act.getProperties());
- setSchemaName(schema.docType);
- setSchemaVersion(schema.docVersion);
- outcomeRequired = transition.getOutcome().isRequired();
- }
-
- if (transition.hasScript()) {
- setScriptName(transition.getScript().getScriptName());
- setScriptVersion(Integer.parseInt(transition.getScript().getScriptVersion()));
- }
}
// Castor persistent fields
- public int getId() {
+ public String getOriginStateName() {
+ return originStateName;
+ }
+
+ public void setOriginStateName(String originStateName) {
+ this.originStateName = originStateName;
+ }
+
+ public String getTargetStateName() {
+ return targetStateName;
+ }
+
+ public void setTargetStateName(String targetStateName) {
+ this.targetStateName = targetStateName;
+ }
+
+ public int getId() {
return id;
}
@@ -155,29 +149,13 @@ public class Job implements C2KLocalObject
stepType = actType;
}
- public int getTransitionId() {
- return transitionId;
- }
-
- public void setTransitionId(int tid) {
- transitionId = tid;
+ public Transition getTransition() {
+ return transition;
}
- public int getCurrentStateId() {
- return currentStateId;
+ public void setTransition(Transition transition) {
+ this.transition = transition;
}
-
- public void setCurrentStateId(int stateId) {
- currentStateId = stateId;
- }
-
- public int getTargetStateId() {
- return targetStateId;
- }
-
- public void setTargetStateId(int targetStateId) {
- this.targetStateId = targetStateId;
- }
public int getAgentId() throws ObjectNotFoundException {
if (agentId == -1)
@@ -210,45 +188,39 @@ public class Job implements C2KLocalObject
agentRole = role;
}
- public String getSchemaName() {
- return schemaName;
- }
-
- public void setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- }
-
- public int getSchemaVersion() {
- return schemaVersion;
+ public String getSchemaName() throws InvalidDataException, ObjectNotFoundException {
+ if (transition.hasOutcome()) {
+ Schema schema = transition.getSchema(actProps);
+ return schema.docType;
+ }
+ return null;
}
- public void setSchemaVersion(int schemaVersion) {
- this.schemaVersion = schemaVersion;
+ public int getSchemaVersion() throws InvalidDataException, ObjectNotFoundException {
+ if (transition.hasOutcome()) {
+ Schema schema = transition.getSchema(actProps);
+ return schema.docVersion;
+ }
+ return -1;
}
public boolean isOutcomeRequired()
{
- return outcomeRequired;
- }
-
- public void setOutcomeRequired(boolean outcomeRequired) {
- this.outcomeRequired = outcomeRequired;
+ return transition.hasOutcome() && transition.getOutcome().isRequired();
}
public String getScriptName() {
- return scriptName;
- }
-
- public void setScriptName(String scriptName) {
- this.scriptName = scriptName;
+ if (transition.hasScript()) {
+ return transition.getScript().getScriptName();
+ }
+ return null;
}
- public int getScriptVersion() {
- return scriptVersion;
- }
-
- public void setScriptVersion(int scriptVersion) {
- this.scriptVersion = scriptVersion;
+ public int getScriptVersion() throws InvalidDataException {
+ if (transition.hasScript()) {
+ return transition.getScriptVersion(actProps);
+ }
+ return -1;
}
public KeyValuePair[] getKeyValuePairs() {
@@ -334,17 +306,17 @@ public class Job implements C2KLocalObject
return outcomeData;
}
- public Outcome getOutcome()
+ public Outcome getOutcome() throws InvalidDataException, ObjectNotFoundException
{
return new Outcome(-1, getOutcomeString(), getSchemaName(), getSchemaVersion());
}
public boolean hasOutcome() {
- return schemaName!=null;
+ return transition.hasOutcome();
}
public boolean hasScript() {
- return scriptName!=null;
+ return transition.hasScript();
}
public boolean isOutcomeSet() {
@@ -359,7 +331,7 @@ public class Job implements C2KLocalObject
public boolean equals(Job job)
{
- return (getItemSysKey() == job.getItemSysKey()) && this.stepPath.equals(job.stepPath) && this.transitionId == job.transitionId;
+ return (getItemSysKey() == job.getItemSysKey()) && this.stepPath.equals(job.stepPath) && transition.getId() == job.getTransition().getId();
}
private void setActProps(CastorHashMap actProps) {
@@ -375,43 +347,4 @@ public class Job implements C2KLocalObject
{
return String.valueOf(actProps.get(name));
}
-
-
- // Deprecated methods from old state machine
-
- @Deprecated
- public String getSchemaType()
- {
- return getSchemaName();
- }
-
- @Deprecated
- public int getPossibleTransition()
- {
- return transitionId;
- }
-
- @Deprecated
- public void setPossibleTransition(int lint)
- {
- transitionId = lint;
- }
-
- @Deprecated
- public CastorHashMap getActProps()
- {
- return actProps;
- }
-
- @Deprecated
- public int getCurrentState()
- {
- return getCurrentStateId();
- }
-
- @Deprecated
- public int getTargetState() {
- return getTargetStateId();
- }
-
} \ No newline at end of file