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%2FJcrExecutionProcess.java;h=180d8f008f84bc7e7d8644896b4486ade72c7fcb;hb=805e3301575e708491482a2a00dd37bc2b41b851;hp=641132d6accfc2563b5e6143c84b9ca5d22d444d;hpb=58e0e18d64a2080680a9f8397b0dfa2894519910;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionProcess.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionProcess.java index 641132d6a..180d8f008 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionProcess.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionProcess.java @@ -15,25 +15,33 @@ */ package org.argeo.slc.jcr.execution; +import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; import javax.jcr.Node; +import javax.jcr.NodeIterator; +import javax.jcr.Property; +import javax.jcr.Repository; import javax.jcr.RepositoryException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.jcr.JcrUtils; +import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; +import org.argeo.slc.core.execution.ProcessThread; import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.execution.ExecutionStep; +import org.argeo.slc.execution.RealizedFlow; +import org.argeo.slc.jcr.SlcJcrUtils; import org.argeo.slc.jcr.SlcNames; import org.argeo.slc.jcr.SlcTypes; /** Execution process implementation based on a JCR node. */ public class JcrExecutionProcess implements ExecutionProcess, SlcNames { - private Log log = LogFactory.getLog(JcrExecutionProcess.class); + private final static Log log = LogFactory.getLog(JcrExecutionProcess.class); private final Node node; private Long nextLogLine = 1l; @@ -42,7 +50,7 @@ public class JcrExecutionProcess implements ExecutionProcess, SlcNames { this.node = node; } - public String getUuid() { + public synchronized String getUuid() { try { return node.getProperty(SLC_UUID).getString(); } catch (RepositoryException e) { @@ -50,7 +58,7 @@ public class JcrExecutionProcess implements ExecutionProcess, SlcNames { } } - public String getStatus() { + public synchronized String getStatus() { try { return node.getProperty(SLC_STATUS).getString(); } catch (RepositoryException e) { @@ -62,7 +70,7 @@ public class JcrExecutionProcess implements ExecutionProcess, SlcNames { } } - public void setStatus(String status) { + public synchronized void setStatus(String status) { try { node.setProperty(SLC_STATUS, status); // last modified properties needs to be manually updated @@ -132,8 +140,55 @@ public class JcrExecutionProcess implements ExecutionProcess, SlcNames { } } - public Node getNode() { - return node; + // public Node getNode() { + // return node; + // } + + public List getRealizedFlows() { + try { + List realizedFlows = new ArrayList(); + Node rootRealizedFlowNode = node.getNode(SLC_FLOW); + // we just manage one level for the time being + NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW); + while (nit.hasNext()) { + Node realizedFlowNode = nit.nextNode(); + + if (realizedFlowNode.hasNode(SLC_ADDRESS)) { + String flowPath = realizedFlowNode.getNode(SLC_ADDRESS) + .getProperty(Property.JCR_PATH).getString(); + NameVersion moduleNameVersion = SlcJcrUtils + .moduleNameVersion(flowPath); + ((ProcessThread) Thread.currentThread()) + .getExecutionModulesManager().start( + moduleNameVersion); + } + + RealizedFlow realizedFlow = new JcrRealizedFlow( + realizedFlowNode); + if (realizedFlow != null) + realizedFlows.add(realizedFlow); + } + return realizedFlows; + } catch (RepositoryException e) { + throw new SlcException("Cannot get realized flows", e); + } + } + + public String getNodePath() { + try { + return node.getPath(); + } catch (RepositoryException e) { + throw new SlcException("Cannot get process node path for " + node, + e); + } } + public Repository getRepository() { + try { + return node.getSession().getRepository(); + } catch (RepositoryException e) { + throw new SlcException("Cannot get process JCR repository for " + + node, e); + } + } }