Search in sources :

Example 6 with ServerParentGraphNode

use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.

the class UndirectedGraphTest method testAddMultipleParents.

@Test
@Request
public void testAddMultipleParents() {
    ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
    ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
    ServerGeoObjectIF distCentral = FastTestDataset.DIST_CENTRAL.getServerObject();
    provCentral.addGraphParent(provWestern, 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);
    ServerParentGraphNode node = provCentral.getGraphParents(type, false, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    List<ServerParentGraphNode> parents = node.getParents();
    Assert.assertEquals(2, parents.size());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 7 with ServerParentGraphNode

use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphStrategy method addParent.

@SuppressWarnings("unchecked")
@Override
public ServerParentGraphNode addParent(VertexServerGeoObject geoObject, VertexServerGeoObject parent, Date startDate, Date endDate) {
    GraphValidationService.validate(type, parent, parent);
    if (this.isCycle(geoObject, parent, startDate, endDate)) {
        throw new UnsupportedOperationException("Cannot add a cycle");
    }
    if (this.getParentEdges(geoObject, parent, startDate, endDate).size() > 0) {
        throw new UnsupportedOperationException("Duplicate edge");
    }
    Set<ValueOverTime> votc = this.getParentCollection(geoObject);
    votc.add(new ValueOverTime(startDate, endDate, parent));
    SortedSet<EdgeObject> newEdges = this.setParentCollection(geoObject, votc);
    ServerParentGraphNode node = new ServerParentGraphNode(geoObject, this.type, startDate, endDate, null);
    node.addParent(new ServerParentGraphNode(parent, this.type, startDate, endDate, newEdges.first().getOid()));
    return node;
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode)

Example 8 with ServerParentGraphNode

use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.

the class UndirectedGraphStrategy method addParent.

@SuppressWarnings("unchecked")
@Override
public <T extends ServerGraphNode> T addParent(VertexServerGeoObject geoObject, VertexServerGeoObject parent, Date startDate, Date endDate) {
    if (this.isCycle(geoObject, parent, startDate, endDate)) {
        throw new UnsupportedOperationException("Cyclic graph is not supported");
    }
    if (this.getEdges(geoObject, parent, startDate, endDate).size() > 0) {
        throw new UnsupportedOperationException("Duplicate edge");
    }
    Set<ValueOverTime> votc = this.getParentCollection(geoObject);
    votc.add(new ValueOverTime(startDate, endDate, parent));
    SortedSet<EdgeObject> newEdges = this.setParentCollection(geoObject, votc);
    ServerParentGraphNode node = new ServerParentGraphNode(geoObject, this.type, startDate, endDate, null);
    node.addParent(new ServerParentGraphNode(parent, this.type, startDate, endDate, newEdges.first().getOid()));
    return (T) node;
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode)

Example 9 with ServerParentGraphNode

use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphTest method testAddChild.

@Test
public void testAddChild() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
    for (TestUserInfo user : allowedUsers) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            DirectedAcyclicGraphControllerWrapper controller = new DirectedAcyclicGraphControllerWrapper(adapter, request);
            ServerParentGraphNode node = 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);
            validateAddChild(node, FastTestDataset.PROV_CENTRAL, FastTestDataset.PROV_WESTERN);
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) DirectedAcyclicGraphControllerWrapper(net.geoprism.registry.test.graph.DirectedAcyclicGraphControllerWrapper) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) Test(org.junit.Test)

Example 10 with ServerParentGraphNode

use of net.geoprism.registry.model.ServerParentGraphNode in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphTest method testAddParentCyclic_DifferentTimes.

@Test
@Request
public void testAddParentCyclic_DifferentTimes() {
    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, new Date(), ValueOverTime.INFINITY_END_DATE);
    ServerParentGraphNode node = provWestern.getGraphParents(type, false, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    Assert.assertEquals(1, node.getParents().size());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) Date(java.util.Date) 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