Search in sources :

Example 6 with ServerChildGraphNode

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);
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 7 with ServerChildGraphNode

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;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 8 with ServerChildGraphNode

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;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject)

Example 9 with ServerChildGraphNode

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);
}
Also used : ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode)

Example 10 with ServerChildGraphNode

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());
}
Also used : ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) Request(com.runwaysdk.session.Request)

Aggregations

ServerChildGraphNode (net.geoprism.registry.model.ServerChildGraphNode)10 Request (com.runwaysdk.session.Request)4 Test (org.junit.Test)4 EdgeObject (com.runwaysdk.business.graph.EdgeObject)3 VertexObject (com.runwaysdk.business.graph.VertexObject)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 GraphQuery (com.runwaysdk.business.graph.GraphQuery)2 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)2 TestUserInfo (net.geoprism.registry.test.TestUserInfo)2 HashedMap (org.apache.commons.collections4.map.HashedMap)2 DirectedAcyclicGraphControllerWrapper (net.geoprism.registry.test.graph.DirectedAcyclicGraphControllerWrapper)1 UndirectedGraphControllerWrapper (net.geoprism.registry.test.graph.UndirectedGraphControllerWrapper)1