]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
Minimal Hello World execution module
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / DefaultExecutionFlowDescriptorConverter.java
index 277e4df0c93ab52a892f894343770ab4262a7e74..27929b4b6fbaff5b34e7a62e8cf6f4ccf398a2a0 100644 (file)
@@ -40,7 +40,6 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.util.Assert;
 import org.springframework.util.StringUtils;
 
 /**
@@ -59,6 +58,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
 
        private ApplicationContext applicationContext;
 
+       @SuppressWarnings("unused")
        public Map<String, Object> convertValues(
                        ExecutionFlowDescriptor executionFlowDescriptor) {
                Map<String, Object> values = executionFlowDescriptor.getValues();
@@ -74,7 +74,11 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                ExecutionSpecAttribute attribute = executionSpec
                                                .getAttributes().get(key);
 
-                               if (attribute.getIsFrozen())
+                               if (attribute == null)
+                                       throw new SlcException("No spec attribute defined for '"
+                                                       + key + "'");
+
+                               if (attribute.getIsConstant())
                                        continue values;
 
                                Object value = values.get(key);
@@ -130,6 +134,8 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                                throw new UnsupportedException("Ref value type",
                                                                refValue.getType());
                                        }
+                               } else {
+                                       convertedValues.put(key, value);
                                }
                        }
                }
@@ -157,14 +163,19 @@ public class DefaultExecutionFlowDescriptorConverter implements
                md.getExecutionFlows().addAll(set);
        }
 
+       @SuppressWarnings("deprecation")
        public ExecutionFlowDescriptor getExecutionFlowDescriptor(
                        ExecutionFlow executionFlow) {
-               Assert.notNull(executionFlow.getName());
+               if (executionFlow.getName() == null)
+                       throw new SlcException("Flow name is null: " + executionFlow);
                String name = executionFlow.getName();
 
                ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
-               Assert.notNull(executionSpec);
-               Assert.notNull(executionSpec.getName());
+               if (executionSpec == null)
+                       throw new SlcException("Execution spec is null: " + executionFlow);
+               if (executionSpec.getName() == null)
+                       throw new SlcException("Execution spec name is null: "
+                                       + executionSpec);
 
                Map<String, Object> values = new TreeMap<String, Object>();
                for (String key : executionSpec.getAttributes().keySet()) {
@@ -184,7 +195,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
                                        // all necessary information is in the spec
                                }
                        } else if (attribute instanceof RefSpecAttribute) {
-                               if (attribute.getIsFrozen()) {
+                               if (attribute.getIsConstant()) {
                                        values.put(key, new RefValue(REF_VALUE_INTERNAL));
                                } else
                                        values.put(
@@ -217,7 +228,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
                RefValue refValue = new RefValue();
                // FIXME: UI should be able to deal with other types
                refValue.setType(REF_VALUE_TYPE_BEAN_NAME);
-               Class targetClass = rsa.getTargetClass();
+               Class<?> targetClass = rsa.getTargetClass();
                String primitiveType = PrimitiveUtils.classAsType(targetClass);
                if (primitiveType != null) {
                        if (executionFlow.isSetAsParameter(key)) {
@@ -288,6 +299,7 @@ public class DefaultExecutionFlowDescriptorConverter implements
 
        private static class ExecutionFlowDescriptorComparator implements
                        Comparator<ExecutionFlowDescriptor> {
+               @SuppressWarnings("deprecation")
                public int compare(ExecutionFlowDescriptor o1,
                                ExecutionFlowDescriptor o2) {
                        // TODO: write unit tests for this