- protected static ExecutionModuleDescriptor createDescriptor(
- String moduleName, String moduleVersion,
- Map<String, ExecutionFlow> executionFlows) {
- // TODO: put this in a separate configurable object
- ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
- md.setName(moduleName);
- md.setVersion(moduleVersion);
-
- for (String name : executionFlows.keySet()) {
- ExecutionFlow executionFlow = executionFlows.get(name);
-
- Assert.notNull(executionFlow.getName());
- Assert.state(name.equals(executionFlow.getName()));
-
- ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
- Assert.notNull(executionSpec);
- Assert.notNull(executionSpec.getName());
-
- Map<String, Object> values = new TreeMap<String, Object>();
- for (String key : executionSpec.getAttributes().keySet()) {
- ExecutionSpecAttribute attribute = executionSpec
- .getAttributes().get(key);
-
- if (executionFlow.isSetAsParameter(key)) {
- Object value = executionFlow.getParameter(key);
- if (attribute instanceof PrimitiveSpecAttribute) {
- PrimitiveValue primitiveValue = new PrimitiveValue();
- primitiveValue
- .setType(((PrimitiveSpecAttribute) attribute)
- .getType());
- primitiveValue.setValue(value);
- values.put(key, primitiveValue);
- } else if (attribute instanceof RefSpecAttribute) {
- RefValue refValue = new RefValue();
- if (value instanceof ScopedObject) {
- refValue.setLabel("RUNTIME "
- + value.getClass().getName());
- } else {
- refValue.setLabel("STATIC "
- + value.getClass().getName());
- }
- values.put(key, refValue);
- } else {
- throw new SlcException("Unkown spec attribute type "
- + attribute.getClass());
- }
- }
-
- }
-
- ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name,
- values, executionSpec);
- if (executionFlow.getPath() != null)
- efd.setPath(executionFlow.getPath());
-
- // Add execution spec if necessary
- if (!md.getExecutionSpecs().contains(executionSpec))
- md.getExecutionSpecs().add(executionSpec);
-
- // Add execution flow
- md.getExecutionFlows().add(efd);
- }
-
- return md;