use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testGetChildrenCyclic.
@Test
@Request
public void testGetChildrenCyclic() {
ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
ServerGeoObjectIF distCentral = FastTestDataset.DIST_CENTRAL.getServerObject();
ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
ServerGeoObjectIF privateCentral = FastTestDataset.PROV_CENTRAL_PRIVATE.getServerObject();
ServerGeoObjectIF centralHospital = FastTestDataset.CENTRAL_HOSPITAL.getServerObject();
provWestern.addGraphParent(provCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
provCentral.addGraphParent(distCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
provCentral.addGraphParent(cambodia, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
cambodia.addGraphParent(privateCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
cambodia.addGraphParent(centralHospital, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
distCentral.addGraphParent(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
ServerChildGraphNode node = provWestern.getGraphChildren(type, true, FastTestDataset.DEFAULT_OVER_TIME_DATE);
Assert.assertNotNull(node);
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class ServerHierarchyStrategy method getChildren.
@SuppressWarnings("unchecked")
@Override
public ServerChildGraphNode getChildren(VertexServerGeoObject parent, Boolean recursive, Date date) {
ServerChildGraphNode tnRoot = new ServerChildGraphNode(parent, this.hierarchy, date, null, null);
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", parent.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND( outE(");
statement.append("'" + this.hierarchy.getMdEdge().getDBClassName() + "'");
statement.append(")");
if (date != null) {
statement.append("[:date BETWEEN startDate AND endDate]");
parameters.put("date", date);
}
statement.append(") FROM :rid");
GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement.toString(), parameters);
List<EdgeObject> edges = query.getResults();
for (EdgeObject edge : edges) {
final VertexObject childVertex = edge.getChild();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) childVertex.getMdClass();
ServerGeoObjectType childType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject child = new VertexServerGeoObject(childType, childVertex, date);
ServerChildGraphNode tnParent;
if (recursive) {
tnParent = this.getChildren(child, recursive, date);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerChildGraphNode(child, this.hierarchy, date, null, edge.getOid());
}
tnRoot.addChild(tnParent);
}
return tnRoot;
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method getChildren.
private ServerChildGraphNode getChildren(VertexServerGeoObject source, Boolean recursive, Date date, TreeSet<String> visited) {
ServerChildGraphNode tnRoot = new ServerChildGraphNode(source, this.type, date, null, null);
List<EdgeObject> edges = this.getEdges(source, date);
for (EdgeObject edge : edges) {
Object sourceRid = source.getVertex().getRID();
final VertexObject vertex = edge.getChild().getRID().equals(sourceRid) ? edge.getParent() : edge.getChild();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) vertex.getMdClass();
ServerGeoObjectType vertexType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject target = new VertexServerGeoObject(vertexType, vertex, date);
if (!source.getUid().equals(target.getUid())) {
ServerChildGraphNode tnParent;
if (recursive && !visited.contains(target.getUid())) {
visited.add(target.getUid());
tnParent = this.getChildren(target, recursive, date, visited);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerChildGraphNode(target, this.type, date, null, edge.getOid());
}
tnRoot.addChild(tnParent);
}
}
return tnRoot;
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class RelationshipVisualizationService method fetchChildrenData.
private void fetchChildrenData(boolean recursive, VertexServerGeoObject vertexGo, GraphType graphType, Date date, JsonArray jaEdges, JsonArray jaVerticies, Set<String> setEdges, Set<String> setVerticies) {
ServerChildGraphNode node = vertexGo.getGraphChildren(graphType, recursive, date);
this.processChildNode(node, graphType, jaEdges, jaVerticies, setVerticies);
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphTest method validateRemoveChild.
@Request
private void validateRemoveChild() {
ServerChildGraphNode node = FastTestDataset.PROV_CENTRAL.getServerObject().getGraphChildren(type, false, FastTestDataset.DEFAULT_END_TIME_DATE);
List<ServerChildGraphNode> children = node.getChildren();
Assert.assertEquals(0, children.size());
}
Aggregations