Search in sources :

Example 31 with ServerGeoObjectService

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

the class ServiceFactory method initialize.

private void initialize() {
    this.registryService = new RegistryService();
    this.cs = new ConversionService();
    this.idService = new RegistryIdService();
    this.adapter = new RegistryAdapterServer(this.idService);
    this.accountService = new AccountService();
    this.goPermissionServ = new GeoObjectPermissionService();
    this.serverGoService = new ServerGeoObjectService(goPermissionServ);
    this.hierarchyService = new HierarchyService();
    this.orgServ = new OrganizationPermissionService();
    this.hierarchyPermServ = new HierarchyTypePermissionService();
    this.goRelPermissionServ = new GeoObjectRelationshipPermissionService();
    this.goTypeRelPermissionServ = new GeoObjectTypeRelationshipPermissionService();
    this.goTypePermissionServ = new GeoObjectTypePermissionService();
    this.rolePermissionServ = new RolePermissionService();
    this.metadataCache = new ServerMetadataCache(this.adapter);
    this.metadataCache.rebuild();
    this.registryService.initialize(this.adapter);
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) HierarchyTypePermissionService(net.geoprism.registry.permission.HierarchyTypePermissionService) HierarchyService(net.geoprism.registry.hierarchy.HierarchyService) ServerMetadataCache(net.geoprism.registry.cache.ServerMetadataCache) OrganizationPermissionService(net.geoprism.registry.permission.OrganizationPermissionService) RegistryAdapterServer(org.commongeoregistry.adapter.RegistryAdapterServer) GeoObjectRelationshipPermissionService(net.geoprism.registry.permission.GeoObjectRelationshipPermissionService) GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) GeoObjectTypeRelationshipPermissionService(net.geoprism.registry.permission.GeoObjectTypeRelationshipPermissionService) GeoObjectTypePermissionService(net.geoprism.registry.permission.GeoObjectTypePermissionService)

Example 32 with ServerGeoObjectService

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

the class ShapefileServiceTest method testBadParentSynonymAndResume.

@Test
@Request
public void testBadParentSynonymAndResume() throws Throwable {
    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("LSAD"), ParentMatchStrategy.ALL));
    // ImportHistory hist = mockImport(config);
    // Assert.assertTrue(hist.getStatus().get(0).equals(AllJobStatus.FEEDBACK));
    ImportHistory hist = importShapefile(testData.clientRequest.getSessionId(), config.toJSON().toString());
    SchedulerTestUtils.waitUntilStatus(hist.getOid(), 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));
    JSONObject page = new JSONObject(new ETLService().getValidationProblems(testData.clientRequest.getSessionId(), hist.getOid(), false, 100, 1).toString());
    JSONArray results = page.getJSONArray("resultSet");
    Assert.assertEquals(1, results.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());
    // Resolve the import problem with a synonym
    GeoObject geoObj = ServiceFactory.getRegistryService().newGeoObjectInstance(testData.clientRequest.getSessionId(), USATestData.COUNTRY.getCode());
    geoObj.setCode("99");
    geoObj.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, "Test Label99");
    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);
    JSONObject valRes = new JSONObject();
    valRes.put("validationProblemId", results.getJSONObject(0).getString("id"));
    valRes.put("resolution", ValidationResolution.SYNONYM);
    valRes.put("code", serverGo.getCode());
    valRes.put("typeCode", serverGo.getType().getCode());
    valRes.put("label", "00");
    new ETLService().submitValidationProblemResolution(testData.clientRequest.getSessionId(), valRes.toString());
    ValidationProblem vp = ValidationProblem.get(results.getJSONObject(0).getString("id"));
    Assert.assertEquals(ValidationResolution.SYNONYM.name(), vp.getResolution());
    Assert.assertEquals(ParentReferenceProblem.DEFAULT_SEVERITY, vp.getSeverity());
    ImportHistory hist2 = importShapefile(testData.clientRequest.getSessionId(), hist.getConfigJson());
    Assert.assertEquals(hist.getOid(), hist2.getOid());
    SchedulerTestUtils.waitUntilStatus(hist.getOid(), AllJobStatus.SUCCESS);
    hist = ImportHistory.get(hist.getOid());
    Assert.assertEquals(ImportStage.COMPLETE, hist.getStage().get(0));
    Assert.assertEquals(new Long(56), hist.getWorkTotal());
    Assert.assertEquals(new Long(56), hist.getWorkProgress());
    Assert.assertEquals(new Long(56), hist.getImportedRecords());
    String sessionId = testData.clientRequest.getSessionId();
    GeoObject go = ServiceFactory.getRegistryService().getGeoObjectByCode(sessionId, "01", USATestData.STATE.getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
    Assert.assertEquals("01", go.getCode());
    ParentTreeNode nodes = ServiceFactory.getRegistryService().getParentGeoObjects(sessionId, go.getCode(), config.getType().getCode(), new String[] { USATestData.COUNTRY.getCode() }, false, TestDataSet.DEFAULT_OVER_TIME_DATE);
    List<ParentTreeNode> parents = nodes.getParents();
    Assert.assertEquals(1, parents.size());
    JSONObject page2 = new JSONObject(new ETLService().getValidationProblems(testData.clientRequest.getSessionId(), hist.getOid(), false, 100, 1).toString());
    JSONArray results2 = page2.getJSONArray("resultSet");
    Assert.assertEquals(0, results2.length());
    Assert.assertEquals(0, page2.getInt("count"));
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) InputStream(java.io.InputStream) BasicColumnFunction(net.geoprism.data.importer.BasicColumnFunction) JSONArray(org.json.JSONArray) ShapefileService(net.geoprism.registry.service.ShapefileService) ServerGeoObjectQuery(net.geoprism.registry.query.ServerGeoObjectQuery) JSONObject(org.json.JSONObject) ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) ServerCodeRestriction(net.geoprism.registry.query.ServerCodeRestriction) Location(net.geoprism.registry.io.Location) AllowAllGeoObjectPermissionService(net.geoprism.registry.permission.AllowAllGeoObjectPermissionService) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 33 with ServerGeoObjectService

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

the class ChangeRequestServiceTest method testCreateGeoObjectCR.

private void testCreateGeoObjectCR(String[] json, ClientRequestIF request) throws Exception {
    ServerGeoObjectService service = new ServerGeoObjectService();
    JsonObject jo = service.createGeoObject(request.getSessionId(), json[0], json[1], null, "test-notes");
    Assert.assertEquals(true, jo.get("isChangeRequest").getAsBoolean());
    Assert.assertEquals(36, jo.get("changeRequestId").getAsString().length());
    testCreateGeoObjectCR_Verify();
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) JsonObject(com.google.gson.JsonObject)

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