diff --git a/io/plugins/eu.esdihumboldt.hale.io.shp.test/src/eu/esdihumboldt/hale/io/shp/ShapefileInstanceWriterTest.groovy b/io/plugins/eu.esdihumboldt.hale.io.shp.test/src/eu/esdihumboldt/hale/io/shp/ShapefileInstanceWriterTest.groovy index a3d1b3dd84..de1cc369ad 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.shp.test/src/eu/esdihumboldt/hale/io/shp/ShapefileInstanceWriterTest.groovy +++ b/io/plugins/eu.esdihumboldt.hale.io.shp.test/src/eu/esdihumboldt/hale/io/shp/ShapefileInstanceWriterTest.groovy @@ -169,7 +169,7 @@ class ShapefileInstanceWriterTest { IOReport report = writer.execute(new LogProgressIndicator()) assertTrue(report.isSuccess()) - assertFalse(report.getErrors().isEmpty()) + assertFalse(report.getWarnings().isEmpty()) return report; } diff --git a/io/plugins/eu.esdihumboldt.hale.io.shp.ui/plugin.xml b/io/plugins/eu.esdihumboldt.hale.io.shp.ui/plugin.xml index 1081b9d401..18aa118524 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.shp.ui/plugin.xml +++ b/io/plugins/eu.esdihumboldt.hale.io.shp.ui/plugin.xml @@ -21,7 +21,7 @@ diff --git a/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/ShapeTargetCRSConfigurationPage.java b/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/ShapeTargetCRSConfigurationPage.java new file mode 100644 index 0000000000..0c0e87ff6e --- /dev/null +++ b/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/ShapeTargetCRSConfigurationPage.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 wetransform GmbH + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + * + * Contributors: + * wetransform GmbH + */ + +package eu.esdihumboldt.hale.io.shp.ui; + +import eu.esdihumboldt.hale.common.core.io.IOProvider; +import eu.esdihumboldt.hale.common.instance.io.GeoInstanceWriter; +import eu.esdihumboldt.hale.ui.io.IOWizard; +import eu.esdihumboldt.hale.ui.io.config.SimpleTargetCRSConfigurationPage; + +/** + * Configuration page for the Shape UI. + * + * @param the concrete I/O wizard type + * @param

the {@link IOProvider} type used in the wizard + * + * @author Emanuela Epure + */ +public class ShapeTargetCRSConfigurationPage

