]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java
Disable trace logging
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / execution / ExecutionModuleDescriptor.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.execution;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.argeo.slc.SlcException;
23 import org.argeo.slc.deploy.ModuleDescriptor;
24
25 /** Describes the information required to launch a flow */
26 public class ExecutionModuleDescriptor extends ModuleDescriptor {
27 /** Metadata header identifying an SLC execution module */
28 public final static String SLC_EXECUTION_MODULE = "SLC-ExecutionModule";
29
30 private static final long serialVersionUID = -2394473464513029512L;
31 private List<ExecutionSpec> executionSpecs = new ArrayList<ExecutionSpec>();
32 private List<ExecutionFlowDescriptor> executionFlows = new ArrayList<ExecutionFlowDescriptor>();
33
34 public List<ExecutionSpec> getExecutionSpecs() {
35 return executionSpecs;
36 }
37
38 public List<ExecutionFlowDescriptor> getExecutionFlows() {
39 return executionFlows;
40 }
41
42 /**
43 * Returns a new {@link ExecutionModuleDescriptor} that can be used to build
44 * a {@link RealizedFlow}.
45 */
46 public ExecutionFlowDescriptor cloneFlowDescriptor(String name) {
47 ExecutionFlowDescriptor res = null;
48 for (ExecutionFlowDescriptor efd : executionFlows) {
49 if (efd.getName().equals(name)
50 || ("/" + efd.getName()).equals(name)) {
51 try {
52 res = (ExecutionFlowDescriptor) efd.clone();
53 } catch (CloneNotSupportedException e) {
54 throw new SlcException("Cannot clone " + efd, e);
55 }
56 }
57 }
58 if (res == null)
59 throw new SlcException("Flow " + name + " not found.");
60 return res;
61 }
62
63 public RealizedFlow asRealizedFlow(String flow, Map<String, Object> values) {
64 RealizedFlow realizedFlow = new RealizedFlow();
65 realizedFlow.setFlowDescriptor(cloneFlowDescriptor(flow));
66 realizedFlow.setModuleName(getName());
67 realizedFlow.setModuleVersion(getVersion());
68 realizedFlow.getFlowDescriptor().getValues().putAll(values);
69 return realizedFlow;
70 }
71
72 public void setExecutionSpecs(List<ExecutionSpec> executionSpecs) {
73 this.executionSpecs = executionSpecs;
74 }
75
76 public void setExecutionFlows(List<ExecutionFlowDescriptor> executionFlows) {
77 this.executionFlows = executionFlows;
78 }
79 }