Fix various bugs with execution
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 12 Feb 2012 17:42:21 +0000 (17:42 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 12 Feb 2012 17:42:21 +0000 (17:42 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5057 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/RefSpecAttribute.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java

index 0d4ae532acd476e1606c1bfc3331b7397086c225..676a0e053bd8d50ede8124b773692e541674ca90 100644 (file)
@@ -351,7 +351,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames {
                                                .getName());
                                JcrUtils.copy(specAttrNode, realizedAttrNode);
 
-                               // ovveride with flow value
+                               // override with flow value
                                if (flowNode.hasNode(attrName)) {
                                        // assuming this is a primitive
                                        realizedAttrNode.setProperty(SLC_VALUE,
index c6c5b035d08f601c77647f15d673d6fa5e13acb8..36bd8f53b2a961a8752a05abd553831860128643 100644 (file)
@@ -18,14 +18,16 @@ package org.argeo.slc.core.execution;
 
 import java.util.List;
 
+/** A spec attribute whose value is a reference to a full fledged object. */
 public class RefSpecAttribute extends AbstractSpecAttribute implements
                Cloneable {
        private static final long serialVersionUID = -3427797452955753574L;
-       private transient Class<?> targetClass;
+       private transient Class<?> targetClass = String.class;
        /** Read only. */
        private String targetClassName;
        private transient Object value = null;
 
+       /** List to be chosen from */
        private List<RefValueChoice> choices = null;
 
        public Object getValue() {
@@ -36,6 +38,7 @@ public class RefSpecAttribute extends AbstractSpecAttribute implements
                this.value = value;
        }
 
+       /** Default is {@link String} */
        public Class<?> getTargetClass() {
                return targetClass;
        }
index cefc67093e3a9476f716fa85fb39845f2ba0ed44..bc0b54bc380258189bb34af6c0377dfa55c6e4f5 100644 (file)
@@ -14,6 +14,7 @@ import javax.jcr.nodetype.NodeType;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.ArgeoNames;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
@@ -292,8 +293,14 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                                attrNode.addMixin(SlcTypes.SLC_REF_SPEC_ATTRIBUTE);
                                RefSpecAttribute rsa = (RefSpecAttribute) esa;
                                attrNode.setProperty(SLC_TYPE, rsa.getTargetClassName());
+                               Object value = rsa.getValue();
                                if (rsa.getChoices() != null) {
+                                       Integer index = null;
+                                       int count = 0;
                                        for (RefValueChoice choice : rsa.getChoices()) {
+                                               String name = choice.getName();
+                                               if (value != null && name.equals(value.toString()))
+                                                       index = count;
                                                Node choiceNode = attrNode.addNode(choice.getName());
                                                choiceNode.addMixin(NodeType.MIX_TITLE);
                                                choiceNode.setProperty(Property.JCR_TITLE,
@@ -302,7 +309,11 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                                                                && !choice.getDescription().trim().equals(""))
                                                        choiceNode.setProperty(Property.JCR_DESCRIPTION,
                                                                        choice.getDescription());
+                                               count++;
                                        }
+
+                                       if (index != null)
+                                               attrNode.setProperty(SLC_VALUE, index);
                                }
                        }
                }
@@ -315,7 +326,7 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                        Node moduleNode = agentNode.getNode(SlcJcrUtils
                                        .getModuleNodeName(module));
                        String relativePath = getExecutionFlowRelativePath(executionFlow);
-                       if (!moduleNode.hasNode(relativePath))
+                       if (moduleNode.hasNode(relativePath))
                                moduleNode.getNode(relativePath).remove();
                        agentNode.getSession().save();
                } catch (RepositoryException e) {