Search in sources :

Example 16 with ServerGeoObjectService

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

the class GraphService method addChild.

@Request(RequestType.SESSION)
public JsonObject addChild(String sessionId, String parentCode, String parentGeoObjectTypeCode, String childCode, String childGeoObjectTypeCode, String graphTypeCode, Date startDate, Date endDate) {
    ServerGeoObjectService service = ServiceFactory.getGeoObjectService();
    ServerGeoObjectIF parent = service.getGeoObjectByCode(parentCode, parentGeoObjectTypeCode, true);
    ServerGeoObjectIF child = service.getGeoObjectByCode(childCode, childGeoObjectTypeCode, true);
    GraphType graphType = this.getGraphType(graphTypeCode);
    // ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(),
    // parent.getType(), child.getType());
    ServerGraphNode node = parent.addGraphChild(child, graphType, startDate, endDate);
    return node.toJSON();
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GraphType(net.geoprism.registry.model.GraphType) ServerGraphNode(net.geoprism.registry.model.ServerGraphNode) Request(com.runwaysdk.session.Request)

Example 17 with ServerGeoObjectService

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

the class GraphService method getParents.

@Request(RequestType.SESSION)
public JsonObject getParents(String sessionId, String childCode, String childGeoObjectTypeCode, String graphTypeCode, Boolean recursive, Date date) {
    ServerGeoObjectService service = ServiceFactory.getGeoObjectService();
    ServerGeoObjectIF child = service.getGeoObjectByCode(childCode, childGeoObjectTypeCode, true);
    GraphType graphType = this.getGraphType(graphTypeCode);
    // ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(),
    // parent.getType(), child.getType());
    ServerGraphNode node = child.getGraphParents(graphType, recursive, date);
    return node.toJSON();
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GraphType(net.geoprism.registry.model.GraphType) ServerGraphNode(net.geoprism.registry.model.ServerGraphNode) Request(com.runwaysdk.session.Request)

Example 18 with ServerGeoObjectService

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

the class ListTypeService method record.

@Request(RequestType.SESSION)
public JsonObject record(String sessionId, String oid, String uid) {
    ListTypeVersion version = ListTypeVersion.get(oid);
    if (version.getWorking()) {
        ListType type = version.getListType();
        if (type.doesActorHaveExploratoryPermission()) {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
            ServerGeoObjectType geoObjectType = type.getGeoObjectType();
            ServerGeoObjectIF geoObject = new ServerGeoObjectService().getGeoObject(uid, geoObjectType.getCode());
            JsonObject object = new JsonObject();
            object.addProperty("recordType", "GEO_OBJECT");
            object.add("type", geoObject.getType().toJSON(new DefaultSerializer()));
            object.addProperty("code", geoObject.getCode());
            object.addProperty(ListTypeVersion.FORDATE, format.format(version.getForDate()));
            // Add geometry so we can zoom to it
            object.add("geoObject", geoObject.toGeoObject(version.getForDate()).toJSON());
            return object;
        }
    }
    return version.record(uid);
}
Also used : DefaultSerializer(org.commongeoregistry.adapter.metadata.DefaultSerializer) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) SimpleDateFormat(java.text.SimpleDateFormat) Request(com.runwaysdk.session.Request)

Example 19 with ServerGeoObjectService

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

the class FhirImportTest method testBasicImport.

@Request
@Test
public void testBasicImport() throws InterruptedException {
    try {
        FhirExternalSystem system = createExternalSystem();
        SynchronizationConfig config = createSyncConfig(system);
        FhirSyncImportConfig iConfig = (FhirSyncImportConfig) config.buildConfiguration();
        FhirResourceProcessor processor = FhirFactory.getProcessor(iConfig.getImplementation());
        IParser parser = FhirContext.forR4().newJsonParser();
        Bundle bundle = new Bundle();
        bundle.addEntry(new BundleEntryComponent().setResource((Resource) parser.parseResource(this.getClass().getResourceAsStream("/fhir/organization.json"))));
        bundle.addEntry(new BundleEntryComponent().setResource((Resource) parser.parseResource(this.getClass().getResourceAsStream("/fhir/location.json"))));
        FhirResourceImporter importer = new FhirResourceImporter(new BasicFhirConnection(system), processor, null, null);
        importer.synchronize(bundle);
        ServerGeoObjectIF geoobject = new ServerGeoObjectService().getGeoObjectByCode("USATestDataHsTwo", "USATestDataHealthStop");
        geoobject.setDate(new Date());
        LocalizedValue displayLabel = geoobject.getDisplayLabel();
        Assert.assertEquals("USATestDataHsTwo ZZZZZZZ", displayLabel.getValue());
    } finally {
        TestDataSet.deleteExternalSystems("FHIRImportTest");
    }
}
Also used : FhirResourceImporter(net.geoprism.registry.etl.fhir.FhirResourceImporter) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) BasicFhirResourceProcessor(net.geoprism.registry.etl.fhir.BasicFhirResourceProcessor) FhirResourceProcessor(net.geoprism.registry.etl.fhir.FhirResourceProcessor) BasicFhirConnection(net.geoprism.registry.etl.fhir.BasicFhirConnection) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Date(java.util.Date) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) IParser(ca.uhn.fhir.parser.IParser) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 20 with ServerGeoObjectService

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

