X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.api.slc%2Fsrc%2Forg%2Fargeo%2Fapi%2Fslc%2Fexecution%2FExecutionModuleDescriptor.java;fp=org.argeo.api.slc%2Fsrc%2Forg%2Fargeo%2Fapi%2Fslc%2Fexecution%2FExecutionModuleDescriptor.java;h=bc6a3ddf98ac0afc6f18e80cf255321c993dc115;hb=09c9e5093fe1353aaac344ac8a8caf2e1dcc0778;hp=0000000000000000000000000000000000000000;hpb=8ff996a3380166be2ae9cf0ef0fa22c58e11746a;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.api.slc/src/org/argeo/api/slc/execution/ExecutionModuleDescriptor.java b/org.argeo.api.slc/src/org/argeo/api/slc/execution/ExecutionModuleDescriptor.java new file mode 100644 index 000000000..bc6a3ddf9 --- /dev/null +++ b/org.argeo.api.slc/src/org/argeo/api/slc/execution/ExecutionModuleDescriptor.java @@ -0,0 +1,64 @@ +package org.argeo.api.slc.execution; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.argeo.api.slc.SlcException; +import org.argeo.api.slc.deploy.ModuleDescriptor; + +/** Describes the information required to launch a flow */ +public class ExecutionModuleDescriptor extends ModuleDescriptor { + /** Metadata header identifying an SLC execution module */ + public final static String SLC_EXECUTION_MODULE = "SLC-ExecutionModule"; + + private static final long serialVersionUID = -2394473464513029512L; + private List executionSpecs = new ArrayList(); + private List executionFlows = new ArrayList(); + + public List getExecutionSpecs() { + return executionSpecs; + } + + public List getExecutionFlows() { + return executionFlows; + } + + /** + * Returns a new {@link ExecutionModuleDescriptor} that can be used to build + * a {@link RealizedFlow}. + */ + public ExecutionFlowDescriptor cloneFlowDescriptor(String name) { + ExecutionFlowDescriptor res = null; + for (ExecutionFlowDescriptor efd : executionFlows) { + if (efd.getName().equals(name) + || ("/" + efd.getName()).equals(name)) { + try { + res = (ExecutionFlowDescriptor) efd.clone(); + } catch (CloneNotSupportedException e) { + throw new SlcException("Cannot clone " + efd, e); + } + } + } + if (res == null) + throw new SlcException("Flow " + name + " not found."); + return res; + } + + public RealizedFlow asRealizedFlow(String flow, Map values) { + RealizedFlow realizedFlow = new RealizedFlow(); + realizedFlow.setFlowDescriptor(cloneFlowDescriptor(flow)); + realizedFlow.setModuleName(getName()); + realizedFlow.setModuleVersion(getVersion()); + realizedFlow.getFlowDescriptor().getValues().putAll(values); + return realizedFlow; + } + + public void setExecutionSpecs(List executionSpecs) { + this.executionSpecs = executionSpecs; + } + + public void setExecutionFlows(List executionFlows) { + this.executionFlows = executionFlows; + } +}