use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class GeoObjectImporterTest method testCreateOnly.
@Test
@Request
public void testCreateOnly() throws InterruptedException {
// USATestData.CO_D_ONE.delete();
InputStream istream = this.getClass().getResourceAsStream("/test-spreadsheet2.xlsx");
Assert.assertNotNull(istream);
ExcelService service = new ExcelService();
ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
GeoObjectImportConfiguration config = this.getTestConfiguration(istream, service, null, ImportStrategy.NEW_ONLY);
config.setHierarchy(hierarchyType);
ImportHistory hist = importExcelFile(testData.clientRequest.getSessionId(), config.toJSON().toString());
SchedulerTestUtils.waitUntilStatus(hist.getOid(), AllJobStatus.FEEDBACK);
hist = ImportHistory.get(hist.getOid());
Assert.assertEquals(new Long(ROW_COUNT), hist.getWorkTotal());
Assert.assertEquals(new Long(ROW_COUNT), hist.getWorkProgress());
Assert.assertEquals(new Long(2), hist.getImportedRecords());
Assert.assertEquals(ImportStage.IMPORT_RESOLVE, hist.getStage().get(0));
GeoObject object = ServiceFactory.getRegistryService().getGeoObjectByCode(testData.clientRequest.getSessionId(), "0001", USATestData.DISTRICT.getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
Assert.assertNotNull(object);
Assert.assertEquals("Test", object.getLocalizedDisplayLabel());
Geometry geometry = object.getGeometry();
Assert.assertNotNull(geometry);
Double lat = new Double(2.232343);
Double lon = new Double(1.134232);
GeometryFactory factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326);
Point expected = new Point(new CoordinateSequence2D(lon, lat), factory);
Assert.assertEquals(expected, geometry);
GeoObject coloradoDistOne = ServiceFactory.getRegistryService().getGeoObjectByCode(testData.clientRequest.getSessionId(), USATestData.CO_D_ONE.getCode(), USATestData.DISTRICT.getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
Double cd1_lat = new Double(80);
Double cd1_lon = new Double(110);
GeometryFactory cd1_factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326);
Point cd1_expected = new Point(new CoordinateSequence2D(cd1_lon, cd1_lat), cd1_factory);
Geometry cd1_geometry = coloradoDistOne.getGeometry();
Assert.assertEquals(cd1_expected, cd1_geometry);
JSONObject json = new JSONObject(new ETLService().getImportErrors(testData.clientRequest.getSessionId(), hist.getOid(), false, 100, 1).toString());
Assert.assertEquals(1, json.getJSONArray("resultSet").length());
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class InheritedHierarchyAnnotationTest method testGetTypeAncestorsInherited.
@Test
@Request
public void testGetTypeAncestorsInherited() {
ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
try {
ServerGeoObjectType childType = TEST_CHILD.getServerObject();
List<GeoObjectType> results = childType.getTypeAncestors(TEST_HT.getServerObject(), true);
Assert.assertEquals(2, results.size());
} finally {
annotation.delete();
}
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class InheritedHierarchyAnnotationTest method testFindHierarchy.
@Test
@Request
public void testFindHierarchy() {
ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
try {
ServerGeoObjectType childType = TEST_CHILD.getServerObject();
ServerHierarchyType hierarchy = childType.findHierarchy(forHierarchy, FastTestDataset.COUNTRY.getServerObject());
Assert.assertEquals(FastTestDataset.HIER_ADMIN.getCode(), hierarchy.getCode());
} finally {
annotation.delete();
}
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class InheritedHierarchyAnnotationTest method testGetByForHierarchy.
@Test
@Request
public void testGetByForHierarchy() {
ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
try {
List<? extends InheritedHierarchyAnnotation> annotations = InheritedHierarchyAnnotation.getByRelationship(forHierarchy.getHierarchicalRelationshipType());
Assert.assertEquals(1, annotations.size());
InheritedHierarchyAnnotation test = annotations.get(0);
Assert.assertEquals(test.getOid(), annotation.getOid());
} finally {
annotation.delete();
}
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class InheritedHierarchyAnnotationTest method testGetByInheritedHierarchy.
@Test
@Request
public void testGetByInheritedHierarchy() {
ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
try {
List<? extends InheritedHierarchyAnnotation> annotations = InheritedHierarchyAnnotation.getByRelationship(inheritedHierarchy.getHierarchicalRelationshipType());
Assert.assertEquals(1, annotations.size());
InheritedHierarchyAnnotation test = annotations.get(0);
Assert.assertEquals(test.getOid(), annotation.getOid());
} finally {
annotation.delete();
}
}
Aggregations