use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphStrategy method getChildren.
@SuppressWarnings("unchecked")
@Override
public ServerChildGraphNode getChildren(VertexServerGeoObject parent, Boolean recursive, Date date) {
ServerChildGraphNode tnRoot = new ServerChildGraphNode(parent, this.type, 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.type.getMdEdgeDAO().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.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 DirectedAcyclicGraphTest method testGetChildren.
@Test
public void testGetChildren() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
DirectedAcyclicGraphControllerWrapper controller = new DirectedAcyclicGraphControllerWrapper(adapter, request);
controller.addChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
ServerChildGraphNode node = controller.getChildren(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), graphTypeCode, false, FastTestDataset.DEFAULT_OVER_TIME_DATE);
List<ServerChildGraphNode> children = node.getChildren();
Assert.assertEquals(1, children.size());
Assert.assertEquals(FastTestDataset.PROV_WESTERN.getCode(), children.get(0).getGeoObject().getCode());
});
}
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class UndirectedGraphTest 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());
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testAddMultipleChildren.
@Test
@Request
public void testAddMultipleChildren() {
ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
ServerGeoObjectIF distCentral = FastTestDataset.DIST_CENTRAL.getServerObject();
provCentral.addGraphChild(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_END_TIME_DATE);
provCentral.addGraphChild(distCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_END_TIME_DATE);
ServerChildGraphNode node = provCentral.getGraphChildren(type, false, FastTestDataset.DEFAULT_END_TIME_DATE);
List<ServerChildGraphNode> children = node.getChildren();
Assert.assertEquals(2, children.size());
}
use of net.geoprism.registry.model.ServerChildGraphNode in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testGetChildren.
@Test
public void testGetChildren() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
UndirectedGraphControllerWrapper controller = new UndirectedGraphControllerWrapper(adapter, request);
controller.addChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
ServerChildGraphNode node = controller.getChildren(FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, false, FastTestDataset.DEFAULT_OVER_TIME_DATE);
List<ServerChildGraphNode> children = node.getChildren();
Assert.assertEquals(1, children.size());
Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), children.get(0).getGeoObject().getCode());
});
}
}
Aggregations