]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java
Improve publishing third parties.
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / execution / ExecutionModuleDescriptor.java
1 package org.argeo.slc.execution;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import java.util.Map;
6
7 import org.argeo.slc.SlcException;
8 import org.argeo.slc.deploy.ModuleDescriptor;
9
10 /** Describes the information required to launch a flow */
11 public class ExecutionModuleDescriptor extends ModuleDescriptor {
12 /** Metadata header identifying an SLC execution module */
13 public final static String SLC_EXECUTION_MODULE = "SLC-ExecutionModule";
14
15 private static final long serialVersionUID = -2394473464513029512L;
16 private List<ExecutionSpec> executionSpecs = new ArrayList<ExecutionSpec>();
17 private List<ExecutionFlowDescriptor> executionFlows = new ArrayList<ExecutionFlowDescriptor>();
18
19 public List<ExecutionSpec> getExecutionSpecs() {
20 return executionSpecs;
21 }
22
23 public List<ExecutionFlowDescriptor> getExecutionFlows() {
24 return executionFlows;
25 }
26
27 /**
28 * Returns a new {@link ExecutionModuleDescriptor} that can be used to build
29 * a {@link RealizedFlow}.
30 */
31 public ExecutionFlowDescriptor cloneFlowDescriptor(String name) {
32 ExecutionFlowDescriptor res = null;
33 for (ExecutionFlowDescriptor efd : executionFlows) {
34 if (efd.getName().equals(name)
35 || ("/" + efd.getName()).equals(name)) {
36 try {
37 res = (ExecutionFlowDescriptor) efd.clone();
38 } catch (CloneNotSupportedException e) {
39 throw new SlcException("Cannot clone " + efd, e);
40 }
41 }
42 }
43 if (res == null)
44 throw new SlcException("Flow " + name + " not found.");
45 return res;
46 }
47
48 public RealizedFlow asRealizedFlow(String flow, Map<String, Object> values) {
49 RealizedFlow realizedFlow = new RealizedFlow();
50 realizedFlow.setFlowDescriptor(cloneFlowDescriptor(flow));
51 realizedFlow.setModuleName(getName());
52 realizedFlow.setModuleVersion(getVersion());
53 realizedFlow.getFlowDescriptor().getValues().putAll(values);
54 return realizedFlow;
55 }
56
57 public void setExecutionSpecs(List<ExecutionSpec> executionSpecs) {
58 this.executionSpecs = executionSpecs;
59 }
60
61 public void setExecutionFlows(List<ExecutionFlowDescriptor> executionFlows) {
62 this.executionFlows = executionFlows;
63 }
64 }