]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java
Work in progress - work on modular distributions.
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.jcr / src / main / java / org / argeo / slc / jcr / execution / JcrExecutionModulesListener.java
index 473dcb343434fc7a7a055624bafeed08fc1f5de9..ea734a8bbd6da7eed8c427b5321b7e74af6e5832 100644 (file)
@@ -243,8 +243,9 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                        String relativePath, ExecutionFlowDescriptor efd)
                        throws RepositoryException {
                Node flowNode = null;
-               Iterator<String> names = Arrays.asList(relativePath.split("/"))
-                               .iterator();
+               List<String> pathTokens = Arrays.asList(relativePath.split("/"));
+
+               Iterator<String> names = pathTokens.iterator();
                // create intermediary paths
                Node currNode = moduleNode;
                while (names.hasNext()) {
@@ -262,8 +263,7 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
 
                // name, description
                flowNode.setProperty(SLC_NAME, efd.getName());
-               String[] tokens = relativePath.split("/");
-               String endName = tokens[tokens.length - 1];
+               String endName = pathTokens.get(pathTokens.size() - 1);
                flowNode.setProperty(Property.JCR_TITLE, endName);
                if (efd.getDescription() != null
                                && !efd.getDescription().trim().equals("")) {
@@ -296,13 +296,14 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                        flowNode.setProperty(SLC_SPEC, executionSpecNode);
                }
 
-               // values
+               // flow values
                for (String attr : efd.getValues().keySet()) {
                        ExecutionSpecAttribute esa = executionSpec.getAttributes()
                                        .get(attr);
                        if (esa instanceof PrimitiveSpecAttribute) {
                                PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
-                               Node valueNode = flowNode.addNode(attr);
+                               // if spec reference there will be no node at this stage
+                               Node valueNode = JcrUtils.getOrAdd(flowNode, attr);
                                valueNode.setProperty(SLC_TYPE, psa.getType());
                                SlcJcrUtils.setPrimitiveAsProperty(valueNode, SLC_VALUE,
                                                (PrimitiveValue) efd.getValues().get(attr));