Search in sources :

Example 1 with RevealExternalSystem

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());
}
Also used : RevealExternalSystem(net.geoprism.registry.graph.RevealExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) RevealExternalSystem(net.geoprism.registry.graph.RevealExternalSystem) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 2 with RevealExternalSystem

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);
}
Also used : RevealExternalSystem(net.geoprism.registry.graph.RevealExternalSystem) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 3 with RevealExternalSystem

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;
    }
}
Also used : LatLonException(net.geoprism.registry.io.LatLonException) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) CoordinateSequence2D(org.jaitools.jts.CoordinateSequence2D) RevealExternalSystem(net.geoprism.registry.graph.RevealExternalSystem) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ShapefileFunction(net.geoprism.data.importer.ShapefileFunction) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 4 with RevealExternalSystem

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);
    }
}
Also used : GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ExcelDataFormatter(net.geoprism.data.etl.excel.ExcelDataFormatter) RevealExternalSystem(net.geoprism.registry.graph.RevealExternalSystem) ExcelSheetReader(net.geoprism.data.etl.excel.ExcelSheetReader) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) FileInputStream(java.io.FileInputStream) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) ImportFileFormatException(net.geoprism.registry.etl.ImportFileFormatException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) LatLonException(net.geoprism.registry.io.LatLonException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Request(com.runwaysdk.session.Request)

Example 5 with RevealExternalSystem

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());
}
Also used : RevealExternalSystem(net.geoprism.registry.graph.RevealExternalSystem) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) Date(java.util.Date) ServerExternalIdRestriction(net.geoprism.registry.query.ServerExternalIdRestriction) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

RevealExternalSystem (net.geoprism.registry.graph.RevealExternalSystem)5 Request (com.runwaysdk.session.Request)4 Test (org.junit.Test)3 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)2 LatLonException (net.geoprism.registry.io.LatLonException)2 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 Point (com.vividsolutions.jts.geom.Point)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Date (java.util.Date)1 ExcelDataFormatter (net.geoprism.data.etl.excel.ExcelDataFormatter)1 ExcelSheetReader (net.geoprism.data.etl.excel.ExcelSheetReader)1 ShapefileFunction (net.geoprism.data.importer.ShapefileFunction)1 ImportFileFormatException (net.geoprism.registry.etl.ImportFileFormatException)1 ExternalSystem (net.geoprism.registry.graph.ExternalSystem)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 ServerExternalIdRestriction (net.geoprism.registry.query.ServerExternalIdRestriction)1