From 659b2045881a49a5987c1e03a41e07799aeda4a8 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 12 Feb 2012 17:42:21 +0000 Subject: [PATCH] Fix various bugs with execution git-svn-id: https://svn.argeo.org/slc/trunk@5057 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../slc/client/ui/editors/ProcessBuilderPage.java | 2 +- .../argeo/slc/core/execution/RefSpecAttribute.java | 5 ++++- .../jcr/execution/JcrExecutionModulesListener.java | 13 ++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java index 0d4ae532a..676a0e053 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java @@ -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, diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/RefSpecAttribute.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/RefSpecAttribute.java index c6c5b035d..36bd8f53b 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/RefSpecAttribute.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/RefSpecAttribute.java @@ -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 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; } diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java index cefc67093..bc0b54bc3 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java @@ -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) { -- 2.39.2