]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java
Remove old license headers
[gpl/argeo-slc.git] / org.argeo.slc.client.ui / src / org / argeo / slc / client / ui / model / SingleResultNode.java
1 package org.argeo.slc.client.ui.model;
2
3 import javax.jcr.Node;
4 import javax.jcr.RepositoryException;
5 import javax.jcr.Workspace;
6
7 import org.argeo.eclipse.ui.TreeParent;
8 import org.argeo.slc.SlcException;
9 import org.argeo.slc.SlcNames;
10
11 /**
12 * UI Tree component. Wraps a result node of a JCR {@link Workspace}. It also
13 * keeps a reference to its parent node that can either be a
14 * {@link ResultFolder}, a {@link SingleResultNode} or a {@link VirtualFolder}.
15 * It has no child.
16 */
17
18 public class SingleResultNode extends ResultParent implements
19 Comparable<SingleResultNode> {
20
21 private final Node node;
22 private boolean passed;
23
24 // keeps a local reference to the node's name to avoid exception when the
25 // session is lost
26
27 /** Creates a new UiNode in the UI Tree */
28 public SingleResultNode(TreeParent parent, Node node, String name) {
29 super(name);
30 setParent(parent);
31 this.node = node;
32 setPassed(refreshPassedStatus());
33 }
34
35 public boolean refreshPassedStatus() {
36 try {
37 Node check;
38 if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
39 check = node.getNode(SlcNames.SLC_AGGREGATED_STATUS);
40 passed = check.getProperty(SlcNames.SLC_SUCCESS).getBoolean();
41 return passed;
42 } else
43 // Happens only if the UI triggers a refresh while the execution
44 // is in progress and the corresponding node is being built
45 return false;
46 } catch (RepositoryException re) {
47 throw new SlcException(
48 "Unexpected error while checking result status", re);
49 }
50 }
51
52 /** returns the node wrapped by the current UI object */
53 public Node getNode() {
54 return node;
55 }
56
57 /**
58 * Override normal behavior : Results have no children for this view
59 */
60 @Override
61 public synchronized Object[] getChildren() {
62 return null;
63 }
64
65 @Override
66 public boolean hasChildren() {
67 return false;
68 }
69
70 public boolean isPassed() {
71 return passed;
72 }
73
74 @Override
75 protected void initialize() {
76 // Do nothing this object is fully initialized at instantiation time.
77 }
78
79 public int compareTo(SingleResultNode o) {
80 return super.compareTo(o);
81 }
82
83 }