X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fmodel%2FResultParentUtils.java;h=d569167dc9c1b0e9e6e435fed81f153a1f3b5aa5;hb=3c158e1fdf8d885eaa2ece409c4cf2584839f633;hp=26d44e7c5574ce49b8065bfebf1970606a87c50c;hpb=58e0e18d64a2080680a9f8397b0dfa2894519910;p=gpl%2Fargeo-slc.git 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 index 26d44e7c5..d569167dc 100644 --- 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 @@ -16,7 +16,6 @@ package org.argeo.slc.client.ui.model; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -38,35 +37,35 @@ public class ResultParentUtils { // private final static Log log = // LogFactory.getLog(ResultParentUtils.class); - public static Object[] orderChildren(Object[] children) { - List folders = new ArrayList(); - List results = new ArrayList(); - 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 second = Collections.reverseOrder(); - Collections.sort(results); - - Object[] orderedChildren = new Object[folders.size() + results.size()]; - int i = 0; - Iterator it = folders.iterator(); - while (it.hasNext()) { - orderedChildren[i] = it.next(); - i++; - } - Iterator it2 = results.iterator(); - while (it2.hasNext()) { - orderedChildren[i] = it2.next(); - i++; - } - return orderedChildren; - } + // public static Object[] orderChildren(Object[] children) { + // List folders = new ArrayList(); + // List results = new ArrayList(); + // 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 second = Collections.reverseOrder(); + // Collections.sort(results); + // + // Object[] orderedChildren = new Object[folders.size() + results.size()]; + // int i = 0; + // Iterator it = folders.iterator(); + // while (it.hasNext()) { + // orderedChildren[i] = it.next(); + // i++; + // } + // Iterator it2 = results.iterator(); + // while (it2.hasNext()) { + // orderedChildren[i] = it2.next(); + // i++; + // } + // return orderedChildren; + // } public static List getResultsForDates(Session session, List dateRelPathes) { @@ -111,7 +110,7 @@ public class ResultParentUtils { } /** - * recursively update passed status of the parent ResultFolder and its + * recursively update passed status of the current ResultFolder and its * parent if needed * * @param node @@ -120,64 +119,25 @@ public class ResultParentUtils { */ public static void updatePassedStatus(Node node, boolean passed) { try { - Node pNode = node.getParent(); - if (!pNode.hasNode(SlcNames.SLC_STATUS)) + if (!node.hasNode(SlcNames.SLC_STATUS)) // we have reached the root of the tree. stop the // recursivity return; - boolean pStatus = pNode.getNode(SlcNames.SLC_STATUS) + boolean pStatus = node.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 + // New status is 'failed' : we only update status of the result + // folder and its // parent if needed - pNode.getNode(SlcNames.SLC_STATUS).setProperty( + node.getNode(SlcNames.SLC_STATUS).setProperty( SlcNames.SLC_SUCCESS, passed); - updatePassedStatus(pNode, passed); + updatePassedStatus(node.getParent(), 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 + // New status is 'passed': we must first check if all siblings + // have also // successfully completed boolean success = true; NodeIterator ni = node.getNodes(); @@ -194,17 +154,15 @@ public class ResultParentUtils { } if (success) { node.getNode(SlcNames.SLC_STATUS).setProperty( - SlcNames.SLC_SUCCESS, true); - updatePassedStatus(node, true); + SlcNames.SLC_SUCCESS, passed); + updatePassedStatus(node.getParent(), passed); } 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); + throw new SlcException("Cannot update result passed status", e); } } - }