X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2Fexecution%2FJcrProcessThread.java;h=09145863388e386b00bf5cbbaf0350abe2f44eb7;hb=cc62743f351e03634604fdd4b66e6e0feebfe02b;hp=eab881f73ff6ccd248a3b1ef709801cf3b134412;hpb=24d560ee846fda5d7954d44f83cb22ab449dbe61;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrProcessThread.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrProcessThread.java index eab881f73..091458633 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrProcessThread.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrProcessThread.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2007-2012 Mathieu Baudier + * + * 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.jcr.execution; import java.util.HashMap; @@ -14,6 +29,7 @@ import org.argeo.slc.core.execution.DefaultExecutionSpec; import org.argeo.slc.core.execution.PrimitiveSpecAttribute; import org.argeo.slc.core.execution.PrimitiveUtils; import org.argeo.slc.core.execution.ProcessThread; +import org.argeo.slc.core.execution.RefSpecAttribute; import org.argeo.slc.execution.ExecutionFlowDescriptor; import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.execution.ExecutionProcess; @@ -94,38 +110,26 @@ public class JcrProcessThread extends ProcessThread implements SlcNames { realizedFlow.setModuleVersion(executionModuleVersion); // retrieve execution spec - DefaultExecutionSpec executionSpec = null; + DefaultExecutionSpec executionSpec = new DefaultExecutionSpec(); + Map attrs = readExecutionSpecAttributes(realizedFlowNode); + executionSpec.setAttributes(attrs); + + // set execution spec name if (flowNode.hasProperty(SlcNames.SLC_SPEC)) { Node executionSpecNode = flowNode.getProperty(SLC_SPEC) .getNode(); - executionSpec = new DefaultExecutionSpec(); executionSpec.setBeanName(executionSpecNode.getProperty( SLC_NAME).getString()); - executionSpec - .setAttributes(readExecutionSpecAttributes(executionSpecNode)); } - // TODO: will with original attr - Map attrs = readExecutionSpecAttributes(realizedFlowNode); + + // explicitly retrieve values Map values = new HashMap(); for (String attrName : attrs.keySet()) { - if (flowNode.hasNode(attrName)) { - // we assume this is a primitive - // since ref are not yet implemented - Node valueNode = flowNode.getNode(attrName); - String type = valueNode.getProperty(SLC_TYPE).getString(); - String valueStr = valueNode.getProperty(SLC_VALUE) - .getString(); - Object value = PrimitiveUtils.convert(type, valueStr); - values.put(attrName, value); - } else { - ExecutionSpecAttribute attr = attrs.get(attrName); - Object value = attr.getValue(); - values.put(attrName, value); - } + ExecutionSpecAttribute attr = attrs.get(attrName); + Object value = attr.getValue(); + values.put(attrName, value); } - // if(executionSpec!=null) - // executionSpec.setAttributes(attrs); ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(flowName, values, executionSpec); realizedFlow.setFlowDescriptor(efd); @@ -157,8 +161,28 @@ public class JcrProcessThread extends ProcessThread implements SlcNames { PrimitiveSpecAttribute specAttr = new PrimitiveSpecAttribute( type, value); attrs.put(specAttrNode.getName(), specAttr); + } else if (specAttrNode + .isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { + if (!specAttrNode.hasProperty(SLC_VALUE)) { + continue; + } + Integer value = (int) specAttrNode.getProperty(SLC_VALUE) + .getLong(); + RefSpecAttribute specAttr = new RefSpecAttribute(); + NodeIterator children = specAttrNode.getNodes(); + int index = 0; + String id = null; + while (children.hasNext()) { + Node child = children.nextNode(); + if (index == value) + id = child.getName(); + index++; + } + specAttr.setValue(id); + attrs.put(specAttrNode.getName(), specAttr); } - + // throw new SlcException("Unsupported spec attribute " + // + specAttrNode); } return attrs; } catch (RepositoryException e) {