X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2FSlcJcrUtils.java;h=693389d119fe02bd1ce462c93061a988b7ce18c7;hb=ce8f53763eec2a2b9e15e97f2eaa8468b551ea31;hp=e0e52c0d517d4c071d50188f8ad6118ae1c99fe3;hpb=76420da459e9fe47612f77166f5e708648e40ef1;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.java index e0e52c0d5..693389d11 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.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,11 +17,14 @@ package org.argeo.slc.jcr; 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.RepositoryException; import javax.jcr.Session; +import javax.jcr.nodetype.NodeType; import org.argeo.jcr.JcrUtils; import org.argeo.jcr.UserJcrUtils; @@ -59,6 +62,14 @@ public class SlcJcrUtils implements SlcNames { return buf.toString(); } + /** Extracts the module name from a flow path */ + public static String moduleName(String fullFlowPath) { + String[] tokens = fullFlowPath.split("/"); + String moduleName = tokens[AGENT_FACTORY_DEPTH + 2]; + moduleName = moduleName.substring(0, moduleName.indexOf('_')); + return moduleName; + } + /** Module node name based on module name and version */ public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) { return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion(); @@ -82,7 +93,7 @@ public class SlcJcrUtils implements SlcNames { + JcrUtils.dateAsPath(now, true) + uuid; } - /** GEt the base for the user processeses. */ + /** Get the base for the user processi. */ public static String getSlcProcessesBasePath(Session session) { try { Node userHome = UserJcrUtils.getUserHome(session); @@ -104,8 +115,26 @@ public class SlcJcrUtils implements SlcNames { public static String createResultPath(Session session, String uuid) throws RepositoryException { Calendar now = new GregorianCalendar(); - return SlcJcrResultUtils.getSlcResultsBasePath(session) + '/' - + JcrUtils.dateAsPath(now, true) + uuid; + StringBuffer absPath = new StringBuffer( + SlcJcrResultUtils.getSlcResultsBasePath(session) + '/'); + // Remove hours and add title property to the result process path on + // request of O. Capillon + // return getSlcProcessesBasePath(session) + '/' + // + JcrUtils.dateAsPath(now, true) + uuid; + String relPath = JcrUtils.dateAsPath(now, false); + List names = JcrUtils.tokenize(relPath); + for (String name : names) { + absPath.append(name + "/"); + Node node = JcrUtils.mkdirs(session, absPath.toString()); + try { + node.addMixin(NodeType.MIX_TITLE); + node.setProperty(Property.JCR_TITLE, name.substring(1)); + } catch (RepositoryException e) { + throw new SlcException( + "unable to create execution process path", e); + } + } + return absPath.toString() + uuid; } /** @@ -167,9 +196,14 @@ public class SlcJcrUtils implements SlcNames { NodeIterator it = node.getNodes(); while (it.hasNext()) { - Integer childStatus = aggregateTestStatus(it.nextNode()); - if (childStatus > status) - status = childStatus; + Node curr = it.nextNode(); + + // Manually skip aggregated status + if (!SlcNames.SLC_AGGREGATED_STATUS.equals(curr.getName())) { + Integer childStatus = aggregateTestStatus(curr); + if (childStatus > status) + status = childStatus; + } } return status; } catch (Exception e) { @@ -203,7 +237,10 @@ public class SlcJcrUtils implements SlcNames { NodeIterator it = node.getNodes(); while (it.hasNext()) { Node child = it.nextNode(); - aggregateTestMessages(child, messages); + // Manually skip aggregated status + if (!SlcNames.SLC_AGGREGATED_STATUS.equals(child.getName())) { + aggregateTestMessages(child, messages); + } } return messages; } catch (Exception e) { @@ -214,6 +251,5 @@ public class SlcJcrUtils implements SlcNames { /** Prevents instantiation */ private SlcJcrUtils() { - } -} +} \ No newline at end of file