Search in sources :

Example 1 with ServerParentGraphNode

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;
}
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) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 2 with ServerParentGraphNode

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;
}
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) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 3 with ServerParentGraphNode

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;
}
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) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode)

Example 4 with ServerParentGraphNode

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

Example 5 with ServerParentGraphNode

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

Aggregations

ServerParentGraphNode (net.geoprism.registry.model.ServerParentGraphNode)14 Test (org.junit.Test)8 Request (com.runwaysdk.session.Request)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 EdgeObject (com.runwaysdk.business.graph.EdgeObject)5 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 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)2 TestUserInfo (net.geoprism.registry.test.TestUserInfo)2 HashedMap (org.apache.commons.collections4.map.HashedMap)2 Date (java.util.Date)1 DirectedAcyclicGraphControllerWrapper (net.geoprism.registry.test.graph.DirectedAcyclicGraphControllerWrapper)1 UndirectedGraphControllerWrapper (net.geoprism.registry.test.graph.UndirectedGraphControllerWrapper)1