]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java
Remove unused.
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui / src / org / argeo / slc / client / ui / model / ParentNodeFolder.java
1 package org.argeo.slc.client.ui.model;
2
3 import javax.jcr.Node;
4 import javax.jcr.NodeIterator;
5 import javax.jcr.RepositoryException;
6 import javax.jcr.nodetype.NodeType;
7
8 import org.argeo.slc.SlcException;
9 import org.argeo.slc.SlcNames;
10 import org.argeo.slc.SlcTypes;
11
12 /**
13 * UI Tree component that wrap a node of type NT_UNSTRUCTURED or base node for
14 * UI specific, user defined tree structure of type SLC_MY_RESULTS_ROOT_FOLDER.
15 *
16 * It is used for
17 * <ul>
18 * <li>automatically generated tree structure to store results (typically
19 * Year/Month/Day...)</li>
20 * <li>parent node for user defined tree structure (typically My Results node)</li>
21 * </ul>
22 * It thus lists either result folders, other folders and/or a list of results
23 * and keeps a reference to its parent.
24 */
25 public class ParentNodeFolder extends ResultParent {
26 // private final static Log log = LogFactory.getLog(ParentNodeFolder.class);
27
28 private Node node = null;
29
30 /**
31 *
32 * @param parent
33 * @param node
34 * throws an exception if null
35 * @param name
36 */
37 public ParentNodeFolder(ParentNodeFolder parent, Node node, String name) {
38 super(name);
39 if (node == null)
40 throw new SlcException("Node Object cannot be null");
41 setParent(parent);
42 this.node = node;
43 }
44
45 @Override
46 protected void initialize() {
47 try {
48 NodeIterator ni = node.getNodes();
49 while (ni.hasNext()) {
50 Node currNode = ni.nextNode();
51 if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
52 SingleResultNode srn = new SingleResultNode(this, currNode,
53 currNode.getProperty(SlcNames.SLC_TEST_CASE)
54 .getString());
55 addChild(srn);
56 } else if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
57 // FIXME change label
58 ResultFolder rf = new ResultFolder(this, currNode,
59 currNode.getName());
60 addChild(rf);
61 } else if (currNode.isNodeType(SlcTypes.SLC_CHECK)) {
62 // FIXME : manually skip node types that are not to be
63 // displayed
64 // Do nothing
65 } else if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
66 addChild(new ParentNodeFolder(this, currNode,
67 currNode.getName()));
68 }
69 } catch (RepositoryException re) {
70 throw new SlcException(
71 "Unexpected error while initializing ParentNodeFolder : "
72 + getName(), re);
73 }
74 }
75
76 public Node getNode() {
77 return node;
78 }
79
80 // /**
81 // * Overriden in the specific case of "My result" root object to return an
82 // * ordered list of children
83 // */
84 // public synchronized Object[] getChildren() {
85 // Object[] children = super.getChildren();
86 // try {
87 // if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
88 // return ResultParentUtils.orderChildren(children);
89 // else
90 // return children;
91 // } catch (RepositoryException re) {
92 // throw new SlcException(
93 // "Unexpected error while initializing simple node folder : "
94 // + getName(), re);
95 // }
96 // }
97 }