the class ShapefileServiceTest method testImportShapefileWithBadParentCode.

@Test
@Request
public void testImportShapefileWithBadParentCode() throws Throwable {
    GeoObject geoObj = ServiceFactory.getRegistryService().newGeoObjectInstance(testData.clientRequest.getSessionId(), USATestData.COUNTRY.getCode());
    geoObj.setCode("00");
    geoObj.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, "Test Label");
    geoObj.setUid(ServiceFactory.getIdService().getUids(1)[0]);
    ServerGeoObjectIF serverGO = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).apply(geoObj, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE, true, false);
    geoObj = RegistryService.getInstance().getGeoObjectByCode(Session.getCurrentSession().getOid(), serverGO.getCode(), serverGO.getType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
    InputStream istream = this.getClass().getResourceAsStream("/cb_2017_us_state_500k.zip.test");
    Assert.assertNotNull(istream);
    ShapefileService service = new ShapefileService();
    GeoObjectImportConfiguration config = this.getTestConfiguration(istream, service, null, ImportStrategy.NEW_AND_UPDATE);
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
    config.setHierarchy(hierarchyType);
    config.addParent(new Location(USATestData.COUNTRY.getServerObject(), hierarchyType, new BasicColumnFunction("GEOID"), ParentMatchStrategy.CODE));
    ImportHistory hist = mockImport(config);
    Assert.assertTrue(hist.getStatus().get(0).equals(AllJobStatus.FEEDBACK));
    hist = ImportHistory.get(hist.getOid());
    Assert.assertEquals(new Long(56), hist.getWorkTotal());
    Assert.assertEquals(new Long(56), hist.getWorkProgress());
    Assert.assertEquals(new Long(0), hist.getImportedRecords());
    Assert.assertEquals(ImportStage.VALIDATION_RESOLVE, hist.getStage().get(0));
    final GeoObjectImportConfiguration test = new GeoObjectImportConfiguration();
    test.fromJSON(hist.getConfigJson(), false);
    // TODO
    // Assert.assertEquals(config.getParentLookupType(),
    // test.getParentLookupType());
    // JSONArray errors = new JSONArray(hist.getErrorJson());
    // 
    // Assert.assertEquals(0, errors.length());
    // Ensure the geo objects were not created
    ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(USATestData.STATE.getServerObject(), config.getStartDate());
    query.setRestriction(new ServerCodeRestriction("01"));
    Assert.assertNull(query.getSingleResult());
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) InputStream(java.io.InputStream) BasicColumnFunction(net.geoprism.data.importer.BasicColumnFunction) ShapefileService(net.geoprism.registry.service.ShapefileService) ServerGeoObjectQuery(net.geoprism.registry.query.ServerGeoObjectQuery) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) ServerCodeRestriction(net.geoprism.registry.query.ServerCodeRestriction) AllowAllGeoObjectPermissionService(net.geoprism.registry.permission.AllowAllGeoObjectPermissionService) Location(net.geoprism.registry.io.Location) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

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