]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/SimpleExecutionFlow.java
Make OSGi and ActiveMQ compatible
[gpl/argeo-slc.git] / runtime / org.argeo.slc.execution / src / main / java / org / argeo / slc / execution / SimpleExecutionFlow.java
index 34018ee9b5ba076b5b193f3419cfc0bb3b0ca619..79f900d023e9b3ef4a070ce8407c2e2f0ae0df6f 100644 (file)
@@ -21,7 +21,13 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
        private Map<String, Object> parameters = new HashMap<String, Object>();
        private List<Executable> executables = new ArrayList<Executable>();
 
-       private final String uuid = UUID.randomUUID().toString();
+       public SimpleExecutionFlow() {
+
+       }
+
+       public SimpleExecutionFlow(Map<String, Object> parameters) {
+               this.parameters.putAll(parameters);
+       }
 
        public void execute() {
                for (Executable executable : executables) {
@@ -35,7 +41,7 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
                        return;
 
                MapBindingResult errors = new MapBindingResult(parameters, "execution#"
-                               + getUuid());
+                               + getName());
                for (String key : executionSpec.getAttributes().keySet()) {
                        ExecutionSpecAttribute executionSpecAttr = executionSpec
                                        .getAttributes().get(key);
@@ -49,6 +55,7 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
                                Object obj = parameters.get(key);
                                if (executionSpecAttr instanceof RefSpecAttribute) {
                                        RefSpecAttribute rsa = (RefSpecAttribute) executionSpecAttr;
+                                       // TODO: make sure this will not cause pb with OSGi
                                        Class targetClass = rsa.getTargetClass();
                                        if (!targetClass.isAssignableFrom(obj.getClass())) {
                                                errors.reject(key
@@ -80,8 +87,8 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
                this.parameters = attributes;
        }
 
-       public String getUuid() {
-               return uuid;
+       public String getName() {
+               return name;
        }
 
        public ExecutionSpec getExecutionSpec() {
@@ -99,7 +106,7 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
                                        return esa.getValue();
                        } else {
                                throw new SlcException("Key " + name
-                                               + " is not define in the specifications of "
+                                               + " is not defined in the specifications of "
                                                + toString());
                        }
                }
@@ -108,7 +115,10 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
        }
 
        public String toString() {
-               return new StringBuffer("Flow ").append(name).toString();// .append(" [#")
-               // .append(uuid).append(']').toString();
+               return new StringBuffer("Flow ").append(name).toString();
+       }
+
+       public boolean equals(Object obj) {
+               return ((ExecutionFlow) obj).getName().equals(name);
        }
 }