+ fix bugs before release
authorBruno Sinou <bsinou@argeo.org>
Thu, 17 Jan 2013 20:15:23 +0000 (20:15 +0000)
committerBruno Sinou <bsinou@argeo.org>
Thu, 17 Jan 2013 20:15:23 +0000 (20:15 +0000)
+ enhance treeViewer

git-svn-id: https://svn.argeo.org/slc/trunk@6040 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

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
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/views/JcrResultTreeView.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/JcrTestResult.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrResultUtils.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcNames.java
runtime/org.argeo.slc.support.jcr/src/main/resources/org/argeo/slc/jcr/slc.cnd

index 429dcedd55dd51e1c6db0ecb2d2c780ad9549bf4..c564492d889f87b6c6febef4e210f5e7a861b8d9 100644 (file)
@@ -38,8 +38,8 @@ public class ResultFolder extends ParentNodeFolder {
                super(parent, node, name);
                try {
                        // initialize passed status if possible
-                       if (node.hasNode(SlcNames.SLC_STATUS))
-                               setPassed(node.getNode(SlcNames.SLC_STATUS)
+                       if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
+                               setPassed(node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
                                                .getProperty(SlcNames.SLC_SUCCESS).getBoolean());
                } catch (RepositoryException re) {
                        throw new SlcException(
index d569167dc9c1b0e9e6e435fed81f153a1f3b5aa5..2d93b2619cfb7fa1dd4e1c35e0a5bf38b5bb62a7 100644 (file)
@@ -77,7 +77,7 @@ public class ResultParentUtils {
                        Iterator<String> it = dateRelPathes.iterator();
                        StringBuffer clause = new StringBuffer();
                        clause.append("SELECT * FROM [");
-                       clause.append(SlcTypes.SLC_DIFF_RESULT);
+                       clause.append(SlcTypes.SLC_TEST_RESULT);
                        clause.append("] as results");
                        clause.append(" WHERE ");
                        while (it.hasNext()) {
@@ -119,11 +119,11 @@ public class ResultParentUtils {
         */
        public static void updatePassedStatus(Node node, boolean passed) {
                try {
-                       if (!node.hasNode(SlcNames.SLC_STATUS))
+                       if (!node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
                                // we have reached the root of the tree. stop the
                                // recursivity
                                return;
-                       boolean pStatus = node.getNode(SlcNames.SLC_STATUS)
+                       boolean pStatus = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
                                        .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
                        if (pStatus == passed)
                                // nothing to update
@@ -132,7 +132,7 @@ public class ResultParentUtils {
                                // New status is 'failed' : we only update status of the result
                                // folder and its
                                // parent if needed
-                               node.getNode(SlcNames.SLC_STATUS).setProperty(
+                               node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
                                                SlcNames.SLC_SUCCESS, passed);
                                updatePassedStatus(node.getParent(), passed);
                        } else {
@@ -145,7 +145,8 @@ public class ResultParentUtils {
                                        Node currNode = ni.nextNode();
                                        if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode
                                                        .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-                                                       && !currNode.getNode(SlcNames.SLC_STATUS)
+                                                       && !currNode
+                                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS)
                                                                        .getProperty(SlcNames.SLC_SUCCESS)
                                                                        .getBoolean()) {
                                                success = false;
@@ -153,7 +154,7 @@ public class ResultParentUtils {
                                        }
                                }
                                if (success) {
-                                       node.getNode(SlcNames.SLC_STATUS).setProperty(
+                                       node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
                                                        SlcNames.SLC_SUCCESS, passed);
                                        updatePassedStatus(node.getParent(), passed);
                                } else
index d587a932195cf1b49e0e71c4db5e3180426e9649..afd1249898858f82452d877f2b83ebfe55ba1466 100644 (file)
@@ -50,8 +50,8 @@ public class SingleResultNode extends ResultParent implements
        public boolean refreshPassedStatus() {
                try {
                        Node check;
-                       if (node.hasNode(SlcNames.SLC_STATUS)) {
-                               check = node.getNode(SlcNames.SLC_STATUS);
+                       if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
+                               check = node.getNode(SlcNames.SLC_AGGREGATED_STATUS);
                                passed = check.getProperty(SlcNames.SLC_SUCCESS).getBoolean();
                                return passed;
                        } else
index 8fcea20aa0ecb23def8c1ffcc2270c2c468f18e2..99d131d8fb50c3fcf3079200b9d5660351de6bd8 100644 (file)
@@ -19,6 +19,7 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.Calendar;\r
+import java.util.Iterator;\r
 import java.util.List;\r
 \r
 import javax.jcr.Node;\r
@@ -31,6 +32,8 @@ import javax.jcr.observation.Event;
 import javax.jcr.observation.EventListener;\r
 import javax.jcr.observation.ObservationManager;\r
 \r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
 import org.argeo.ArgeoException;\r
 import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;\r
 import org.argeo.eclipse.ui.utils.CommandUtils;\r
@@ -53,13 +56,13 @@ import org.argeo.slc.client.ui.model.SingleResultNode;
 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.client.ui.wizards.ConfirmOverwriteWizard;\r
 import org.argeo.slc.jcr.SlcJcrResultUtils;\r
 import org.argeo.slc.jcr.SlcNames;\r
 import org.argeo.slc.jcr.SlcTypes;\r
 import org.eclipse.jface.action.IMenuListener;\r
 import org.eclipse.jface.action.IMenuManager;\r
 import org.eclipse.jface.action.MenuManager;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
 import org.eclipse.jface.viewers.ColumnLabelProvider;\r
 import org.eclipse.jface.viewers.DecoratingLabelProvider;\r
 import org.eclipse.jface.viewers.DoubleClickEvent;\r
@@ -75,7 +78,6 @@ import org.eclipse.jface.viewers.TreePath;
 import org.eclipse.jface.viewers.TreeViewer;\r
 import org.eclipse.jface.viewers.Viewer;\r
 import org.eclipse.jface.viewers.ViewerDropAdapter;\r
-import org.eclipse.jface.wizard.WizardDialog;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.SashForm;\r
 import org.eclipse.swt.dnd.DND;\r
@@ -103,8 +105,7 @@ public class JcrResultTreeView extends ViewPart {
        private final static DateFormat dateFormat = new SimpleDateFormat(\r
                        SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);\r
 \r
-       // private final static Log log =\r
-       // LogFactory.getLog(JcrResultTreeView.class);\r
+       private final static Log log = LogFactory.getLog(JcrResultTreeView.class);\r
 \r
        /* DEPENDENCY INJECTION */\r
        private Session session;\r
@@ -125,10 +126,10 @@ public class JcrResultTreeView extends ViewPart {
                        SlcTypes.SLC_TEST_RESULT, NodeType.NT_UNSTRUCTURED };\r
 \r
        // FIXME cache to ease D&D\r
-       private boolean isActionUnderMyResult = false;\r
+       // private boolean isActionUnderMyResult = false;\r
        // private ResultParent lastSelectedTargetElement;\r
-       private ResultParent lastSelectedSourceElement;\r
-       private ResultParent lastSelectedSourceElementParent;\r
+       // private ResultParent lastSelectedSourceElement;\r
+       // private ResultParent lastSelectedSourceElementParent;\r
        private boolean isResultFolder = false;\r
 \r
        // FIXME we cache the fact that we are moving a node to avoid exception\r
@@ -276,7 +277,7 @@ public class JcrResultTreeView extends ViewPart {
                                        else if (SlcNames.SLC_MESSAGE.equals(name))\r
                                                value = "Message";\r
                                        else if (SlcNames.SLC_ERROR_MESSAGE.equals(name))\r
-                                                       value = "Error";\r
+                                               value = "Error";\r
                                        return value;\r
                                } catch (RepositoryException e) {\r
                                        throw new ArgeoException(\r
@@ -395,7 +396,7 @@ public class JcrResultTreeView extends ViewPart {
                boolean isPassed = true;\r
                try {\r
                        if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {\r
-                               isPassed = node.getNode(SlcNames.SLC_STATUS)\r
+                               isPassed = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)\r
                                                .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
                        } else if (node.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {\r
                                NodeIterator ni = node.getNodes();\r
@@ -403,9 +404,9 @@ public class JcrResultTreeView extends ViewPart {
                                        Node currChild = ni.nextNode();\r
                                        isPassed = isPassed & jcrRefresh(currChild);\r
                                }\r
-                               if (isPassed != node.getNode(SlcNames.SLC_STATUS)\r
+                               if (isPassed != node.getNode(SlcNames.SLC_AGGREGATED_STATUS)\r
                                                .getProperty(SlcNames.SLC_SUCCESS).getBoolean()) {\r
-                                       node.getNode(SlcNames.SLC_STATUS).setProperty(\r
+                                       node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(\r
                                                        SlcNames.SLC_SUCCESS, isPassed);\r
                                        node.getSession().save();\r
                                        return isPassed;\r
@@ -537,29 +538,41 @@ public class JcrResultTreeView extends ViewPart {
                        IStructuredSelection selection = (IStructuredSelection) resultTreeViewer\r
                                        .getSelection();\r
                        boolean doIt = false;\r
-                       // only one node at a time for the time being.\r
-                       if (selection.size() == 1) {\r
-                               try {\r
+\r
+                       // FIXME clean this code.\r
+                       try {\r
+                               if (selection.size() == 1) {\r
                                        Object obj = selection.getFirstElement();\r
-                                       if (obj instanceof SingleResultNode) {\r
-                                               Node tNode = ((SingleResultNode) obj).getNode();\r
-                                               if (tNode.getPrimaryNodeType().isNodeType(\r
-                                                               SlcTypes.SLC_TEST_RESULT)) {\r
-                                                       doIt = true;\r
-                                                       isResultFolder = false;\r
-                                               }\r
-                                       } else if (obj instanceof ResultFolder) {\r
+                                       if (obj instanceof ResultFolder) {\r
                                                Node tNode = ((ResultFolder) obj).getNode();\r
                                                if (tNode.getPrimaryNodeType().isNodeType(\r
                                                                SlcTypes.SLC_RESULT_FOLDER)) {\r
                                                        doIt = true;\r
                                                        isResultFolder = true;\r
                                                }\r
+                                       } else\r
+                                               isResultFolder = false;\r
+                               } else\r
+                                       isResultFolder = false;\r
+\r
+                               if (!isResultFolder) {\r
+                                       @SuppressWarnings("rawtypes")\r
+                                       Iterator it = selection.iterator();\r
+                                       while (it.hasNext()) {\r
+                                               Object obj = it.next();\r
+                                               if (obj instanceof SingleResultNode) {\r
+                                                       Node tNode = ((SingleResultNode) obj).getNode();\r
+                                                       if (tNode.getPrimaryNodeType().isNodeType(\r
+                                                                       SlcTypes.SLC_TEST_RESULT)) {\r
+                                                               doIt = true;\r
+                                                       }\r
+                                               }\r
                                        }\r
-                               } catch (RepositoryException re) {\r
-                                       throw new SlcException(\r
-                                                       "unexpected error while validating drag source", re);\r
                                }\r
+\r
+                       } catch (RepositoryException re) {\r
+                               throw new SlcException(\r
+                                               "unexpected error while validating drag source", re);\r
                        }\r
                        event.doit = doIt;\r
                }\r
@@ -567,15 +580,27 @@ public class JcrResultTreeView extends ViewPart {
                public void dragSetData(DragSourceEvent event) {\r
                        IStructuredSelection selection = (IStructuredSelection) resultTreeViewer\r
                                        .getSelection();\r
-                       Object obj = selection.getFirstElement();\r
+\r
                        try {\r
-                               Node first;\r
-                               if (obj instanceof SingleResultNode) {\r
-                                       first = ((SingleResultNode) obj).getNode();\r
-                                       event.data = first.getIdentifier();\r
-                               } else if (obj instanceof ResultFolder) {\r
-                                       first = ((ResultFolder) obj).getNode();\r
-                                       event.data = first.getIdentifier();\r
+                               // specific case of a result folder\r
+                               if (isResultFolder) {\r
+                                       Object obj = selection.getFirstElement();\r
+                                       event.data = ((ResultFolder) obj).getNode().getIdentifier();\r
+                               } else {\r
+                                       @SuppressWarnings("rawtypes")\r
+                                       Iterator it = selection.iterator();\r
+                                       StringBuffer nodes = new StringBuffer();\r
+                                       while (it.hasNext()) {\r
+                                               Object obj = it.next();\r
+                                               if (obj instanceof SingleResultNode) {\r
+                                                       Node tNode = ((SingleResultNode) obj).getNode();\r
+                                                       if (tNode.getPrimaryNodeType().isNodeType(\r
+                                                                       SlcTypes.SLC_TEST_RESULT)) {\r
+                                                               nodes.append(tNode.getIdentifier() + ";");\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       event.data = nodes.toString();\r
                                }\r
                        } catch (RepositoryException re) {\r
                                throw new SlcException("unexpected error while setting data",\r
@@ -618,31 +643,8 @@ public class JcrResultTreeView extends ViewPart {
                                }\r
 \r
                                if (tpNode != null) {\r
-                                       // Sanity check : we cannot move a folder to one of its sub\r
-                                       // folder or neither move an object in the same parent\r
-                                       // folder\r
-                                       boolean doit = true;\r
-                                       Node source = null;\r
-                                       if (isResultFolder) {\r
-                                               source = ((ParentNodeFolder) lastSelectedSourceElement)\r
-                                                               .getNode();\r
-                                               if (tpNode.getPath().startsWith(source.getPath())\r
-                                                               || source.getParent().getPath()\r
-                                                                               .equals(tpNode.getPath()))\r
-                                                       doit = false;\r
-                                       } else if (lastSelectedSourceElement instanceof SingleResultNode) {\r
-                                               source = ((SingleResultNode) lastSelectedSourceElement)\r
-                                                               .getNode();\r
-                                               String sourceParentPath = JcrUtils.parentPath(source\r
-                                                               .getPath());\r
-                                               if (tpNode.getPath().equals(sourceParentPath))\r
-                                                       doit = false;\r
-                                       }\r
-                                       if (doit) {\r
-                                               targetParentNode = tpNode;\r
-                                               validDrop = true;\r
-                                               // lastSelectedTargetElement = (ResultParent) target;\r
-                                       }\r
+                                       targetParentNode = tpNode;\r
+                                       validDrop = true;\r
                                }\r
                        } catch (RepositoryException re) {\r
                                throw new SlcException(\r
@@ -656,65 +658,171 @@ public class JcrResultTreeView extends ViewPart {
                        // clear selection to prevent unwanted scrolling of the UI\r
                        resultTreeViewer.setSelection(null);\r
                        try {\r
-                               Node source = session.getNodeByIdentifier((String) data);\r
-\r
-                               String name;\r
-                               if (source.hasProperty(Property.JCR_TITLE))\r
-                                       name = source.getProperty(Property.JCR_TITLE).getString();\r
-                               else if (source.hasProperty(SlcNames.SLC_TEST_CASE))\r
-                                       name = source.getProperty(SlcNames.SLC_TEST_CASE)\r
-                                                       .getString();\r
-                               else\r
-                                       name = source.getName();\r
-\r
-                               // Check if a user defined folder result with same name exists\r
-                               // at target\r
-                               if (targetParentNode.hasNode(name)\r
-                                               && targetParentNode.getNode(name).isNodeType(\r
-                                                               SlcTypes.SLC_RESULT_FOLDER)) {\r
-                                       ConfirmOverwriteWizard wizard = new ConfirmOverwriteWizard(\r
-                                                       name, targetParentNode);\r
-                                       WizardDialog dialog = new WizardDialog(Display.getDefault()\r
-                                                       .getActiveShell(), wizard);\r
-\r
-                                       if (dialog.open() == WizardDialog.CANCEL)\r
-                                               return true;\r
-\r
-                                       if (wizard.overwrite()) {\r
-                                               targetParentNode.getNode(name).remove();\r
-                                               // session.save();\r
-                                       } else\r
-                                               name = wizard.newName();\r
-                               }\r
+                               if (isResultFolder) {\r
+                                       // Sanity check : we cannot move a folder to one of its sub\r
+                                       // folder or neither move an object in the same parent\r
+                                       // folder\r
+                                       Node source = session.getNodeByIdentifier((String) data);\r
+                                       if (targetParentNode.getPath().startsWith(source.getPath())\r
+                                                       || source.getParent().getPath()\r
+                                                                       .equals(targetParentNode.getPath()))\r
+                                               return false;\r
 \r
-                               Node target;\r
-                               boolean passedStatus = source.getNode(SlcNames.SLC_STATUS)\r
-                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
-                               if (!isActionUnderMyResult) {// Copy\r
-                                       target = targetParentNode.addNode(source.getName(), source\r
-                                                       .getPrimaryNodeType().getName());\r
-                                       JcrUtils.copy(source, target);\r
-                               } else {// move\r
+                                       // Move\r
                                        String sourcePath = source.getPath();\r
-                                       String destPath = targetParentNode.getPath() + "/" + name;\r
+                                       String destPath = targetParentNode.getPath() + "/"\r
+                                                       + source.getName();\r
                                        session.move(sourcePath, destPath);\r
-                                       // session.save();\r
                                        // Update passed status of the parent source Node\r
                                        ResultParentUtils.updatePassedStatus(\r
                                                        session.getNode(JcrUtils.parentPath(sourcePath)),\r
                                                        true);\r
-                                       target = session.getNode(destPath);\r
+                                       Node target = session.getNode(destPath);\r
+                                       session.save();\r
+                                       return true;\r
+                               }\r
+\r
+                               String[] datas = ((String) data).split(";");\r
+                               nodesToCopy: for (String id : datas) {\r
+\r
+                                       Node source = session.getNodeByIdentifier(id);\r
+                                       String name;\r
+                                       if (source.hasProperty(Property.JCR_TITLE))\r
+                                               name = source.getProperty(Property.JCR_TITLE)\r
+                                                               .getString();\r
+                                       else if (source.hasProperty(SlcNames.SLC_TEST_CASE))\r
+                                               name = source.getProperty(SlcNames.SLC_TEST_CASE)\r
+                                                               .getString();\r
+                                       else\r
+                                               name = source.getName();\r
+\r
+                                       // Check if another copy of the same test instance already\r
+                                       // exists at target\r
+                                       NodeIterator ni = targetParentNode.getNodes();\r
+                                       String slcUid = source.getProperty(SlcNames.SLC_UUID)\r
+                                                       .getString();\r
+                                       while (ni.hasNext()) {\r
+                                               Node curr = ni.nextNode();\r
+                                               if (curr.hasProperty(SlcNames.SLC_UUID)\r
+                                                               && slcUid.equals(curr.getProperty(\r
+                                                                               SlcNames.SLC_UUID).getString())) {\r
+                                                       MessageDialog\r
+                                                                       .openWarning(\r
+                                                                                       PlatformUI.getWorkbench()\r
+                                                                                                       .getDisplay()\r
+                                                                                                       .getActiveShell(),\r
+                                                                                       "Duplicated instance.",\r
+                                                                                       "An instance of the same test case ("\r
+                                                                                                       + name\r
+                                                                                                       + ") exists at destination.\n "\r
+                                                                                                       + "This item will not be neither copied nor moved.");\r
+                                                       continue nodesToCopy;\r
+\r
+                                               }\r
+                                       }\r
+\r
+                                       Node target;\r
+                                       boolean passedStatus = source\r
+                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS)\r
+                                                       .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
+\r
+                                       boolean isActionUnderMyResult = source.getPath()\r
+                                                       .startsWith(\r
+                                                                       SlcJcrResultUtils\r
+                                                                                       .getMyResultsBasePath(session));\r
+\r
+                                       if (!isActionUnderMyResult) {// Copy\r
+                                               target = targetParentNode.addNode(source.getName(),\r
+                                                               source.getPrimaryNodeType().getName());\r
+                                               JcrUtils.copy(source, target);\r
+                                       } else {// move\r
+                                               String sourcePath = source.getPath();\r
+                                               String destPath = targetParentNode.getPath() + "/"\r
+                                                               + name;\r
+                                               session.move(sourcePath, destPath);\r
+                                               // session.save();\r
+                                               // Update passed status of the parent source Node\r
+                                               ResultParentUtils\r
+                                                               .updatePassedStatus(session.getNode(JcrUtils\r
+                                                                               .parentPath(sourcePath)), true);\r
+                                               target = session.getNode(destPath);\r
+\r
+                                       }\r
+                                       if (!target.isNodeType(NodeType.MIX_TITLE))\r
+                                               target.addMixin(NodeType.MIX_TITLE);\r
+                                       target.setProperty(Property.JCR_TITLE, name);\r
+                                       ResultParentUtils.updatePassedStatus(target.getParent(),\r
+                                                       passedStatus);\r
+                                       session.save();\r
+\r
+                                       // try {\r
+                                       // Node source = session.getNodeByIdentifier(id);\r
+                                       // String name;\r
+                                       // if (source.hasProperty(Property.JCR_TITLE))\r
+                                       // name = source.getProperty(Property.JCR_TITLE)\r
+                                       // .getString();\r
+                                       // else if (source.hasProperty(SlcNames.SLC_TEST_CASE))\r
+                                       // name = source.getProperty(SlcNames.SLC_TEST_CASE)\r
+                                       // .getString();\r
+                                       // else\r
+                                       // name = source.getName();\r
+                                       //\r
+                                       // // Check if a user defined folder result with same name\r
+                                       // // exists\r
+                                       // // at target\r
+                                       // if (targetParentNode.hasNode(name)\r
+                                       // && targetParentNode.getNode(name).isNodeType(\r
+                                       // SlcTypes.SLC_RESULT_FOLDER)) {\r
+                                       // ConfirmOverwriteWizard wizard = new\r
+                                       // ConfirmOverwriteWizard(\r
+                                       // name, targetParentNode);\r
+                                       // WizardDialog dialog = new WizardDialog(Display\r
+                                       // .getDefault().getActiveShell(), wizard);\r
+                                       //\r
+                                       // if (dialog.open() == WizardDialog.CANCEL)\r
+                                       // return true;\r
+                                       //\r
+                                       // if (wizard.overwrite()) {\r
+                                       // targetParentNode.getNode(name).remove();\r
+                                       // // session.save();\r
+                                       // } else\r
+                                       // name = wizard.newName();\r
+                                       // }\r
+                                       //\r
+                                       // Node target;\r
+                                       // boolean passedStatus = source\r
+                                       // .getNode(SlcNames.SLC_AGGREGATED_STATUS)\r
+                                       // .getProperty(SlcNames.SLC_SUCCESS).getBoolean();\r
+                                       //\r
+                                       // if (!isActionUnderMyResult) {// Copy\r
+                                       // target = targetParentNode.addNode(source.getName(),\r
+                                       // source.getPrimaryNodeType().getName());\r
+                                       // JcrUtils.copy(source, target);\r
+                                       // } else {// move\r
+                                       // String sourcePath = source.getPath();\r
+                                       // String destPath = targetParentNode.getPath() + "/"\r
+                                       // + name;\r
+                                       // session.move(sourcePath, destPath);\r
+                                       // // session.save();\r
+                                       // // Update passed status of the parent source Node\r
+                                       // ResultParentUtils\r
+                                       // .updatePassedStatus(session.getNode(JcrUtils\r
+                                       // .parentPath(sourcePath)), true);\r
+                                       // target = session.getNode(destPath);\r
+                                       //\r
+                                       // }\r
+                                       // if (!target.isNodeType(NodeType.MIX_TITLE))\r
+                                       // target.addMixin(NodeType.MIX_TITLE);\r
+                                       // target.setProperty(Property.JCR_TITLE, name);\r
+                                       // ResultParentUtils.updatePassedStatus(target.getParent(),\r
+                                       // passedStatus);\r
+                                       // session.save();\r
 \r
                                }\r
-                               if (!target.isNodeType(NodeType.MIX_TITLE))\r
-                                       target.addMixin(NodeType.MIX_TITLE);\r
-                               target.setProperty(Property.JCR_TITLE, name);\r
-                               ResultParentUtils.updatePassedStatus(target.getParent(),\r
-                                               passedStatus);\r
-                               session.save();\r
                        } catch (RepositoryException re) {\r
                                throw new SlcException(\r
                                                "unexpected error while copying dropped node", re);\r
+\r
                        }\r
                        return true;\r
                }\r
@@ -769,8 +877,9 @@ public class JcrResultTreeView extends ViewPart {
 \r
                protected void onEventInUiThread(List<Event> events)\r
                                throws RepositoryException {\r
-                       if (lastSelectedSourceElementParent != null)\r
-                               refresh(lastSelectedSourceElementParent);\r
+                       refresh(null);\r
+                       // if (lastSelectedSourceElementParent != null)\r
+                       // refresh(lastSelectedSourceElementParent);\r
                }\r
        }\r
 \r
@@ -792,8 +901,9 @@ public class JcrResultTreeView extends ViewPart {
                                                        props.add(node.getProperty(SlcNames.SLC_TEST_CASE));\r
                                                if (node.hasProperty(SlcNames.SLC_COMPLETED))\r
                                                        props.add(node.getProperty(SlcNames.SLC_COMPLETED));\r
-                                               if (node.hasNode(SlcNames.SLC_STATUS)) {\r
-                                                       Node status = node.getNode(SlcNames.SLC_STATUS);\r
+                                               if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {\r
+                                                       Node status = node\r
+                                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS);\r
                                                        props.add(status.getProperty(SlcNames.SLC_SUCCESS));\r
                                                        if (status.hasProperty(SlcNames.SLC_MESSAGE))\r
                                                                props.add(status\r
@@ -828,27 +938,27 @@ public class JcrResultTreeView extends ViewPart {
                                        propertiesViewer.setInput(null);\r
                                // update cache for Drag & drop\r
                                // lastSelectedTargetElement = firstItem;\r
-                               lastSelectedSourceElement = firstItem;\r
-                               lastSelectedSourceElementParent = (ResultParent) firstItem\r
-                                               .getParent();\r
-                               String pPath = "";\r
-                               try {\r
-\r
-                                       if (firstItem instanceof ParentNodeFolder)\r
-                                               pPath = ((ParentNodeFolder) firstItem).getNode()\r
-                                                               .getPath();\r
-                                       else if (firstItem instanceof SingleResultNode)\r
-                                               pPath = ((SingleResultNode) firstItem).getNode()\r
-                                                               .getPath();\r
-                               } catch (RepositoryException e) {\r
-                                       throw new SlcException(\r
-                                                       "Unexpected error while checking parent UI tree", e);\r
-                               }\r
-                               if ((pPath.startsWith(SlcJcrResultUtils\r
-                                               .getMyResultsBasePath(session))))\r
-                                       isActionUnderMyResult = true;\r
-                               else\r
-                                       isActionUnderMyResult = false;\r
+                               // lastSelectedSourceElement = firstItem;\r
+                               // lastSelectedSourceElementParent = (ResultParent) firstItem\r
+                               // .getParent();\r
+                               // String pPath = "";\r
+                               // try {\r
+                               //\r
+                               // if (firstItem instanceof ParentNodeFolder)\r
+                               // pPath = ((ParentNodeFolder) firstItem).getNode()\r
+                               // .getPath();\r
+                               // else if (firstItem instanceof SingleResultNode)\r
+                               // pPath = ((SingleResultNode) firstItem).getNode()\r
+                               // .getPath();\r
+                               // } catch (RepositoryException e) {\r
+                               // throw new SlcException(\r
+                               // "Unexpected error while checking parent UI tree", e);\r
+                               // }\r
+                               // if ((pPath.startsWith(SlcJcrResultUtils\r
+                               // .getMyResultsBasePath(session))))\r
+                               // isActionUnderMyResult = true;\r
+                               // else\r
+                               // isActionUnderMyResult = false;\r
                        }\r
                }\r
        }\r
@@ -864,5 +974,4 @@ public class JcrResultTreeView extends ViewPart {
        public void setSession(Session session) {\r
                this.session = session;\r
        }\r
-\r
-}\r
+}
\ No newline at end of file
index d20cf4d8d06692cc2b0cdd0a2f118c44e4baf071..a27217811938bc95310773dad8324abd74f19c42 100644 (file)
@@ -128,23 +128,77 @@ public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
        public void addResultPart(TestResultPart testResultPart) {
                Node node = getNode();
                try {
-                       Node resultPartNode = node.addNode(SlcNames.SLC_STATUS,
+                       // add the new result part, retrieving status information
+                       Node resultPartNode = node.addNode(SlcNames.SLC_RESULT_PART,
                                        SlcTypes.SLC_CHECK);
                        resultPartNode.setProperty(SLC_SUCCESS,
                                        testResultPart.getStatus() == TestStatus.PASSED);
                        if (testResultPart.getMessage() != null)
                                resultPartNode.setProperty(SLC_MESSAGE,
                                                testResultPart.getMessage());
-                       if (testResultPart.getExceptionMessage() != null)
+                       if (testResultPart.getStatus() == TestStatus.ERROR) {
                                resultPartNode.setProperty(SLC_ERROR_MESSAGE,
-                                               testResultPart.getExceptionMessage());
+                                               (testResultPart.getExceptionMessage() == null) ? ""
+                                                               : testResultPart.getExceptionMessage());
+                       }
+
+                       // helper update aggregate status node
+                       Node mainStatus;
+                       if (!node.hasNode(SLC_AGGREGATED_STATUS)) {
+
+                               mainStatus = node.addNode(SLC_AGGREGATED_STATUS,
+                                               SlcTypes.SLC_CHECK);
+                               mainStatus.setProperty(SLC_SUCCESS,
+                                               resultPartNode.getProperty(SLC_SUCCESS).getBoolean());
+                               if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_MESSAGE).getString());
+                               if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE))
+                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
+                       } else {
+                               mainStatus = node.getNode(SLC_AGGREGATED_STATUS);
+                               if (mainStatus.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       // main status already in error we do nothing
+                               } else if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       // main status was not in error and new result part is in
+                                       // error; we update main status
+                                       mainStatus.setProperty(SLC_SUCCESS, false);
+                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
+                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                               .getProperty(SLC_MESSAGE).getString());
+                                       else
+                                               // remove old message to remain consistent
+                                               mainStatus.setProperty(SLC_MESSAGE, "");
+                               } else if (!mainStatus.getProperty(SLC_SUCCESS).getBoolean()) {
+                                       // main status was already failed and new result part is not
+                                       // in error, we do nothing
+                               } else if (!resultPartNode.getProperty(SLC_SUCCESS)
+                                               .getBoolean()) {
+                                       // new resultPart that is failed
+                                       mainStatus.setProperty(SLC_SUCCESS, false);
+                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                               .getProperty(SLC_MESSAGE).getString());
+                                       else
+                                               // remove old message to remain consistent
+                                               mainStatus.setProperty(SLC_MESSAGE, "");
+                               } else if (resultPartNode.hasProperty(SLC_MESSAGE)
+                                               && (!mainStatus.hasProperty(SLC_MESSAGE) || (""
+                                                               .equals(mainStatus.getProperty(SLC_MESSAGE)
+                                                                               .getString().trim())))) {
+                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_MESSAGE).getString());
+                               }
+                       }
                        JcrUtils.updateLastModified(node);
                        node.getSession().save();
                } catch (Exception e) {
                        JcrUtils.discardUnderlyingSessionQuietly(node);
                        throw new SlcException("Cannot get UUID from " + node, e);
                }
-
        }
 
        public String getUuid() {
index 4466138d91af00d0d0f82e3bc0f744b19e640af1..729c2d74b7c3dcd958dfce3959291586a8bea4ee 100644 (file)
@@ -153,7 +153,7 @@ public class SlcJcrResultUtils {
                        }
                        Node rfNode = JcrUtils.mkdirs(session, absPath);
                        rfNode.setPrimaryType(SlcTypes.SLC_RESULT_FOLDER);
-                       Node statusNode = rfNode.addNode(SlcNames.SLC_STATUS,
+                       Node statusNode = rfNode.addNode(SlcNames.SLC_AGGREGATED_STATUS,
                                        SlcTypes.SLC_CHECK);
                        statusNode.setProperty(SlcNames.SLC_SUCCESS, true);
                        session.save();
index 3473827cdd7a2e921cd12f9905689c8442fefdc7..693389d119fe02bd1ce462c93061a988b7ce18c7 100644 (file)
@@ -196,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) {
@@ -232,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) {
@@ -243,6 +251,5 @@ public class SlcJcrUtils implements SlcNames {
 
        /** Prevents instantiation */
        private SlcJcrUtils() {
-
        }
-}
+}
\ No newline at end of file
index 94b865bfd8d01d01239b3aa23f46f402cdfa80ba..9e915984a14b89616fe0cf2d60ee59679c7fc83c 100644 (file)
@@ -21,6 +21,17 @@ public interface SlcNames {
 
        public final static String SLC_UUID = "slc:uuid";
        public final static String SLC_STATUS = "slc:status";
+       // generic name for result parts of a given test result (slc:testResult)
+       // note that corresponding nodes can be retrieved using
+       // myTestResultNode.getNodes(SLC_RESULT_PART+"*") method
+       public final static String SLC_RESULT_PART = "slc:resultPart";
+       // Fixed name of the child node of a slc:testResult of type
+       // slc:check that aggregate status of all result parts of a given test
+       // result
+       public final static String SLC_AGGREGATED_STATUS = "slc:aggregatedStatus";
+       
+       
+       
        public final static String SLC_TYPE = "slc:type";
        public final static String SLC_NAME = "slc:name";
        public final static String SLC_VERSION = "slc:version";
index 92e81a4ef58a9d0c2489aeb825d3d44e72f79b91..9890fc365313b89e57c70bbb4a0be7d8558fc905 100644 (file)
@@ -99,12 +99,9 @@ mixin
 - slc:uuid (STRING) ! m
 - slc:testCase (STRING)
 - slc:completed (DATE)
-// Added by the engine once the test has been fully processed. 
-// If the test is killed before it ends, this node is not created
-+ slc:status (slc:check)
-// DEPRECATED. This Node is now rather called slc:status (see above)
-// Should be removed in Argeo 2.
-+ slc:testStatus (slc:check)
+// Helper to keep a centralize place to have testResultStatus
+// when adding more than one result part to a given testResult 
++ slc:aggregatedStatus (slc:check)
 
 [slc:diffResult] > slc:testResult
 + slc:summary