From da731d2bb81666b9c697d9099da632e7dfcdc0f7 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 9 Sep 2014 12:13:21 +0200 Subject: 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. --- .../com/c2kernel/lifecycle/instance/Workflow.java | 45 ++++++++++++++-------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Workflow.java') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java index 451d7fd..33c80a4 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java @@ -1,5 +1,6 @@ package com.c2kernel.lifecycle.instance; import java.util.ArrayList; +import java.util.UUID; import com.c2kernel.common.AccessRightsException; import com.c2kernel.common.InvalidDataException; @@ -14,6 +15,8 @@ import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.TypeNameAndConstructionInfo; import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer; import com.c2kernel.lookup.AgentPath; +import com.c2kernel.lookup.InvalidAgentPathException; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.utils.Language; import com.c2kernel.utils.Logger; @@ -24,7 +27,7 @@ import com.c2kernel.utils.Logger; public class Workflow extends CompositeActivity implements C2KLocalObject { public History history; - private Integer itemSysKey = null; + private ItemPath itemPath = null; /** TypeNameAndConstructionInfo[] variables added by Steve */ private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo = @@ -57,9 +60,9 @@ public class Workflow extends CompositeActivity implements C2KLocalObject public History getHistory() throws InvalidDataException { if (history == null) { - if (itemSysKey == null) + if (itemPath == null) throw new InvalidDataException("Workflow not initialized.", ""); - history = new History(itemSysKey, this); + history = new History(itemPath, this); } return history; } @@ -98,12 +101,12 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @throws PersistencyException */ //requestData is xmlstring - public String requestAction(AgentPath agent, String stepPath, int itemSysKey, int transitionID, String requestData) + public String requestAction(AgentPath agent, String stepPath, ItemPath itemPath, int transitionID, String requestData) throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException { - Logger.msg(3, "Action: " + transitionID + " " + stepPath + " by " + agent.getAgentName()); + Logger.msg(3, "Action: " + transitionID + " " + stepPath + " by " + agent); if (search(stepPath) != null) - return ((Activity) search(stepPath)).request(agent, itemSysKey, transitionID, requestData); + return ((Activity) search(stepPath)).request(agent, itemPath, transitionID, requestData); else throw new ObjectNotFoundException(stepPath + " not found", ""); } @@ -172,12 +175,12 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @throws AccessRightsException * @throws InvalidTransitionException */ - public void initialise(int systemKey, AgentPath agent) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException + public void initialise(ItemPath itemPath, AgentPath agent) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException { - itemSysKey = systemKey; + setItemPath(itemPath); try { - runFirst(agent, systemKey); + runFirst(agent, itemPath); } catch (InvalidDataException ex) { @@ -188,13 +191,22 @@ public class Workflow extends CompositeActivity implements C2KLocalObject } } - public Integer getItemSysKey() { - return itemSysKey; + public ItemPath getItemPath() { + return itemPath; } - public void setItemSysKey(Integer itemSysKey) { - this.itemSysKey = itemSysKey; + public void setItemPath(ItemPath itemPath) { + this.itemPath = itemPath; } + + public void setItemUUID( String uuid ) + { + setItemPath(new ItemPath(UUID.fromString(uuid))); + } + + public String getItemUUID() { + return getItemPath().getUUID().toString(); + } /** * if type = 0 only domain steps will be queried if type = 1 only predefined steps will be queried else both will be queried @@ -204,14 +216,15 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @return * @throws ObjectNotFoundException * @throws InvalidDataException + * @throws InvalidAgentPathException */ - public ArrayList calculateJobs(AgentPath agent, int itemSysKey, int type) throws ObjectNotFoundException, InvalidDataException + public ArrayList calculateJobs(AgentPath agent, ItemPath itemPath, int type) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException { ArrayList jobs = new ArrayList(); if (type != 1) - jobs.addAll(((CompositeActivity) search("workflow/domain")).calculateJobs(agent, itemSysKey, true)); + jobs.addAll(((CompositeActivity) search("workflow/domain")).calculateJobs(agent, itemPath, true)); if (type != 0) - jobs.addAll(((CompositeActivity) search("workflow/predefined")).calculateJobs(agent, itemSysKey, true)); + jobs.addAll(((CompositeActivity) search("workflow/predefined")).calculateJobs(agent, itemPath, true)); return jobs; } /** -- cgit v1.2.3