use of net.geoprism.registry.graph.RevealExternalSystem in project geoprism-registry by terraframe.
the class ExternalSystemTest method testCreateRevealExternalSystem.
@Test
@Request
public void testCreateRevealExternalSystem() {
RevealExternalSystem system = new RevealExternalSystem();
system.setId(EXTERNAL_SYSTEM_ID);
system.setOrganization(FastTestDataset.ORG_CGOV.getServerObject());
system.getEmbeddedComponent(ExternalSystem.LABEL).setValue("defaultLocale", "Test");
system.getEmbeddedComponent(ExternalSystem.DESCRIPTION).setValue("defaultLocale", "Test");
system.apply();
ExternalSystem test = ExternalSystem.get(system.getOid());
Assert.assertEquals(system.getId(), test.getId());
}
use of net.geoprism.registry.graph.RevealExternalSystem in project geoprism-registry by terraframe.
the class ExternalSystemTest method testAddExternalId.
@Test
@Request
public void testAddExternalId() {
RevealExternalSystem system = new RevealExternalSystem();
system.setId(EXTERNAL_SYSTEM_ID);
system.setOrganization(FastTestDataset.ORG_CGOV.getServerObject());
system.getEmbeddedComponent(ExternalSystem.LABEL).setValue("defaultLocale", "Test");
system.getEmbeddedComponent(ExternalSystem.DESCRIPTION).setValue("defaultLocale", "Test");
system.apply();
String expected = "EXTERNAL ID";
ServerGeoObjectIF serverGO = FastTestDataset.PROV_CENTRAL.getServerObject();
serverGO.createExternalId(system, expected, ImportStrategy.NEW_ONLY);
String actual = serverGO.getExternalId(system);
Assert.assertEquals(expected, actual);
}
use of net.geoprism.registry.graph.RevealExternalSystem in project geoprism-registry by terraframe.
the class ExcelImporter method getGeometry.
@Override
public Geometry getGeometry(FeatureRow row) {
if (this.config.isExternalImport() && this.config.getExternalSystem() instanceof RevealExternalSystem) {
return ((RevealExcelContentHandler) this.excelHandler).getGeometry();
} else {
ShapefileFunction latitudeFunction = this.config.getFunction(GeoObjectImportConfiguration.LATITUDE);
ShapefileFunction longitudeFunction = this.config.getFunction(GeoObjectImportConfiguration.LONGITUDE);
if (latitudeFunction != null && longitudeFunction != null) {
Object latitude = latitudeFunction.getValue(row);
Object longitude = longitudeFunction.getValue(row);
if (latitude != null && longitude != null) {
Double lat = new Double(latitude.toString());
Double lon = new Double(longitude.toString());
if (Math.abs(lat) > 90 || Math.abs(lon) > 180) {
LatLonException ex = new LatLonException();
ex.setLat(lat.toString());
ex.setLon(lon.toString());
throw ex;
}
ImportConfiguration configuration = this.objectImporter.getConfiguration();
if (configuration instanceof GeoObjectImportConfiguration) {
ServerGeoObjectType type = ((GeoObjectImportConfiguration) configuration).getType();
if (type.getGeometryType().equals(GeometryType.POINT) || type.getGeometryType().equals(GeometryType.MIXED)) {
return new Point(new CoordinateSequence2D(lon, lat), factory);
}
}
return new MultiPoint(new Point[] { new Point(new CoordinateSequence2D(lon, lat), factory) }, factory);
}
}
return null;
}
}
use of net.geoprism.registry.graph.RevealExternalSystem in project geoprism-registry by terraframe.
the class ExcelImporter method process.
@Request
private void process(ImportStage stage, File file) throws InvocationTargetException, IOException {
try {
/*
* Check permissions
*/
ImportConfiguration config = this.getObjectImporter().getConfiguration();
config.enforceCreatePermissions();
// TODO Determine permissions for
this.progressListener.setWorkTotal(this.getWorkTotal(file));
if (this.config.isExternalImport() && this.config.getExternalSystem() instanceof RevealExternalSystem && this.config instanceof GeoObjectImportConfiguration) {
this.excelHandler = new RevealExcelContentHandler(this.objectImporter, stage, this.getStartIndex(), ((GeoObjectImportConfiguration) this.config).getRevealGeometryColumn());
} else {
this.excelHandler = new ExcelContentHandler(this.objectImporter, stage, this.getStartIndex());
}
ExcelDataFormatter formatter = new ExcelDataFormatter();
ExcelSheetReader reader = new ExcelSheetReader(excelHandler, formatter);
reader.process(new FileInputStream(file));
} catch (Exception e) {
throw new ProgrammingErrorException(e);
}
}
use of net.geoprism.registry.graph.RevealExternalSystem in project geoprism-registry by terraframe.
the class ExternalSystemTest method testVertexExternalIdRestriction.
@Test
@Request
public void testVertexExternalIdRestriction() {
RevealExternalSystem system = new RevealExternalSystem();
system.setId(EXTERNAL_SYSTEM_ID);
system.setOrganization(FastTestDataset.ORG_CGOV.getServerObject());
system.getEmbeddedComponent(ExternalSystem.LABEL).setValue("defaultLocale", "Test");
system.getEmbeddedComponent(ExternalSystem.DESCRIPTION).setValue("defaultLocale", "Test");
system.apply();
String externalId = "EXTERNAL ID";
ServerGeoObjectIF serverGO = FastTestDataset.PROV_CENTRAL.getServerObject();
serverGO.createExternalId(system, externalId, ImportStrategy.NEW_ONLY);
VertexGeoObjectQuery query = new VertexGeoObjectQuery(FastTestDataset.PROVINCE.getServerObject(), new Date());
query.setRestriction(new ServerExternalIdRestriction(system, externalId));
ServerGeoObjectIF result = query.getSingleResult();
Assert.assertNotNull(result);
Assert.assertEquals(serverGO.getCode(), result.getCode());
}
Aggregations