> + extends SimpleTargetCRSConfigurationPage { + + /** + * Default constructor. + */ + public ShapeTargetCRSConfigurationPage() { + super(true); + } + +} diff --git a/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/TypeSelectionPage.java b/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/TypeSelectionPage.java index 4586288239..a9d9e27312 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/TypeSelectionPage.java +++ b/io/plugins/eu.esdihumboldt.hale.io.shp.ui/src/eu/esdihumboldt/hale/io/shp/ui/TypeSelectionPage.java @@ -63,11 +63,8 @@ public class TypeSelectionPage extends InstanceReaderConfigurationPage implements ShapefileConstants { private TypeDefinitionSelector selector; - private LocatableInputSupplier lastSource; - private TypeDefinition lastType; - private Button matchShortPropertyNames; /** diff --git a/io/plugins/eu.esdihumboldt.hale.io.shp/src/eu/esdihumboldt/hale/io/shp/writer/ShapefileInstanceWriter.java b/io/plugins/eu.esdihumboldt.hale.io.shp/src/eu/esdihumboldt/hale/io/shp/writer/ShapefileInstanceWriter.java index e9297b5c9f..5d60e06c5d 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.shp/src/eu/esdihumboldt/hale/io/shp/writer/ShapefileInstanceWriter.java +++ b/io/plugins/eu.esdihumboldt.hale.io.shp/src/eu/esdihumboldt/hale/io/shp/writer/ShapefileInstanceWriter.java @@ -118,7 +118,8 @@ protected IOReport execute(ProgressIndicator progress, IOReporter reporter) return file.toURI(); }).collect(Collectors.toList()); - // Reset the target property so that a caller can find out which + // Reset the target property so that a caller can find out + // which // files were created. setTarget(new MultiLocationOutputSupplier(uris)); } @@ -152,7 +153,7 @@ protected String getDefaultTypeName() { * 3. create features
* 4. write the feature data to the Shapefile. * - * @param instances instance to write to. + * @param instanceCollection instance to write to. * @param progress the progress indicator. * @param reporter the reporter. * @param location file path URI. @@ -162,19 +163,19 @@ protected String getDefaultTypeName() { * @throws IOException exception in any. * */ - protected List writeInstances(InstanceCollection instances, ProgressIndicator progress, - IOReporter reporter, URI location) throws IOException { + protected List writeInstances(InstanceCollection instanceCollection, + ProgressIndicator progress, IOReporter reporter, URI location) throws IOException { // in all the variables, outer Map is for tracking multiple schemas and // inner Map for multiple geometries. - Map> schemaFtMap = createFeatureType(instances, - progress, reporter); + Map> schemaFtMap = createFeatureType( + instanceCollection, progress, reporter); Map> schemaDataStoreMap = createSchema(location, schemaFtMap); - Map>> schemaFeaturesMap = createFeatures(instances, - progress, reporter, schemaFtMap); + Map>> schemaFeaturesMap = createFeatures( + instanceCollection, progress, reporter, schemaFtMap); return writeToFile(schemaDataStoreMap, schemaFtMap, schemaFeaturesMap); } @@ -226,13 +227,16 @@ private Map> createFeatureType( // present. } } - for (String localPart : missingGeomsForSchemas) { - reporter.error( - "Cannot create Shapefile for Schema: " + localPart + " as no Geometry found!!"); - } + // create SimpleFeatureType from SimpleFeatureTypeBuilder. for (Entry> schemaEntry : schemaBuilderMap .entrySet()) { + + if (missingGeomsForSchemas.contains(schemaEntry.getKey())) { + reporter.warn("No geometry found for " + schemaEntry.getKey()); + continue; + } + for (Entry geometryEntry : schemaEntry.getValue() .entrySet()) { SimpleFeatureType buildFeatureType = geometryEntry.getValue().buildFeatureType(); @@ -439,9 +443,6 @@ private void createSimpleFeatureTypeBuilderWithGeometry(String localPart, private Map> createSchema(URI location, Map> schemaSftMap) throws IOException { - if (schemaSftMap.isEmpty()) { - throw new IOException("Cannot export to the shape file as no Geometry found!!"); - } Map> schemaDataStoreMap = new HashMap>(); // logic to create file name based on the multiple schemas and/or @@ -635,8 +636,15 @@ private void writePropertiesInstanceData( List> geoms = traverseInstanceForGeometries(instance); // add value by traversing geometryType from instance for (GeometryProperty geoProp : geoms) { - String geometryType = geoProp.getGeometry().getGeometryType(); - schemaFbMap.get(localPart).get(geometryType).add(value); + if (geoProp.getGeometry() != null) { + String geometryType = geoProp.getGeometry().getGeometryType(); + if (schemaFbMap.get(localPart) != null + && schemaFbMap.get(localPart).get(geometryType) != null + && value != null) { + schemaFbMap.get(localPart).get(geometryType).add(value); + } + } + } } } diff --git a/ui/plugins/eu.esdihumboldt.hale.ui/src/eu/esdihumboldt/hale/ui/io/config/SimpleTargetCRSConfigurationPage.java b/ui/plugins/eu.esdihumboldt.hale.ui/src/eu/esdihumboldt/hale/ui/io/config/SimpleTargetCRSConfigurationPage.java index 64291223a0..31af39ce1c 100644 --- a/ui/plugins/eu.esdihumboldt.hale.ui/src/eu/esdihumboldt/hale/ui/io/config/SimpleTargetCRSConfigurationPage.java +++ b/ui/plugins/eu.esdihumboldt.hale.ui/src/eu/esdihumboldt/hale/ui/io/config/SimpleTargetCRSConfigurationPage.java @@ -22,10 +22,12 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.PlatformUI; import org.geotools.referencing.CRS; import eu.esdihumboldt.hale.common.core.io.IOProvider; @@ -49,6 +51,7 @@ public class SimpleTargetCRSConfigurationPage