]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java
Disable trace logging
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / execution / RealizedFlow.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.io.Serializable;
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.argeo.slc.DefaultNameVersion;
23 import org.argeo.slc.NameVersion;
24
25 /** A fully configured execution flow, ready to be executed. */
26 public class RealizedFlow implements Serializable {
27 private static final long serialVersionUID = 1L;
28
29 private String moduleName;
30 private String moduleVersion;
31 private ExecutionFlowDescriptor flowDescriptor;
32
33 public String getModuleName() {
34 return moduleName;
35 }
36
37 public void setModuleName(String moduleName) {
38 this.moduleName = moduleName;
39 }
40
41 public NameVersion getModuleNameVersion() {
42 return new DefaultNameVersion(getModuleName(), getModuleVersion());
43 }
44
45 public String getModuleVersion() {
46 return moduleVersion;
47 }
48
49 public void setModuleVersion(String moduleVersion) {
50 this.moduleVersion = moduleVersion;
51 }
52
53 public ExecutionFlowDescriptor getFlowDescriptor() {
54 return flowDescriptor;
55 }
56
57 public void setFlowDescriptor(ExecutionFlowDescriptor flowDescriptor) {
58 this.flowDescriptor = flowDescriptor;
59 }
60
61 /** Create a simple realized flow */
62 public static RealizedFlow create(String module, String version,
63 String flowName, Map<String, String> args) {
64 final RealizedFlow realizedFlow = new RealizedFlow();
65 realizedFlow.setModuleName(module);
66 // TODO deal with version
67 if (version == null)
68 version = "0.0.0";
69 realizedFlow.setModuleVersion(version);
70 ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
71 efd.setName(flowName);
72
73 // arguments
74 if (args != null && args.size() > 0) {
75 Map<String, Object> values = new HashMap<String, Object>();
76 for (String key : args.keySet()) {
77 String value = args.get(key);
78 values.put(key, value);
79 }
80 efd.setValues(values);
81 }
82
83 realizedFlow.setFlowDescriptor(efd);
84 return realizedFlow;
85 }
86 }