Search in sources :

Example 21 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class GeoObjectUtilTest method testGetAncestorMapForTreeType.

@Test
@Request
public void testGetAncestorMapForTreeType() {
    ServerGeoObjectType type = USATestData.AREA.getServerObject();
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
    ServerGeoObjectIF object = new ServerGeoObjectService().getGeoObjectByCode(USATestData.CO_A_ONE.getCode(), type);
    List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
    List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
    for (GeoObjectType ancestor : dtoAncestors) {
        ancestors.add(ServerGeoObjectType.get(ancestor));
    }
    Map<String, LocationInfo> map = object.getAncestorMap(hierarchyType, ancestors);
    Assert.assertEquals(3, map.size());
    // Validate the county values
    Assert.assertTrue(map.containsKey(USATestData.COUNTY.getCode()));
    LocationInfo vObject = map.get(USATestData.COUNTY.getCode());
    Assert.assertEquals(USATestData.CO_C_ONE.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.CO_C_ONE.getDisplayLabel(), vObject.getLabel());
    // Validate the state values
    Assert.assertTrue(map.containsKey(USATestData.STATE.getCode()));
    vObject = map.get(USATestData.STATE.getCode());
    Assert.assertEquals(USATestData.COLORADO.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.COLORADO.getDisplayLabel(), vObject.getLabel());
    // Validate the country values
    Assert.assertTrue(map.containsKey(USATestData.COUNTRY.getCode()));
    vObject = map.get(USATestData.COUNTRY.getCode());
    Assert.assertEquals(USATestData.USA.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.USA.getDisplayLabel(), vObject.getLabel());
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList) LocationInfo(net.geoprism.registry.model.LocationInfo) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 22 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class ChangeRequestServiceTest method testUpdateGeoObjectCR.

private void testUpdateGeoObjectCR(String json, ClientRequestIF request) throws Exception {
    ServerGeoObjectService service = new ServerGeoObjectService();
    JsonObject jo = service.updateGeoObject(request.getSessionId(), FastTestDataset.CAMBODIA.getCode(), FastTestDataset.COUNTRY.getCode(), json, null, "test-notes");
    Assert.assertEquals(true, jo.get("isChangeRequest").getAsBoolean());
    Assert.assertEquals(36, jo.get("changeRequestId").getAsString().length());
    testUpdateGeoObjectCR_Verify();
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) JsonObject(com.google.gson.JsonObject)

Example 23 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class CreateGeoObjectAction method execute.

@Override
public void execute() {
    String sJson = this.getGeoObjectJson();
    GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
    ServerGeoObjectService service = new ServerGeoObjectService();
    service.apply(geoObject, true, false);
    ServerGeoObjectIF child = service.getGeoObjectByCode(geoObject.getCode(), geoObject.getType().getCode());
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getParentJson());
    child.setParents(ptnOt);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Example 24 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class SetParentAction method execute.

@Override
public void execute() {
    ServerGeoObjectService service = new ServerGeoObjectService();
    ServerGeoObjectIF child = service.getGeoObjectByCode(this.getChildCode(), this.getChildTypeCode());
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getJson());
    child.setParents(ptnOt);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Example 25 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class UpdateGeoObjectAction method execute.

@Override
public void execute() {
    String sJson = this.getGeoObjectJson();
    GeoObjectOverTime goTime = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
    ServerGeoObjectService builder = new ServerGeoObjectService();
    builder.apply(goTime, false, false);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)

Aggregations

ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)33 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)23 Request (com.runwaysdk.session.Request)10 JsonObject (com.google.gson.JsonObject)8 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)7 AllowAllGeoObjectPermissionService (net.geoprism.registry.permission.AllowAllGeoObjectPermissionService)7 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)7 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)6 Date (java.util.Date)5 JsonArray (com.google.gson.JsonArray)4 Location (net.geoprism.registry.io.Location)4 GraphType (net.geoprism.registry.model.GraphType)4 ServerCodeRestriction (net.geoprism.registry.query.ServerCodeRestriction)4 ServerGeoObjectQuery (net.geoprism.registry.query.ServerGeoObjectQuery)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 ArrayList (java.util.ArrayList)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 ServerGraphNode (net.geoprism.registry.model.ServerGraphNode)3 Test (org.junit.Test)3 InputStream (java.io.InputStream)2