X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FDefaultModulesManager.java;h=7da391a3796316697be997cedd10c944136e3b51;hb=e1d7987700a05a5952cc16bfb4fe755dfc079f92;hp=75d94db02fd46f83ae6805d6abc192685bcb4173;hpb=2887de51b854588b4a60ab12124c179997e0a015;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultModulesManager.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultModulesManager.java index 75d94db02..7da391a37 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultModulesManager.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultModulesManager.java @@ -1,10 +1,13 @@ package org.argeo.slc.core.execution; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.slc.SlcException; import org.argeo.slc.execution.ExecutionFlow; import org.argeo.slc.execution.ExecutionFlowDescriptor; import org.argeo.slc.execution.ExecutionModule; @@ -23,8 +26,9 @@ public class DefaultModulesManager implements ExecutionModulesManager { protected ExecutionModule getExecutionModule(String moduleName, String version) { for (ExecutionModule moduleT : executionModules) { if (moduleT.getName().equals(moduleName)) { - // TODO: check version - return moduleT; + if(moduleT.getVersion().equals(version)) { + return moduleT; + } } } return null; @@ -48,20 +52,42 @@ public class DefaultModulesManager implements ExecutionModulesManager { } public void process(SlcExecution slcExecution) { - log.info("SlcExecution " + slcExecution); + log.info("##\n## Process SLC Execution " + slcExecution+"\n##"); for(RealizedFlow flow : slcExecution.getRealizedFlows()) { ExecutionModule module = getExecutionModule(flow.getModuleName(), flow.getModuleVersion()); if(module != null) { ExecutionContext executionContext = new ExecutionContext(); - executionContext.addVariables(slcExecution.getAttributes()); + + // convert the values of flow.getFlowDescriptor() + Map values = flow.getFlowDescriptor().getValues(); + + Map convertedValues = new HashMap(); + + for(String key : values.keySet()) { + Object value = values.get(key); + if(value instanceof PrimitiveValue) { + PrimitiveValue primitiveValue = (PrimitiveValue) value; + + // TODO: check that the class of the the primitiveValue.value matches + // the primitiveValue.type + convertedValues.put(key, primitiveValue.getValue()); + } + else if(value instanceof RefValue) { + RefValue refValue = (RefValue) value; + convertedValues.put(key, refValue.getLabel()); + } + } + + executionContext.addVariables(convertedValues); ExecutionThread thread = new ExecutionThread(executionContext, flow.getFlowDescriptor(), module); thread.start(); } else { - // throw exception ? + throw new SlcException("ExecutionModule " + flow.getModuleName() + ", version " + + flow.getModuleVersion() + " not found."); } } } @@ -85,6 +111,7 @@ public class DefaultModulesManager implements ExecutionModulesManager { try { executionModule.execute(executionFlowDescriptor); } catch (Exception e) { + //TODO: re-throw exception ? log.error("Execution " + executionContext.getUuid() + " failed.", e); }