Merge tag 'v2.3.15' into testing
[gpl/argeo-slc.git] / org.argeo.api.slc / src / org / argeo / api / slc / execution / RealizedFlow.java
diff --git a/org.argeo.api.slc/src/org/argeo/api/slc/execution/RealizedFlow.java b/org.argeo.api.slc/src/org/argeo/api/slc/execution/RealizedFlow.java
new file mode 100644 (file)
index 0000000..202a1a4
--- /dev/null
@@ -0,0 +1,71 @@
+package org.argeo.api.slc.execution;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.api.slc.DefaultNameVersion;
+import org.argeo.api.slc.NameVersion;
+
+/** A fully configured execution flow, ready to be executed. */
+public class RealizedFlow implements Serializable {
+       private static final long serialVersionUID = 1L;
+
+       private String moduleName;
+       private String moduleVersion;
+       private ExecutionFlowDescriptor flowDescriptor;
+
+       public String getModuleName() {
+               return moduleName;
+       }
+
+       public void setModuleName(String moduleName) {
+               this.moduleName = moduleName;
+       }
+
+       public NameVersion getModuleNameVersion() {
+               return new DefaultNameVersion(getModuleName(), getModuleVersion());
+       }
+
+       public String getModuleVersion() {
+               return moduleVersion;
+       }
+
+       public void setModuleVersion(String moduleVersion) {
+               this.moduleVersion = moduleVersion;
+       }
+
+       public ExecutionFlowDescriptor getFlowDescriptor() {
+               return flowDescriptor;
+       }
+
+       public void setFlowDescriptor(ExecutionFlowDescriptor flowDescriptor) {
+               this.flowDescriptor = flowDescriptor;
+       }
+
+       /** Create a simple realized flow */
+       public static RealizedFlow create(String module, String version,
+                       String flowName, Map<String, String> args) {
+               final RealizedFlow realizedFlow = new RealizedFlow();
+               realizedFlow.setModuleName(module);
+               // TODO deal with version
+               if (version == null)
+                       version = "0.0.0";
+               realizedFlow.setModuleVersion(version);
+               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
+               efd.setName(flowName);
+
+               // arguments
+               if (args != null && args.size() > 0) {
+                       Map<String, Object> values = new HashMap<String, Object>();
+                       for (String key : args.keySet()) {
+                               String value = args.get(key);
+                               values.put(key, value);
+                       }
+                       efd.setValues(values);
+               }
+
+               realizedFlow.setFlowDescriptor(efd);
+               return realizedFlow;
+       }
+}