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
.slc
.SlcException
;
14 import org
.argeo
.slc
.SlcNames
;
15 import org
.argeo
.slc
.SlcTypes
;
18 * Abstract the base of a given modular distribution set i.e. the parent of all
19 * versions of a given modular distribution
21 public class ModularDistVersionBaseElem
extends DistParentElem
{
23 // final static public String AETHER_CATEGORY_BASE = "categoryBase";
24 final static public String AETHER_BINARIES_TYPE
= "binaries";
25 final static public String AETHER_DEP_TYPE
= "dep";
27 private Node modularDistVersionBase
;
29 public ModularDistVersionBaseElem(WorkspaceElem wkspElem
, String name
,
30 Node modularDistVersionBase
, String type
) {
31 super(name
, wkspElem
.inHome(), wkspElem
.isReadOnly());
33 this.modularDistVersionBase
= modularDistVersionBase
;
37 public Node
getModularDistBase() {
39 // if (type.equals(AETHER_CATEGORY_BASE))
40 // return modularDistVersionBase;
43 return modularDistVersionBase
.getParent();
44 } catch (RepositoryException e
) {
45 throw new SlcException("unable to get parent node for "
46 + modularDistVersionBase
, e
);
50 public WorkspaceElem
getWkspElem() {
51 return (WorkspaceElem
) getParent();
55 * Override normal behaviour to initialise children only when first
59 public synchronized boolean hasChildren() {
61 return super.hasChildren();
68 * Override normal behaviour to initialise children only when first
72 public synchronized Object
[] getChildren() {
74 return super.getChildren();
77 NodeIterator ni
= getDistVersions();
78 while (ni
!= null && ni
.hasNext()) {
79 Node curNode
= ni
.nextNode();
80 if (curNode
.hasProperty(SlcNames
.SLC_ARTIFACT_VERSION
))
81 addChild(new ModularDistVersionElem(this, curNode
82 .getProperty(SlcNames
.SLC_ARTIFACT_VERSION
)
83 .getString(), curNode
));
85 return super.getChildren();
86 } catch (RepositoryException re
) {
87 throw new SlcException("Unable to retrieve children for "
88 + modularDistVersionBase
, re
);
93 private NodeIterator
getDistVersions() {
95 // if (AETHER_CATEGORY_BASE.equals(type))
98 QueryManager queryManager
= modularDistVersionBase
.getSession()
99 .getWorkspace().getQueryManager();
100 QueryObjectModelFactory factory
= queryManager
.getQOMFactory();
101 Selector source
= factory
.selector(
102 SlcTypes
.SLC_MODULAR_DISTRIBUTION
,
103 SlcTypes
.SLC_MODULAR_DISTRIBUTION
);
104 Constraint constraint
= factory
.descendantNode(
105 source
.getSelectorName(), modularDistVersionBase
.getPath());
106 // Ordering order = factory.descending(factory.propertyValue(
107 // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
108 // Ordering[] orderings = { order };
109 QueryObjectModel query
= factory
.createQuery(source
, constraint
,
111 QueryResult queryResult
= query
.execute();
112 return queryResult
.getNodes();
113 } catch (RepositoryException e
) {
114 throw new SlcException(
115 "Unable to version for modular distribution: " + getName(),
120 public String
getType() {