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 of a given modular distribution set i.e. the parent of all
20 * versions of a given modular distribution
22 public class ModularDistVersionBaseElem
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 modularDistVersionBase
;
30 public ModularDistVersionBaseElem(WorkspaceElem wkspElem
, String name
,
31 Node modularDistVersionBase
, String type
) {
32 super(name
, wkspElem
.inHome(), wkspElem
.isReadOnly());
34 this.modularDistVersionBase
= modularDistVersionBase
;
38 public Node
getModularDistBase() {
40 // if (type.equals(AETHER_CATEGORY_BASE))
41 // return modularDistVersionBase;
44 return modularDistVersionBase
.getParent();
45 } catch (RepositoryException e
) {
46 throw new SlcException("unable to get parent node for "
47 + modularDistVersionBase
, e
);
51 public WorkspaceElem
getWkspElem() {
52 return (WorkspaceElem
) getParent();
56 * Override normal behaviour to initialise children only when first
60 public synchronized boolean hasChildren() {
62 return super.hasChildren();
69 * Override normal behaviour to initialise children only when first
73 public synchronized Object
[] getChildren() {
75 return super.getChildren();
78 NodeIterator ni
= getDistVersions();
79 while (ni
!= null && ni
.hasNext()) {
80 Node curNode
= ni
.nextNode();
81 if (curNode
.hasProperty(SlcNames
.SLC_ARTIFACT_VERSION
))
82 addChild(new ModularDistVersionElem(this, curNode
83 .getProperty(SlcNames
.SLC_ARTIFACT_VERSION
)
84 .getString(), curNode
));
86 return super.getChildren();
87 } catch (RepositoryException re
) {
88 throw new ArgeoException("Unable to retrieve children for "
89 + modularDistVersionBase
, re
);
94 private NodeIterator
getDistVersions() {
96 // if (AETHER_CATEGORY_BASE.equals(type))
99 QueryManager queryManager
= modularDistVersionBase
.getSession()
100 .getWorkspace().getQueryManager();
101 QueryObjectModelFactory factory
= queryManager
.getQOMFactory();
102 Selector source
= factory
.selector(
103 SlcTypes
.SLC_MODULAR_DISTRIBUTION
,
104 SlcTypes
.SLC_MODULAR_DISTRIBUTION
);
105 Constraint constraint
= factory
.descendantNode(
106 source
.getSelectorName(), modularDistVersionBase
.getPath());
107 // Ordering order = factory.descending(factory.propertyValue(
108 // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
109 // Ordering[] orderings = { order };
110 QueryObjectModel query
= factory
.createQuery(source
, constraint
,
112 QueryResult queryResult
= query
.execute();
113 return queryResult
.getNodes();
114 } catch (RepositoryException e
) {
115 throw new SlcException(
116 "Unable to version for modular distribution: " + getName(),
121 public String
getType() {