introduce a new view to display JcrResults has a tree.
authorBruno Sinou <bsinou@argeo.org>
Fri, 24 Aug 2012 16:09:41 +0000 (16:09 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 24 Aug 2012 16:09:41 +0000 (16:09 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5541 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

12 files changed:
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/AddResultFolder.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/commands/DeleteResult.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ParentNodeFolder.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ResultFolder.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ResultParentUtils.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/SimpleNodeFolder.java [deleted file]
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/SingleResultNode.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/VirtualFolder.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrResultTreeView.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrConstants.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrResultUtils.java

index e1b357482d85e6a3e014bc12a8f0b486d9d95bfc..dc61fc47786f1da0efbe2a63abfc8ed74d6dbc3c 100644 (file)
@@ -23,6 +23,7 @@ import org.argeo.eclipse.ui.ErrorFeedback;
 import org.argeo.eclipse.ui.dialogs.SingleValue;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.model.ParentNodeFolder;
 import org.argeo.slc.client.ui.model.ResultFolder;
 import org.argeo.slc.jcr.SlcJcrResultUtils;
 import org.eclipse.core.commands.AbstractHandler;
@@ -48,18 +49,32 @@ public class AddResultFolder extends AbstractHandler {
 
                // Sanity check, already done when populating the corresponding popup
                // menu.
-               if (selection != null && selection.size() == 1
-                               && selection.getFirstElement() instanceof ResultFolder) {
-                       ResultFolder rf = (ResultFolder) selection.getFirstElement();
+               if (selection != null && selection.size() == 1) {
+                       Object obj = selection.getFirstElement();
+
                        try {
-                               String folderName = SingleValue.ask("Folder name",
-                                               "Enter folder name");
-                               if (folderName != null) {
-                                       Node parentNode = rf.getNode();
-                                       String absPath = parentNode.getPath()+ "/"
-                                                       + folderName;
-                                       SlcJcrResultUtils.createResultFolderNode(
-                                                       parentNode.getSession(), absPath);
+                               Node parentNode = null;
+
+                               if (obj instanceof ResultFolder) {
+                                       ResultFolder rf = (ResultFolder) obj;
+                                       parentNode = rf.getNode();
+                               } else if (obj instanceof ParentNodeFolder) {
+                                       Node node = ((ParentNodeFolder) obj).getNode();
+                                       if (node.getPath().startsWith(
+                                                       SlcJcrResultUtils.getMyResultsBasePath(node
+                                                                       .getSession())))
+                                               parentNode = node;
+                               }
+
+                               if (parentNode != null) {
+                                       String folderName = SingleValue.ask("Folder name",
+                                                       "Enter folder name");
+                                       if (folderName != null) {
+                                               String absPath = parentNode.getPath() + "/"
+                                                               + folderName;
+                                               SlcJcrResultUtils.createResultFolderNode(
+                                                               parentNode.getSession(), absPath);
+                                       }
                                }
                        } catch (RepositoryException e) {
                                throw new SlcException(
index 321a6b552a39458cbe8f52b250704f4ffa21248a..94cdd3e94f332bb4f375af1ff871b2bc14286614 100644 (file)
@@ -26,7 +26,9 @@ import javax.jcr.Session;
 \r
 import org.argeo.eclipse.ui.ErrorFeedback;\r
 import org.argeo.slc.client.ui.model.ResultFolder;\r
+import org.argeo.slc.client.ui.model.ResultParentUtils;\r
 import org.argeo.slc.client.ui.model.SingleResultNode;\r
+import org.argeo.slc.jcr.SlcNames;\r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
@@ -83,7 +85,9 @@ public class DeleteResult extends AbstractHandler {
                                                for (final String path : nodes) {\r
                                                        if (session.itemExists(path)) {\r
                                                                node = session.getNode(path);\r
+                                                               Node parent = node.getParent();\r
                                                                node.remove();\r
+                                                               ResultParentUtils.updateStatusOnRemoval(parent);\r
                                                        }\r
                                                        monitor.worked(1);\r
                                                }\r
index 1d021e2a3ddd3be1b4e8be4cab0fc17bc1d5ca0c..64c759b77db6f8edbe66831f83aa86992d6a0d54 100644 (file)
@@ -15,8 +15,6 @@
  */
 package org.argeo.slc.client.ui.decorators;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.client.ui.ClientUiPlugin;
 import org.argeo.slc.client.ui.model.ResultParent;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -30,8 +28,8 @@ import org.eclipse.ui.ISharedImages;
 public class ResultFailedDecorator extends LabelProvider implements
                ILabelDecorator {
 
-       private final static Log log = LogFactory
-                       .getLog(ResultFailedDecorator.class);
+       // private final static Log log = LogFactory
+       // .getLog(ResultFailedDecorator.class);
 
        public ResultFailedDecorator() {
                super();
@@ -45,8 +43,6 @@ public class ResultFailedDecorator extends LabelProvider implements
                // decorates resource icon with basic decorations provided
                // by Eclipse
                if (object instanceof ResultParent) {
-                       log.debug("decorate : " + ((ResultParent) object).getName()
-                                       + " - passed : " + ((ResultParent) object).isPassed());
                        if (!((ResultParent) object).isPassed()) {
                                ImageDescriptor desc = ClientUiPlugin.getDefault()
                                                .getWorkbench().getSharedImages()
diff --git a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ParentNodeFolder.java b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ParentNodeFolder.java
new file mode 100644 (file)
index 0000000..91163c8
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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.client.ui.model;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+
+/**
+ * UI Tree component that wrap a node of type NT_UNSTRUCTURED. list either
+ * result folders, other folders and/or a list of results. keeps a reference to
+ * its parent.
+ */
+public class ParentNodeFolder extends ResultParent {
+
+       private Node node = null;
+
+       /**
+        * 
+        * @param parent
+        * @param node
+        *            throws an exception if null
+        * @param name
+        */
+       public ParentNodeFolder(ParentNodeFolder parent, Node node, String name) {
+               super(name);
+               if (node == null)
+                       throw new SlcException("Node Object cannot be null");
+               setParent(parent);
+               this.node = node;
+       }
+
+       @Override
+       protected void initialize() {
+               try {
+                       NodeIterator ni = node.getNodes();
+                       while (ni.hasNext()) {
+                               Node currNode = ni.nextNode();
+                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
+                                       SingleResultNode srn = new SingleResultNode(this, currNode,
+                                                       currNode.getProperty(SlcNames.SLC_TEST_CASE)
+                                                                       .getString());
+                                       addChild(srn);
+                               } else if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
+                                       // FIXME change label
+                                       ResultFolder rf = new ResultFolder(this, currNode,
+                                                       currNode.getName());
+                                       addChild(rf);
+                               } else if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
+                                       addChild(new ParentNodeFolder(this, currNode,
+                                                       currNode.getName()));
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing simple node folder : "
+                                                       + getName(), re);
+               }
+       }
+
+       @Override
+       public synchronized void dispose() {
+               super.dispose();
+       }
+
+       public Node getNode() {
+               return node;
+       }
+
+       /**
+        * Overriden in the specific case of "My result" root object to return an
+        * ordered list of children
+        */
+       public synchronized Object[] getChildren() {
+               Object[] children = super.getChildren();
+               try {
+                       if (node.getPath().equals(
+                                       SlcJcrResultUtils.getMyResultsBasePath(node.getSession())))
+                               return ResultParentUtils.orderChildren(children);
+                       else
+                               return children;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing simple node folder : "
+                                                       + getName(), re);
+               }
+       }
+}
\ No newline at end of file
index ac4eb9f7cc36b5deeff5d6342714f03ee8c76489..a5c43168ec18ce34e518bd379d0ed9faf9606976 100644 (file)
@@ -27,7 +27,7 @@ import org.argeo.slc.jcr.SlcTypes;
  * UI Tree component that wrap a node of type ResultFolder. list either other
  * folders and/or a list of results. keeps a reference to its parent.
  */
-public class ResultFolder extends ResultParent {
+public class ResultFolder extends ResultParent implements Comparable<ResultFolder> {
 
        private Node node = null;
 
@@ -38,16 +38,17 @@ public class ResultFolder extends ResultParent {
         *            throws an exception if null
         * @param name
         */
-       public ResultFolder(ResultFolder parent, Node node, String name) {
+       public ResultFolder(ResultParent parent, Node node, String name) {
                super(name);
                try {
                        if (node == null)
                                throw new SlcException("Node Object cannot be null");
                        setParent(parent);
                        this.node = node;
-                       // initialize passed status
-                       setPassed(node.getNode(SlcNames.SLC_STATUS)
-                                       .getProperty(SlcNames.SLC_SUCCESS).getBoolean());
+                       // initialize passed status if possible
+                       if (node.hasNode(SlcNames.SLC_STATUS))
+                               setPassed(node.getNode(SlcNames.SLC_STATUS)
+                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean());
                } catch (RepositoryException re) {
                        throw new SlcException(
                                        "Unexpected error while initializing result folder : "
@@ -90,51 +91,15 @@ public class ResultFolder extends ResultParent {
                return node;
        }
 
-       // /** Override normal behavior to initialize display */
-       // @Override
-       // public synchronized Object[] getChildren() {
-       // if (isLoaded()) {
-       // return super.getChildren();
-       // } else {
-       // // initialize current object
-       // try {
-       // if (node != null) {
-       // NodeIterator ni = node.getNodes();
-       // while (ni.hasNext()) {
-       // Node currNode = ni.nextNode();
-       // if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT))
-       // addChild(new SingleResultNode(this, node, node
-       // .getProperty(SlcNames.SLC_TEST_CASE)
-       // .getString()));
-       // else if (currNode
-       // .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-       // addChild(new ResultFolder(this, node,
-       // node.getName()));
-       // }
-       // }
-       // return super.getChildren();
-       // } catch (RepositoryException e) {
-       // throw new ArgeoException(
-       // "Cannot initialize WorkspaceNode UI object."
-       // + getName(), e);
-       // }
-       // }
-       // }
-
-       // @Override
-       // public boolean refreshPassedStatus() {
-       // Object[] children = getChildren();
-       // isPassed = true;
-       // checkChildrenStatus: for (int i = 0; i <= children.length; i++) {
-       // if (children[i] instanceof ResultFolder) {
-       //
-       // }
-       // if (!((ResultParent) children[i]).isPassed()) {
-       // isPassed = false;
-       // break checkChildrenStatus;
-       // }
-       // }
-       // return isPassed;
-       // }
+       /**
+        * Overriden to return an ordered list of children
+        */
+       public synchronized Object[] getChildren() {
+               Object[] children = super.getChildren();
+               return ResultParentUtils.orderChildren(children);
+       }
 
+       public int compareTo(ResultFolder o) {
+               return super.compareTo(o);
+       }
 }
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ResultParentUtils.java b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ResultParentUtils.java
new file mode 100644 (file)
index 0000000..fc4eec7
--- /dev/null
@@ -0,0 +1,202 @@
+package org.argeo.slc.client.ui.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+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.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+
+public class ResultParentUtils {
+       private final static Log log = LogFactory.getLog(ResultParentUtils.class);
+
+       public static Object[] orderChildren(Object[] children) {
+               List<ResultFolder> folders = new ArrayList<ResultFolder>();
+               List<SingleResultNode> results = new ArrayList<SingleResultNode>();
+               for (Object child : children) {
+                       if (child instanceof ResultFolder)
+                               folders.add((ResultFolder) child);
+                       else if (child instanceof SingleResultNode)
+                               results.add((SingleResultNode) child);
+               }
+
+               // Comparator first = Collections.reverseOrder();
+               Collections.sort(folders);
+               // Comparator<SingleResultNode> second = Collections.reverseOrder();
+               Collections.sort(results);
+
+               Object[] orderedChildren = new Object[children.length];
+               int i = 0;
+               Iterator<ResultFolder> it = folders.iterator();
+               while (it.hasNext()) {
+                       orderedChildren[i] = it.next();
+                       i++;
+               }
+               Iterator<SingleResultNode> it2 = results.iterator();
+               while (it2.hasNext()) {
+                       orderedChildren[i] = it2.next();
+                       i++;
+               }
+               return orderedChildren;
+       }
+
+       public static ResultParent[] getResultsForDates(Session session,
+                       List<String> dateRelPathes) {
+               if (dateRelPathes == null || dateRelPathes.size() == 0)
+                       throw new SlcException("Specify at least one correct date as Path");
+
+               try {
+                       String basePath = SlcJcrResultUtils.getSlcResultsBasePath(session);
+                       Iterator<String> it = dateRelPathes.iterator();
+                       StringBuffer clause = new StringBuffer();
+                       clause.append("SELECT * FROM [");
+                       clause.append(SlcTypes.SLC_DIFF_RESULT);
+                       clause.append("] as results");
+                       clause.append(" WHERE ");
+                       while (it.hasNext()) {
+                               String absPath = basePath + "/" + it.next();
+                               clause.append("ISDESCENDANTNODE(results, [");
+                               clause.append(absPath);
+                               clause.append("]) ");
+                               clause.append(" OR ");
+                       }
+                       // remove last " OR "
+                       clause.delete(clause.length() - 4, clause.length());
+                       clause.append(" ORDER BY results.[" + Property.JCR_CREATED
+                                       + "] DESC");
+
+                       // log.debug("request : " + clause.toString());
+                       QueryManager qm = session.getWorkspace().getQueryManager();
+                       Query q = qm.createQuery(clause.toString(), Query.JCR_SQL2);
+                       QueryResult result = q.execute();
+
+                       NodeIterator ni = result.getNodes();
+                       ResultParent[] results = new ResultParent[(int) ni.getSize()];
+                       int i = 0;
+                       while (ni.hasNext()) {
+                               Node currNode = ni.nextNode();
+                               SingleResultNode srn = new SingleResultNode(null, currNode,
+                                               currNode.getProperty(SlcNames.SLC_TEST_CASE)
+                                                               .getString());
+
+                               results[i] = srn;
+                               i++;
+                       }
+                       return results;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Results for given date", re);
+               }
+       }
+
+       /**
+        * recursively update passed status of the parent ResultFolder and its
+        * parent if needed
+        * 
+        * @param node
+        *            cannot be null
+        * 
+        */
+       public static void updatePassedStatus(Node node, boolean passed) {
+               try {
+                       Node pNode = node.getParent();
+                       if (!pNode.hasNode(SlcNames.SLC_STATUS))
+                               // we have reached the root of the tree. stop the
+                               // recursivity
+                               return;
+                       boolean pStatus = pNode.getNode(SlcNames.SLC_STATUS)
+                                       .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
+                       if (pStatus == passed)
+                               // nothing to update
+                               return;
+                       else if (!passed) {
+                               // error we only update status of the result folder and its
+                               // parent if needed
+                               pNode.getNode(SlcNames.SLC_STATUS).setProperty(
+                                               SlcNames.SLC_SUCCESS, passed);
+                               updatePassedStatus(pNode, passed);
+                       } else {
+                               // success we must first check if all siblings have also
+                               // successfully completed
+                               boolean success = true;
+                               NodeIterator ni = pNode.getNodes();
+                               children: while (ni.hasNext()) {
+                                       Node currNode = ni.nextNode();
+                                       if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode
+                                                       .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
+                                                       && !currNode.getNode(SlcNames.SLC_STATUS)
+                                                                       .getProperty(SlcNames.SLC_SUCCESS)
+                                                                       .getBoolean()) {
+                                               success = false;
+                                               break children;
+                                       }
+                               }
+                               if (success) {
+                                       pNode.getNode(SlcNames.SLC_STATUS).setProperty(
+                                                       SlcNames.SLC_SUCCESS, passed);
+                                       updatePassedStatus(pNode, passed);
+                               } else
+                                       // one of the siblings had also the failed status so
+                                       // above tree remains unchanged.
+                                       return;
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listeners", e);
+               }
+       }
+
+       public static void updateStatusOnRemoval(Node node) {
+               try {
+                       if (!node.hasNode(SlcNames.SLC_STATUS))
+                               // nothing to do
+                               return;
+                       boolean pStatus = node.getNode(SlcNames.SLC_STATUS)
+                                       .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
+                       if (pStatus == true)
+                               // nothing to update
+                               return;
+                       else {
+                               // success we must first check if all siblings have also
+                               // successfully completed
+                               boolean success = true;
+                               NodeIterator ni = node.getNodes();
+                               children: while (ni.hasNext()) {
+                                       Node currNode = ni.nextNode();
+                                       if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode
+                                                       .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
+                                                       && !currNode.getNode(SlcNames.SLC_STATUS)
+                                                                       .getProperty(SlcNames.SLC_SUCCESS)
+                                                                       .getBoolean()) {
+                                               success = false;
+                                               break children;
+                                       }
+                               }
+                               if (success) {
+                                       node.getNode(SlcNames.SLC_STATUS).setProperty(
+                                                       SlcNames.SLC_SUCCESS, true);
+                                       updatePassedStatus(node, true);
+                               } else
+                                       // one of the siblings had also the failed status so
+                                       // above tree remains unchanged.
+                                       return;
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while updating status on removal", e);
+               }
+       }
+
+}
diff --git a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/SimpleNodeFolder.java b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/SimpleNodeFolder.java
deleted file mode 100644 (file)
index c08dafd..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-
-/**
- * UI Tree component that wrap a node of type NT_UNSTRUCTURED. list either other
- * folders and/or a list of results. keeps a reference to its parent.
- */
-public class SimpleNodeFolder extends ResultParent {
-
-       private Node node = null;
-
-       /**
-        * 
-        * @param parent
-        * @param node
-        *            throws an exception if null
-        * @param name
-        */
-       public SimpleNodeFolder(SimpleNodeFolder parent, Node node, String name) {
-               super(name);
-               if (node == null)
-                       throw new SlcException("Node Object cannot be null");
-               setParent(parent);
-               this.node = node;
-       }
-
-       @Override
-       protected void initialize() {
-               try {
-                       NodeIterator ni = node.getNodes();
-                       while (ni.hasNext()) {
-                               Node currNode = ni.nextNode();
-                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
-                                       SingleResultNode srn = new SingleResultNode(this, currNode,
-                                                       currNode.getProperty(SlcNames.SLC_TEST_CASE)
-                                                                       .getString());
-                                       addChild(srn);
-                               } else if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
-                                       addChild(new SimpleNodeFolder(this, currNode,
-                                                       currNode.getName()));
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while initializing simple node folder : "
-                                                       + getName(), re);
-               }
-       }
-
-       @Override
-       public synchronized void dispose() {
-               super.dispose();
-       }
-
-       public Node getNode() {
-               return node;
-       }
-}
\ No newline at end of file
index 5a08349a98687f698d6e4f47a715370a231e131c..aa4acea9c9f3d9e32d83d3eaabbae075b1a0ab74 100644 (file)
@@ -30,7 +30,8 @@ import org.argeo.slc.jcr.SlcNames;
  * It has no child.
  */
 
-public class SingleResultNode extends ResultParent {
+public class SingleResultNode extends ResultParent implements
+               Comparable<SingleResultNode> {
 
        private final Node node;
        private boolean passed;
@@ -84,4 +85,8 @@ public class SingleResultNode extends ResultParent {
                // Do nothing this object is fully initialized at instantiation time.
        }
 
+       public int compareTo(SingleResultNode o) {
+               return super.compareTo(o);
+       }
+
 }
index c69e562d9e33ae9630e4a7d6676c372b871b8c4d..5a6bc77ceb3022454a03ccf69ab669dbb377e228 100644 (file)
  */
 package org.argeo.slc.client.ui.model;
 
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.ArgeoException;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-
 /**
  * UI Tree component. Virtual folder to list either other folders and/or a list
  * of results. Keeps a reference to its parent that might be null if the .
  */
 public class VirtualFolder extends ResultParent {
+       ResultParent[] children;
 
-       private Node node = null;
-       private boolean isPassed = true;
-
-       public VirtualFolder(VirtualFolder parent, Node node, String name) {
+       public VirtualFolder(VirtualFolder parent, ResultParent[] children,
+                       String name) {
                super(name);
                setParent(parent);
-               this.node = node;
+               this.children = children;
        }
 
        @Override
@@ -43,56 +34,16 @@ public class VirtualFolder extends ResultParent {
                super.dispose();
        }
 
-       /** Override normal behavior to initialize display */
-       @Override
-       public synchronized Object[] getChildren() {
-               if (isLoaded()) {
-                       return super.getChildren();
-               } else {
-                       // initialize current object
-                       try {
-                               if (node != null) {
-                                       NodeIterator ni = node.getNodes();
-                                       while (ni.hasNext()) {
-                                               Node currNode = ni.nextNode();
-                                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT))
-                                                       addChild(new SingleResultNode(this, node, node
-                                                                       .getProperty(SlcNames.SLC_TEST_CASE)
-                                                                       .getString()));
-                                               else if (currNode
-                                                               .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-                                                       addChild(new VirtualFolder(this, node,
-                                                                       node.getName()));
-                                       }
-                               }
-                               return super.getChildren();
-                       } catch (RepositoryException e) {
-                               throw new ArgeoException(
-                                               "Cannot initialize WorkspaceNode UI object."
-                                                               + getName(), e);
-                       }
-               }
-       }
-
-       // @Override
-       // public boolean refreshPassedStatus() {
-       // Object[] children = getChildren();
-       // isPassed = true;
-       // checkChildrenStatus: for (int i = 0; i <= children.length; i++) {
-       // if (children[i] instanceof VirtualFolder) {
-       //
-       // }
-       // if (!((ResultParent) children[i]).isPassed()) {
-       // isPassed = false;
-       // break checkChildrenStatus;
-       // }
-       // }
-       // return isPassed;
-       // }
-
        @Override
        protected void initialize() {
-               // TODO Auto-generated method stub
+               if (children != null)
+                       for (ResultParent child : children)
+                               addChild(child);
        }
 
+       public void resetChildren(ResultParent[] children) {
+               clearChildren();
+               this.children = children;
+               initialize();
+       }
 }
\ No newline at end of file
index a00548a2c3d069aa1bd585775c92cc18a29881e2..ea0e85a445106a1646ccdb44dfdf2541257c8bd3 100644 (file)
@@ -1,6 +1,7 @@
 package org.argeo.slc.client.ui.views;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Calendar;\r
 import java.util.List;\r
 \r
 import javax.jcr.Node;\r
@@ -11,6 +12,7 @@ import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;\r
 import javax.jcr.Session;\r
 import javax.jcr.Value;\r
+import javax.jcr.nodetype.NodeType;\r
 import javax.jcr.observation.Event;\r
 import javax.jcr.observation.EventListener;\r
 import javax.jcr.observation.ObservationManager;\r
@@ -25,10 +27,12 @@ import org.argeo.jcr.UserJcrUtils;
 import org.argeo.slc.SlcException;\r
 import org.argeo.slc.client.ui.ClientUiPlugin;\r
 import org.argeo.slc.client.ui.commands.AddResultFolder;\r
+import org.argeo.slc.client.ui.model.ParentNodeFolder;\r
 import org.argeo.slc.client.ui.model.ResultFolder;\r
 import org.argeo.slc.client.ui.model.ResultParent;\r
-import org.argeo.slc.client.ui.model.SimpleNodeFolder;\r
+import org.argeo.slc.client.ui.model.ResultParentUtils;\r
 import org.argeo.slc.client.ui.model.SingleResultNode;\r
+import org.argeo.slc.client.ui.model.VirtualFolder;\r
 import org.argeo.slc.client.ui.providers.ResultTreeContentProvider;\r
 import org.argeo.slc.client.ui.providers.ResultTreeLabelProvider;\r
 import org.argeo.slc.jcr.SlcJcrResultUtils;\r
@@ -82,7 +86,13 @@ public class JcrResultTreeView extends ViewPart {
 \r
        private EventListener resultsObserver = null;\r
 \r
-       private final static String[] observedNodeTypes = { SlcTypes.SLC_TEST_RESULT };\r
+       private final static String[] observedNodeTypes = {\r
+                       SlcTypes.SLC_TEST_RESULT, SlcTypes.SLC_RESULT_FOLDER,\r
+                       NodeType.NT_UNSTRUCTURED };\r
+\r
+       // FIXME cache to ease refresh after D&D\r
+       private ResultParent lastSelectedElement;\r
+       private ResultParent lastSelectedElementParent;\r
 \r
        /**\r
         * To be overridden to adapt size of form and result frames.\r
@@ -114,23 +124,6 @@ public class JcrResultTreeView extends ViewPart {
 \r
                // Refresh the view to initialize it\r
                refresh(null);\r
-\r
-               try {\r
-                       ObservationManager observationManager = session.getWorkspace()\r
-                                       .getObservationManager();\r
-                       // FIXME Will not be notified if empty result is deleted\r
-                       if (UserJcrUtils.getUserHome(session) != null) {\r
-                               resultsObserver = new ResultObserver(resultTreeViewer.getTree()\r
-                                               .getDisplay());\r
-                               observationManager.addEventListener(resultsObserver,\r
-                                               Event.PROPERTY_ADDED | Event.NODE_REMOVED, UserJcrUtils\r
-                                                               .getUserHome(session).getPath(), true, null,\r
-                                               observedNodeTypes, false);\r
-                       }\r
-               } catch (RepositoryException e) {\r
-                       throw new SlcException("Cannot register listeners", e);\r
-               }\r
-\r
        }\r
 \r
        // The main tree viewer\r
@@ -183,10 +176,12 @@ public class JcrResultTreeView extends ViewPart {
                                                                                .getNode());\r
                                        else\r
                                                propertiesViewer.setInput(null);\r
+                                       lastSelectedElement = (ResultParent) firstItem;\r
+                                       lastSelectedElementParent = (ResultParent) ((ResultParent) firstItem)\r
+                                                       .getParent();\r
                                }\r
                        }\r
                });\r
-\r
                return viewer;\r
        }\r
 \r
@@ -308,16 +303,13 @@ public class JcrResultTreeView extends ViewPart {
                if (resultParent == null) {\r
                        resultTreeViewer.setInput(initializeResultTree());\r
                        if (resultsObserver == null) {\r
-                               // force initialization of the resultsObserver, only useful\r
-                               // if the current view has been displayed before a single\r
-                               // test has been run\r
                                try {\r
                                        ObservationManager observationManager = session\r
                                                        .getWorkspace().getObservationManager();\r
                                        resultsObserver = new ResultObserver(resultTreeViewer\r
                                                        .getTree().getDisplay());\r
                                        observationManager.addEventListener(resultsObserver,\r
-                                                       Event.PROPERTY_ADDED | Event.NODE_REMOVED, UserJcrUtils\r
+                                                       Event.NODE_ADDED | Event.NODE_REMOVED, UserJcrUtils\r
                                                                        .getUserHome(session).getPath(), true,\r
                                                        null, observedNodeTypes, false);\r
                                } catch (RepositoryException e) {\r
@@ -331,21 +323,63 @@ public class JcrResultTreeView extends ViewPart {
                                ResultFolder currFolder = (ResultFolder) resultParent;\r
                                jcrRefresh(currFolder.getNode());\r
                                currFolder.forceFullRefresh();\r
+                               resultTreeViewer.refresh(lastSelectedElement);\r
                        }\r
                }\r
        }\r
 \r
        private ResultParent[] initializeResultTree() {\r
-               ResultParent[] roots = new ResultParent[2];\r
                try {\r
-                       roots[0] = new ResultFolder(null,\r
-                                       SlcJcrResultUtils.getMyResultParentNode(session),\r
-                                       "My results");\r
-                       Node otherResultsPar = session.getNode(SlcJcrResultUtils\r
-                                       .getSlcResultsBasePath(session));\r
-                       roots[1] = new SimpleNodeFolder(null, otherResultsPar,\r
-                                       "All results");\r
-                       return roots;\r
+                       if (session.nodeExists(SlcJcrResultUtils\r
+                                       .getSlcResultsBasePath(session))) {\r
+                               ResultParent[] roots = new ResultParent[5];\r
+\r
+                               // My results\r
+                               roots[0] = new ParentNodeFolder(null,\r
+                                               SlcJcrResultUtils.getMyResultParentNode(session),\r
+                                               "My results");\r
+\r
+                               // today\r
+                               Calendar cal = Calendar.getInstance();\r
+                               String relPath = JcrUtils.dateAsPath(cal);\r
+                               List<String> datePathes = new ArrayList<String>();\r
+                               datePathes.add(relPath);\r
+                               roots[1] = new VirtualFolder(null,\r
+                                               ResultParentUtils.getResultsForDates(session,\r
+                                                               datePathes), "Today");\r
+\r
+                               // Yesterday\r
+                               cal = Calendar.getInstance();\r
+                               cal.add(Calendar.DAY_OF_YEAR, -1);\r
+                               relPath = JcrUtils.dateAsPath(cal);\r
+                               datePathes = new ArrayList<String>();\r
+                               datePathes.add(relPath);\r
+                               roots[2] = new VirtualFolder(null,\r
+                                               ResultParentUtils.getResultsForDates(session,\r
+                                                               datePathes), "Yesterday");\r
+                               // Last 7 days\r
+\r
+                               cal = Calendar.getInstance();\r
+                               datePathes = new ArrayList<String>();\r
+\r
+                               for (int i = 0; i < 7; i++) {\r
+                                       cal.add(Calendar.DAY_OF_YEAR, -i);\r
+                                       relPath = JcrUtils.dateAsPath(cal);\r
+                                       datePathes.add(relPath);\r
+                               }\r
+                               roots[3] = new VirtualFolder(null,\r
+                                               ResultParentUtils.getResultsForDates(session,\r
+                                                               datePathes), "Last 7 days");\r
+\r
+                               // All results\r
+                               Node otherResultsPar = session.getNode(SlcJcrResultUtils\r
+                                               .getSlcResultsBasePath(session));\r
+                               roots[4] = new ParentNodeFolder(null, otherResultsPar,\r
+                                               "All results");\r
+                               return roots;\r
+                       } else\r
+                               // no test has yet been processed, we leave the viewer blank\r
+                               return null;\r
                } catch (RepositoryException re) {\r
                        throw new ArgeoException(\r
                                        "Unexpected error while initializing ResultTree.", re);\r
@@ -367,13 +401,15 @@ public class JcrResultTreeView extends ViewPart {
                if (selection.size() == 1) {\r
                        Object obj = selection.getFirstElement();\r
                        try {\r
-                               Node targetParentNode = null;\r
-                               if (obj instanceof ResultFolder) {\r
-                                       targetParentNode = ((ResultFolder) obj).getNode();\r
-\r
-                                       if (targetParentNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))\r
-                                               isMyResultFolder = true;\r
-                               }\r
+                               if (obj instanceof ResultFolder\r
+                                               && (((ResultFolder) obj).getNode())\r
+                                                               .isNodeType(SlcTypes.SLC_RESULT_FOLDER))\r
+                                       isMyResultFolder = true;\r
+                               else if (obj instanceof ParentNodeFolder\r
+                                               && (((ParentNodeFolder) obj).getNode().getPath()\r
+                                                               .startsWith(SlcJcrResultUtils\r
+                                                                               .getMyResultsBasePath(session))))\r
+                                       isMyResultFolder = true;\r
                        } catch (RepositoryException re) {\r
                                throw new SlcException(\r
                                                "unexpected error while building condition for context menu",\r
@@ -456,20 +492,30 @@ public class JcrResultTreeView extends ViewPart {
                                // We can only drop under myResults\r
                                Node targetParentNode = null;\r
                                if (target instanceof ResultFolder) {\r
-                                       Node currNode = ((ResultFolder) target).getNode();\r
-\r
-                                       if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {\r
-                                               targetParentNode = currNode;\r
-                                       }\r
+                                       targetParentNode = ((ResultFolder) target).getNode();\r
+                               } else if (target instanceof ParentNodeFolder) {\r
+                                       if ((((ParentNodeFolder) target).getNode().getPath()\r
+                                                       .startsWith(SlcJcrResultUtils\r
+                                                                       .getMyResultsBasePath(session))))\r
+                                               targetParentNode = ((ParentNodeFolder) target)\r
+                                                               .getNode();\r
                                } else if (target instanceof SingleResultNode) {\r
                                        Node currNode = ((SingleResultNode) target).getNode();\r
-                                       if (currNode.getParent().isNodeType(\r
-                                                       SlcTypes.SLC_RESULT_FOLDER))\r
+                                       if (currNode\r
+                                                       .getParent()\r
+                                                       .getPath()\r
+                                                       .startsWith(\r
+                                                                       SlcJcrResultUtils\r
+                                                                                       .getMyResultsBasePath(session)))\r
                                                targetParentNode = currNode.getParent();\r
                                }\r
                                if (targetParentNode != null) {\r
                                        currParentNode = targetParentNode;\r
                                        validDrop = true;\r
+                                       // FIXME\r
+                                       lastSelectedElement = (ResultParent) target;\r
+                                       lastSelectedElementParent = (ResultParent) ((ResultParent) target)\r
+                                                       .getParent();\r
                                }\r
                        } catch (RepositoryException re) {\r
                                throw new SlcException(\r
@@ -486,7 +532,7 @@ public class JcrResultTreeView extends ViewPart {
                                Node target = currParentNode.addNode(source.getName(), source\r
                                                .getPrimaryNodeType().getName());\r
                                JcrUtils.copy(source, target);\r
-                               updatePassedStatus(target, target.getNode(SlcNames.SLC_STATUS)\r
+                               ResultParentUtils.updatePassedStatus(target, target.getNode(SlcNames.SLC_STATUS)\r
                                                .getProperty(SlcNames.SLC_SUCCESS).getBoolean());\r
                                target.getSession().save();\r
                        } catch (RepositoryException re) {\r
@@ -495,59 +541,6 @@ public class JcrResultTreeView extends ViewPart {
                        }\r
                        return true;\r
                }\r
-\r
-               /**\r
-                * recursively update passed status of the parent ResultFolder and its\r
-                * parent if needed\r
-                * \r
-                * @param node\r
-                *            cannot be null\r
-                * \r
-                */\r
-               private void updatePassedStatus(Node node, boolean passed) {\r
-                       try {\r
-                               Node pNode = node.getParent();\r
-                               boolean pStatus = pNode.getNode(SlcNames.SLC_STATUS)\r
-                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
-                               if (pStatus == passed)\r
-                                       // nothing to update\r
-                                       return;\r
-                               else if (!passed) {\r
-                                       // error we only update status of the result folder and its\r
-                                       // parent if needed\r
-                                       pNode.getNode(SlcNames.SLC_STATUS).setProperty(\r
-                                                       SlcNames.SLC_SUCCESS, passed);\r
-                                       updatePassedStatus(pNode, passed);\r
-                               } else {\r
-                                       // success we must first check if all siblings have also\r
-                                       // successfully completed\r
-                                       boolean success = true;\r
-                                       NodeIterator ni = pNode.getNodes();\r
-                                       children: while (ni.hasNext()) {\r
-                                               Node currNode = ni.nextNode();\r
-                                               if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode\r
-                                                               .isNodeType(SlcTypes.SLC_RESULT_FOLDER))\r
-                                                               && !currNode.getNode(SlcNames.SLC_STATUS)\r
-                                                                               .getProperty(SlcNames.SLC_SUCCESS)\r
-                                                                               .getBoolean()) {\r
-                                                       success = false;\r
-                                                       break children;\r
-                                               }\r
-                                       }\r
-                                       if (success) {\r
-                                               pNode.getNode(SlcNames.SLC_STATUS).setProperty(\r
-                                                               SlcNames.SLC_SUCCESS, passed);\r
-                                               updatePassedStatus(pNode, passed);\r
-                                       } else\r
-                                               // one of the siblings had also the failed status so\r
-                                               // above tree remains unchanged.\r
-                                               return;\r
-                               }\r
-\r
-                       } catch (RepositoryException e) {\r
-                               throw new SlcException("Cannot register listeners", e);\r
-                       }\r
-               }\r
        }\r
 \r
        class ResultObserver extends AsyncUiEventListener {\r
@@ -559,31 +552,72 @@ public class JcrResultTreeView extends ViewPart {
                @Override\r
                protected Boolean willProcessInUiThread(List<Event> events)\r
                                throws RepositoryException {\r
+                       // unfiltered for the time being\r
+                       return true;\r
+                       // for (Event event : events) {\r
+                       // getLog().debug("Received event " + event);\r
+                       // int eventType = event.getType();\r
+                       // if (eventType == Event.NODE_REMOVED)\r
+                       // ;//return true;\r
+                       // String path = event.getPath();\r
+                       // int index = path.lastIndexOf('/');\r
+                       // String propertyName = path.substring(index + 1);\r
+                       // if (propertyName.equals(SlcNames.SLC_COMPLETED)\r
+                       // || propertyName.equals(SlcNames.SLC_UUID)) {\r
+                       // ;//return true;\r
+                       // }\r
+                       // }\r
+                       // return false;\r
+               }\r
+\r
+               protected void onEventInUiThread(List<Event> events)\r
+                               throws RepositoryException {\r
+\r
                        for (Event event : events) {\r
-                               // getLog().debug("Received event " + event);\r
+                                getLog().debug("Received event " + event);\r
                                int eventType = event.getType();\r
-                               if (eventType == Event.NODE_REMOVED)\r
-                                       return true;\r
-                               String path = event.getPath();\r
-                               int index = path.lastIndexOf('/');\r
-                               String propertyName = path.substring(index + 1);\r
-                               if (propertyName.equals(SlcNames.SLC_COMPLETED)\r
-                                               || propertyName.equals(SlcNames.SLC_UUID)) {\r
-                                       return true;\r
+                               if (eventType == Event.NODE_REMOVED) {\r
+                                       String path = event.getPath();\r
+                                       int index = path.lastIndexOf('/');\r
+                                       String parPath = path.substring(0, index + 1);\r
+                                       if (session.nodeExists(parPath)) {\r
+                                               Node currNode = session.getNode(parPath);\r
+                                               if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED)) {\r
+                                                       refresh(null);\r
+                                                       jcrRefresh(currNode);\r
+                                                       resultTreeViewer.refresh(true);\r
+                                                       resultTreeViewer.expandToLevel(\r
+                                                                       lastSelectedElementParent, 1);\r
+                                                       \r
+                                               }\r
+                                       }\r
+                               } else if (eventType == Event.NODE_ADDED) {\r
+                                       String path = event.getPath();\r
+                                       if (session.nodeExists(path)) {\r
+                                               Node currNode = session.getNode(path);\r
+                                               if (currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT)\r
+                                                               || currNode\r
+                                                                               .isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {\r
+                                                       refresh(null);\r
+                                                       resultTreeViewer.expandToLevel(lastSelectedElement,\r
+                                                                       1);\r
+                                               }\r
+                                       }\r
                                }\r
+                               // String path = event.getPath();\r
+                               // int index = path.lastIndexOf('/');\r
+                               // String propertyName = path.substring(index + 1);\r
+                               // if (propertyName.equals(SlcNames.SLC_COMPLETED)\r
+                               // || propertyName.equals(SlcNames.SLC_UUID)) {\r
+                               // }\r
                        }\r
-                       return false;\r
-               }\r
 \r
-               protected void onEventInUiThread(List<Event> events)\r
-                               throws RepositoryException {\r
                        // FIXME implement correct behaviour. treeViewer selection is\r
                        // disposed by the drag & drop.\r
                        // resultTreeViewer.refresh();\r
                        // refresh(null);\r
                        // log.warn("Implement refresh.");\r
                }\r
-\r
        }\r
 \r
        class PropertiesContentProvider implements IStructuredContentProvider {\r
index 6c36aa949527bf94bfd76814238f3ac0d702cafa..4cf955c1d87f23bd5c4e97efa84bbac0d4a76c20 100644 (file)
@@ -30,5 +30,5 @@ public interface SlcJcrConstants {
        /*
         * SLC SPECIFIC JCR PATHS
         */
-       public final static String SLC_MYRESULT_BASEPATH = "slc:myResults/";
+       public final static String SLC_MYRESULT_BASEPATH = "slc:myResults";
 }
index 0f07fe56729444c2a40a829101994d843bd4e591..ca9dabfe77f1c8a7fa86a3276319c11e196f06ca 100644 (file)
@@ -18,7 +18,9 @@ package org.argeo.slc.jcr;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
 
+import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.argeo.ArgeoException;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.jcr.UserJcrUtils;
@@ -58,20 +60,36 @@ public class SlcJcrResultUtils {
                }
        }
 
+       /**
+        * Creates a new node with type NodeType.NT_UNSTRUCTURED at the given
+        * absolute path. If a node already exists at the given path, returns that
+        * node if it has the correct type and throws an exception otherwise.
+        * 
+        * @param session
+        * @return
+        */
        public static Node getMyResultParentNode(Session session) {
                try {
-                       if (session.nodeExists(SlcJcrResultUtils
-                                       .getMyResultsBasePath(session)))
-                               return session.getNode(getMyResultsBasePath(session));
-                       else
-                               return createResultFolderNode(session,
-                                               getMyResultsBasePath(session));
+                       String absPath = getMyResultsBasePath(session);
+                       if (session.nodeExists(absPath)) {
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       } else {
+                               Node myResParNode = JcrUtils.mkdirs(session, absPath);
+                               myResParNode.setPrimaryType(NodeType.NT_UNSTRUCTURED);
+                               session.save();
+                               return myResParNode;
+                       }
                } catch (RepositoryException re) {
                        throw new ArgeoException(
                                        "Unexpected error while creating user MyResult base node.",
                                        re);
                }
-
        }
 
        /**