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());
}
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;
}
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;
}
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);
});
}
}
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());
}
Aggregations