Search in sources :

Example 1 with ServerChildGraphNode

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;
}
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 2 with ServerChildGraphNode

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());
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) DirectedAcyclicGraphControllerWrapper(net.geoprism.registry.test.graph.DirectedAcyclicGraphControllerWrapper) Test(org.junit.Test)

Example 3 with ServerChildGraphNode

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

Example 4 with ServerChildGraphNode

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

Example 5 with ServerChildGraphNode

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());
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) UndirectedGraphControllerWrapper(net.geoprism.registry.test.graph.UndirectedGraphControllerWrapper) ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) Test(org.junit.Test)

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