1 package org
.argeo
.slc
.client
.ui
.dist
.model
;
4 import javax
.jcr
.NodeIterator
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.query
.QueryManager
;
7 import javax
.jcr
.query
.QueryResult
;
8 import javax
.jcr
.query
.qom
.Constraint
;
9 import javax
.jcr
.query
.qom
.QueryObjectModel
;
10 import javax
.jcr
.query
.qom
.QueryObjectModelFactory
;
11 import javax
.jcr
.query
.qom
.Selector
;
13 import org
.argeo
.ArgeoException
;
14 import org
.argeo
.slc
.SlcException
;
15 import org
.argeo
.slc
.jcr
.SlcNames
;
16 import org
.argeo
.slc
.jcr
.SlcTypes
;
19 * Abstract the base a given modular distribution set that is the parent all
20 * versions of the same distribution
22 public class ModularDistBaseElem
extends DistParentElem
{
24 final static public String AETHER_CATEGORY_BASE
= "categoryBase";
25 final static public String AETHER_BINARIES_TYPE
= "binaries";
26 final static public String AETHER_DEP_TYPE
= "dep";
28 private Node artifactBase
;
30 public ModularDistBaseElem(WorkspaceElem wkspElem
, String name
,
31 Node artifactBase
, String type
) {
32 super(name
, wkspElem
.inHome(), wkspElem
.isReadOnly());
34 this.artifactBase
= artifactBase
;
38 public Node
getCategoryBase() {
40 if (type
.equals(AETHER_CATEGORY_BASE
))
44 return artifactBase
.getParent();
45 } catch (RepositoryException e
) {
46 throw new SlcException("unable tyo get parent node for "
52 * Override normal behavior to initialize children only when first requested
55 public synchronized boolean hasChildren() {
57 return super.hasChildren();
64 * Override normal behavior to initialize children only when first requested
67 public synchronized Object
[] getChildren() {
69 return super.getChildren();
71 // initialize current object
73 NodeIterator ni
= getDistVersions();
74 while (ni
!= null && ni
.hasNext()) {
75 Node curNode
= ni
.nextNode();
76 addChild(new ModularDistVersionElem(this, curNode
77 .getProperty(SlcNames
.SLC_ARTIFACT_VERSION
)
78 .getString(), curNode
));
80 return super.getChildren();
81 } catch (RepositoryException re
) {
82 throw new ArgeoException(
83 "Unexcpected error while initializing children SingleJcrNode",
89 private NodeIterator
getDistVersions() {
91 if (AETHER_CATEGORY_BASE
.equals(type
))
94 QueryManager queryManager
= artifactBase
.getSession()
95 .getWorkspace().getQueryManager();
96 QueryObjectModelFactory factory
= queryManager
.getQOMFactory();
97 Selector source
= factory
.selector(
98 SlcTypes
.SLC_MODULAR_DISTRIBUTION
,
99 SlcTypes
.SLC_MODULAR_DISTRIBUTION
);
100 Constraint constraint
= factory
.descendantNode(
101 source
.getSelectorName(), artifactBase
.getPath());
102 // Ordering order = factory.descending(factory.propertyValue(
103 // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
104 // Ordering[] orderings = { order };
105 QueryObjectModel query
= factory
.createQuery(source
, constraint
,
107 QueryResult queryResult
= query
.execute();
108 return queryResult
.getNodes();
109 } catch (RepositoryException e
) {
110 throw new SlcException(
111 "Unable to version for modular distribution: " + getName(),
116 public String
getType() {