From 0f892332b19ba8741a7db66a5c4daa386b2b5c1e Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 25 Oct 2013 17:27:29 +0200 Subject: Changes and refactoring to gui requirements Used descriptions must use an integer version. --- .../com/c2kernel/entity/agent/ActiveEntity.java | 2 +- src/main/java/com/c2kernel/entity/agent/Job.java | 177 +++++++-------------- .../java/com/c2kernel/entity/proxy/ItemProxy.java | 10 +- 3 files changed, 61 insertions(+), 128 deletions(-) (limited to 'src/main/java/com/c2kernel/entity') 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 diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java index 1740159..ceea6c3 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java @@ -107,10 +107,10 @@ public class ItemProxy extends EntityProxy ObjectAlreadyExistsException { String outcome = thisJob.getOutcomeString(); - // check fields that should have been filled in - if (outcome==null) - if (thisJob.isOutcomeRequired()) - throw new InvalidDataException("Outcome is required.", ""); + // check fields that should have been filled in + if (outcome==null) + if (thisJob.isOutcomeRequired()) + throw new InvalidDataException("Outcome is required.", ""); else outcome=""; @@ -119,7 +119,7 @@ public class ItemProxy extends EntityProxy Logger.msg(7, "ItemProxy - executing "+thisJob.getStepPath()+" for "+thisJob.getAgentName()); requestAction (thisJob.getAgentId(), thisJob.getStepPath(), - thisJob.getTransitionId(), outcome); + thisJob.getTransition().getId(), outcome); } //requestData is xmlString -- cgit v1.2.3