X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.specs%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fexecution%2FExecutionModuleDescriptor.java;h=4de0268228c8d1cc6305186dba92effb076613ab;hb=d4bd245768d2e2b3f94928b3db5a01380857e8b8;hp=555ef40d749ed768e8eaad726b57b0096a3e5e78;hpb=b0c2c01573db47690afdf723e49fb7fa39561e8e;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java index 555ef40d7..4de026822 100644 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java +++ b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java @@ -1,15 +1,33 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.slc.execution; -import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.argeo.slc.SlcException; +import org.argeo.slc.deploy.ModuleDescriptor; -public class ExecutionModuleDescriptor implements Serializable { - private static final long serialVersionUID = 1L; - private String name; - private String version; +/** 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(); @@ -21,28 +39,41 @@ public class ExecutionModuleDescriptor implements Serializable { return executionFlows; } - public void setExecutionSpecs(List executionSpecs) { - this.executionSpecs = executionSpecs; - } - - public void setExecutionFlows(List executionFlows) { - this.executionFlows = executionFlows; - } - - public String getName() { - return name; + /** + * 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 void setName(String name) { - this.name = name; + 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 String getVersion() { - return version; + public void setExecutionSpecs(List executionSpecs) { + this.executionSpecs = executionSpecs; } - public void setVersion(String version) { - this.version = version; + public void setExecutionFlows(List executionFlows) { + this.executionFlows = executionFlows; } - }