]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
Add generate script
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / DefaultExecutionFlowDescriptorConverter.java
index baa9b86a1d9a1daec12d0a44fa9884206ff87800..0e51cfeaa9b959b624f9c6e815e73c3334d9d7b2 100644 (file)
@@ -27,6 +27,9 @@ public class DefaultExecutionFlowDescriptorConverter implements
                ExecutionFlowDescriptorConverter, ApplicationContextAware {
        public final static String REF_VALUE_TYPE_BEAN_NAME = "beanName";
 
+       /** Workaround for https://www.spartadn.com/bugzilla/show_bug.cgi?id=206 */
+       private final static String REF_VALUE_IS_FROZEN = "[internal]";
+
        private final static Log log = LogFactory
                        .getLog(DefaultExecutionFlowDescriptorConverter.class);
 
@@ -36,9 +39,20 @@ public class DefaultExecutionFlowDescriptorConverter implements
                        ExecutionFlowDescriptor executionFlowDescriptor) {
                Map<String, Object> values = executionFlowDescriptor.getValues();
                Map<String, Object> convertedValues = new HashMap<String, Object>();
+               ExecutionSpec executionSpec = executionFlowDescriptor
+                               .getExecutionSpec();
+
+               if (executionSpec == null)
+                       log.warn("Execution spec is null for " + executionFlowDescriptor);
+
+               if (values != null && executionSpec != null) {
+                       values: for (String key : values.keySet()) {
+                               ExecutionSpecAttribute attribute = executionSpec
+                                               .getAttributes().get(key);
+
+                               if (attribute.getIsFrozen())
+                                       continue values;
 
-               if (values != null) {
-                       for (String key : values.keySet()) {
                                Object value = values.get(key);
                                if (value instanceof PrimitiveValue) {
                                        PrimitiveValue primitiveValue = (PrimitiveValue) value;
@@ -95,8 +109,12 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                                // all necessary information is in the spec
                                        }
                                } else if (attribute instanceof RefSpecAttribute) {
-                                       values.put(key, buildRefValue((RefSpecAttribute) attribute,
-                                                       executionFlow, key));
+                                       if (attribute.getIsFrozen()) {
+                                               values.put(key, new RefValue(REF_VALUE_IS_FROZEN));
+                                       } else
+                                               values.put(key, buildRefValue(
+                                                               (RefSpecAttribute) attribute, executionFlow,
+                                                               key));
                                } else {
                                        throw new SlcException("Unkown spec attribute type "
                                                        + attribute.getClass());
@@ -158,12 +176,15 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                        }
                                }
                        }
-                       if (ref == null)
+                       if (ref == null) {
                                log.warn("Cannot define reference for ref spec attribute "
-                                               + key + " in " + executionFlow + " (" + rsa + ")");
-                       else if (log.isDebugEnabled())
-                               log.debug(ref + " is the reference for ref spec attribute "
-                                               + key + " in " + executionFlow + " (" + rsa + ")");
+                                               + key + " in " + executionFlow + " (" + rsa + ")."
+                                               + " If it is an inner bean consider put it frozen.");
+                       } else {
+                               if (log.isDebugEnabled())
+                                       log.debug(ref + " is the reference for ref spec attribute "
+                                                       + key + " in " + executionFlow + " (" + rsa + ")");
+                       }
                        refValue.setRef(ref);
                }
                return refValue;