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 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 modularDistBase
;
30 public ModularDistBaseElem(WorkspaceElem wkspElem
, String name
,
31 Node modularDistBase
, String type
) {
32 super(name
, wkspElem
.inHome(), wkspElem
.isReadOnly());
34 this.modularDistBase
= modularDistBase
;
38 public Node
getCategoryBase() {
40 if (type
.equals(AETHER_CATEGORY_BASE
))
41 return modularDistBase
;
44 return modularDistBase
.getParent();
45 } catch (RepositoryException e
) {
46 throw new SlcException("unable tyo get parent node for "
47 + modularDistBase
, e
);
52 * Override normal behaviour to initialise children only when first requested
55 public synchronized boolean hasChildren() {
57 return super.hasChildren();
64 * Override normal behaviour to initialise children only when first requested
67 public synchronized Object
[] getChildren() {
69 return super.getChildren();
72 NodeIterator ni
= getDistVersions();
73 while (ni
!= null && ni
.hasNext()) {
74 Node curNode
= ni
.nextNode();
75 addChild(new ModularDistVersionElem(this, curNode
76 .getProperty(SlcNames
.SLC_ARTIFACT_VERSION
)
77 .getString(), curNode
));
79 return super.getChildren();
80 } catch (RepositoryException re
) {
81 throw new ArgeoException(
82 "Unable to retrieve children for "
83 + modularDistBase
, re
);
88 private NodeIterator
getDistVersions() {
90 if (AETHER_CATEGORY_BASE
.equals(type
))
93 QueryManager queryManager
= modularDistBase
.getSession()
94 .getWorkspace().getQueryManager();
95 QueryObjectModelFactory factory
= queryManager
.getQOMFactory();
96 Selector source
= factory
.selector(
97 SlcTypes
.SLC_MODULAR_DISTRIBUTION
,
98 SlcTypes
.SLC_MODULAR_DISTRIBUTION
);
99 Constraint constraint
= factory
.descendantNode(
100 source
.getSelectorName(), modularDistBase
.getPath());
101 // Ordering order = factory.descending(factory.propertyValue(
102 // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
103 // Ordering[] orderings = { order };
104 QueryObjectModel query
= factory
.createQuery(source
, constraint
,
106 QueryResult queryResult
= query
.execute();
107 return queryResult
.getNodes();
108 } catch (RepositoryException e
) {
109 throw new SlcException(
110 "Unable to version for modular distribution: " + getName(),
115 public String
getType() {