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() {
this.value = value;
}
+ /** Default is {@link String} */
public Class<?> getTargetClass() {
return targetClass;
}
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;
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,
&& !choice.getDescription().trim().equals(""))
choiceNode.setProperty(Property.JCR_DESCRIPTION,
choice.getDescription());
+ count++;
}
+
+ if (index != null)
+ attrNode.setProperty(SLC_VALUE, index);
}
}
}
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) {