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=cbce65b608b46f8828c4ad8276142a7cca4e926f;hpb=699640c58cc0578beebfc3edd00dac9eed65ee0b;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 cbce65b60..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,5 +1,5 @@ /* - * Copyright (C) 2007-2012 Mathieu Baudier + * 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. @@ -17,7 +17,9 @@ package org.argeo.slc.execution; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import org.argeo.slc.SlcException; import org.argeo.slc.deploy.ModuleDescriptor; /** Describes the information required to launch a flow */ @@ -37,6 +39,36 @@ public class ExecutionModuleDescriptor extends ModuleDescriptor { 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; }