From 11e7a9aaed7c22ec93a791ea752e159b4b120e4e Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 4 Apr 2014 17:26:10 +0200 Subject: Module XML now supports a workflowVer attribute for the Item element. If not given, it assumed version 0, as per the previous behaviour. Fixes #180 --- .../predefined/entitycreation/NewItem.java | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index 5f8cf12..07b8462 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -39,6 +39,7 @@ public class NewItem extends ModuleImport { public String initialPath; public String workflow; + public Integer workflowVer; public ArrayList properties = new ArrayList(); public ArrayList aggregationList = new ArrayList(); public ArrayList dependencyList = new ArrayList(); @@ -48,11 +49,12 @@ public class NewItem extends ModuleImport { public NewItem() { } - public NewItem(String name, String initialPath, String wf) { + public NewItem(String name, String initialPath, String wf, int wfVer) { this(); this.name = name; this.initialPath = initialPath; this.workflow = wf; + this.workflowVer = wfVer; } public void setNamespace(String ns) { @@ -82,11 +84,22 @@ public class NewItem extends ModuleImport { // set the name property properties.add(new Property("Name", name, true)); - // init the new item + // find workflow def + CompositeActivityDef compact; + // default workflow version is 0 if not given + int usedWfVer; + if (workflowVer == null) usedWfVer = 0; + else usedWfVer = workflowVer.intValue(); try { - - // find workflow def - CompositeActivityDef compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, 0); + compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, usedWfVer); + } catch (ObjectNotFoundException ex) { + throw new CannotManageException("Could not find workflow "+workflow+"v"+usedWfVer+" for item "+domPath, ""); + } catch (InvalidDataException e) { + throw new CannotManageException("Workflow def "+workflow+" v"+usedWfVer+" for item "+domPath+" was not valid", ""); + } + + try { + // initialise the new item with workflow and properties newItem.initialise( agentId, Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), -- cgit v1.2.3