/*
- * 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.
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;
+import org.argeo.slc.BasicNameVersion;
+import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
import org.argeo.slc.core.execution.PrimitiveAccessor;
import org.argeo.slc.core.execution.PrimitiveUtils;
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;
+ }
+
+ /** Extracts the module name and version from a flow path */
+ public static NameVersion moduleNameVersion(String fullFlowPath) {
+ String[] tokens = fullFlowPath.split("/");
+ String module = tokens[AGENT_FACTORY_DEPTH + 2];
+ String moduleName = module.substring(0, module.indexOf('_'));
+ String moduleVersion = module.substring(module.indexOf('_') + 1);
+ return new BasicNameVersion(moduleName, moduleVersion);
+ }
+
/** Module node name based on module name and version */
public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
+ 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);
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<String> 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;
}
/**
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) {
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) {
/** Prevents instantiation */
private SlcJcrUtils() {
-
}
-}
+}
\ No newline at end of file