use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphStrategy method getParents.
@SuppressWarnings("unchecked")
@Override
public ServerParentGraphNode getParents(VertexServerGeoObject child, Boolean recursive, Date date) {
ServerParentGraphNode tnRoot = new ServerParentGraphNode(child, this.type, date, null, null);
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", child.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND( inE(");
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 parentVertex = edge.getParent();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, date);
ServerParentGraphNode tnParent;
if (recursive) {
tnParent = this.getParents(parent, recursive, date);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerParentGraphNode(parent, this.type, date, null, edge.getOid());
}
tnRoot.addParent(tnParent);
}
return tnRoot;
}
use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.
the class ServerHierarchyStrategy method getParents.
@SuppressWarnings("unchecked")
@Override
public ServerParentGraphNode getParents(VertexServerGeoObject child, Boolean recursive, Date date) {
ServerParentGraphNode tnRoot = new ServerParentGraphNode(child, this.hierarchy, date, null, null);
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", child.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND( inE(");
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 parentVertex = edge.getParent();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, date);
ServerParentGraphNode tnParent;
if (recursive) {
tnParent = this.getParents(parent, recursive, date);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerParentGraphNode(parent, this.hierarchy, date, null, edge.getOid());
}
tnRoot.addParent(tnParent);
}
return tnRoot;
}
use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method getParents.
private ServerParentGraphNode getParents(VertexServerGeoObject source, Boolean recursive, Date date, TreeSet<String> visited) {
ServerParentGraphNode tnRoot = new ServerParentGraphNode(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 targetType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject target = new VertexServerGeoObject(targetType, vertex, date);
if (!target.getUid().equals(source.getUid())) {
ServerParentGraphNode tnParent;
if (recursive & !visited.contains(target.getUid())) {
visited.add(target.getUid());
tnParent = this.getParents(target, recursive, date, visited);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerParentGraphNode(target, this.type, date, null, edge.getOid());
}
tnRoot.addParent(tnParent);
}
}
return tnRoot;
}
use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.
the class RelationshipVisualizationService method fetchParentsData.
private void fetchParentsData(boolean recursive, VertexServerGeoObject vertexGo, GraphType graphType, Date date, JsonArray jaEdges, JsonArray jaVerticies, Set<String> setEdges, Set<String> setVerticies) {
ServerParentGraphNode node = vertexGo.getGraphParents(graphType, recursive, date);
processParentNode(node, graphType, jaEdges, jaVerticies, setVerticies);
}
use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphTest method testAddParent.
@Test
@Request
public void testAddParent() {
ServerGeoObjectIF parent = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF child = FastTestDataset.PROV_WESTERN.getServerObject();
ServerParentGraphNode node = child.addGraphParent(parent, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
Assert.assertNotNull(node);
Assert.assertEquals(child.getCode(), node.getGeoObject().getCode());
Assert.assertEquals(FastTestDataset.DEFAULT_OVER_TIME_DATE, node.getStartDate());
Assert.assertEquals(FastTestDataset.DEFAULT_OVER_TIME_DATE, node.getEndDate());
List<ServerParentGraphNode> parents = node.getParents();
Assert.assertEquals(1, parents.size());
Assert.assertEquals(parent.getCode(), parents.get(0).getGeoObject().getCode());
}
Aggregations