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. --- .../predefined/item/CreateItemFromDescription.java | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java index 728631c..60218e8 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java @@ -53,7 +53,7 @@ public class CreateItemFromDescription extends PredefinedStep //requestdata is xmlstring @Override - protected String runActivityLogic(AgentPath agent, int itemSysKey, + protected String runActivityLogic(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws InvalidDataException { String[] input = getDataList(requestData); @@ -65,17 +65,17 @@ public class CreateItemFromDescription extends PredefinedStep try { // check if the path is already taken DomainPath context = new DomainPath(new DomainPath(domPath), newName); - Logger.debug(8,"context "+context.getSysKey()+" "+context.getPath()+" "+context.getString()); - if (context.getSysKey()!=-1) - throw new ObjectAlreadyExistsException("The item name " +newName+ " exists already.", ""); + //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString()); + if (context.exists()) + throw new ObjectAlreadyExistsException("The path " +context+ " exists already.", ""); // get init objects /* ITEM CREATION */ // generate new entity key - Logger.msg(6, "CreateItemFromDescription - Requesting new sysKey"); - ItemPath entityPath = Gateway.getNextKeyManager().generateNextEntityKey(); + Logger.msg(6, "CreateItemFromDescription - Requesting new item path"); + ItemPath newItemPath = new ItemPath(); // resolve the item factory Logger.msg(6, "CreateItemFromDescription - Resolving item factory"); @@ -84,8 +84,8 @@ public class CreateItemFromDescription extends PredefinedStep Logger.msg(3, "CreateItemFromDescription - Creating Item"); CorbaServer factory = Gateway.getCorbaServer(); if (factory == null) throw new AccessRightsException("This process cannot create new Items", ""); - TraceableEntity newItem = (TraceableEntity)factory.createEntity(entityPath); - Gateway.getLookupManager().add(entityPath); + TraceableEntity newItem = factory.createItem(newItemPath); + Gateway.getLookupManager().add(newItemPath); // initialise it with its properties and workflow @@ -93,15 +93,15 @@ public class CreateItemFromDescription extends PredefinedStep Logger.msg(3, "CreateItemFromDescription - Initializing Item"); newItem.initialise( - agent.getSysKey(), - Gateway.getMarshaller().marshall(getNewProperties(itemSysKey, newName, agent)), - Gateway.getMarshaller().marshall(getNewWorkflow(itemSysKey)), - Gateway.getMarshaller().marshall(getNewCollections(itemSysKey)) + agent.getSystemKey(), + Gateway.getMarshaller().marshall(getNewProperties(itemPath, newName, agent)), + Gateway.getMarshaller().marshall(getNewWorkflow(itemPath)), + Gateway.getMarshaller().marshall(getNewCollections(itemPath)) ); // add its domain path Logger.msg(3, "CreateItemFromDescription - Creating "+context); - context.setEntity(entityPath); + context.setEntity(newItemPath); Gateway.getLookupManager().add(context); return requestData; } catch (Exception e) { @@ -111,9 +111,9 @@ public class CreateItemFromDescription extends PredefinedStep } - protected PropertyArrayList getNewProperties(int itemSysKey, String newName, AgentPath agent) throws ObjectNotFoundException { + protected PropertyArrayList getNewProperties(ItemPath itemPath, String newName, AgentPath agent) throws ObjectNotFoundException { // copy properties -- intend to create from propdesc - PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemSysKey); + PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemPath); PropertyArrayList props = pdList.instanciate(); // set Name prop or create if not present boolean foundName = false; @@ -128,13 +128,13 @@ public class CreateItemFromDescription extends PredefinedStep return props; } - protected CompositeActivity getNewWorkflow(int itemSysKey) throws ClusterStorageException, ObjectNotFoundException, InvalidDataException { + protected CompositeActivity getNewWorkflow(ItemPath itemPath) throws ClusterStorageException, ObjectNotFoundException, InvalidDataException { // loop through collections, collecting instantiated descriptions and finding the default workflow def - String[] collNames = Gateway.getStorage().getClusterContents(itemSysKey, ClusterStorage.COLLECTION); + String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION); String wfDefName = null; Integer wfDefVer = null; for (String collName : collNames) { if (collName.equalsIgnoreCase("workflow")) { - Collection thisCol = (Collection)Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null); + Collection thisCol = (Collection)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/"+collName, null); ArrayList members = thisCol.getMembers().list; // get the first member from the wf collection CollectionMember wfMember = members.get(0); @@ -164,12 +164,12 @@ public class CreateItemFromDescription extends PredefinedStep } } - protected CollectionArrayList getNewCollections(int itemSysKey) throws ClusterStorageException, ObjectNotFoundException { + protected CollectionArrayList getNewCollections(ItemPath itemPath) throws ClusterStorageException, ObjectNotFoundException { // loop through collections, collecting instantiated descriptions and finding the default workflow def CollectionArrayList colls = new CollectionArrayList(); - String[] collNames = Gateway.getStorage().getClusterContents(itemSysKey, ClusterStorage.COLLECTION); + String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION); for (String collName : collNames) { - Collection thisCol = (Collection)Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null); + Collection thisCol = (Collection)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/"+collName, null); if (thisCol instanceof CollectionDescription) { CollectionDescription thisDesc = (CollectionDescription)thisCol; colls.put(thisDesc.newInstance()); -- cgit v1.2.3