Search in sources :

Example 1 with MasterListExcelExporterSheet

use of net.geoprism.registry.excel.MasterListExcelExporter.MasterListExcelExporterSheet in project geoprism-registry by terraframe.

the class MasterListShapefileExporter method writeDictionaryFile.

/**
 * Writes an additional "data dictionary" / metadata excel spreadsheet to the directory, which is intended to be
 * part of the final Shapfile. This is useful for downstream developers trying to make sense of the GIS data.
 *
 * See also:
 * - https://github.com/terraframe/geoprism-registry/issues/628
 */
private void writeDictionaryFile(File directory) {
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.version.getMdBusinessOid());
    List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> this.version.isValid(mdAttribute)).collect(Collectors.toList());
    mdAttributes = mdAttributes.stream().filter(mdAttribute -> !mdAttribute.definesAttribute().equals("invalid")).collect(Collectors.toList());
    String excelFilter;
    if (filterJson == null) {
        excelFilter = "[{attribute:invalid,value:false}]";
    } else {
        excelFilter = new String(filterJson);
    }
    try {
        File file = new File(directory, "metadata.xlsx");
        FileOutputStream fos = new FileOutputStream(file);
        MasterListExcelExporter exporter = new MasterListExcelExporter(this.version, mdBusiness, mdAttributes, excelFilter, this.columnNames, new MasterListExcelExporterSheet[] { MasterListExcelExporterSheet.DICTIONARY, MasterListExcelExporterSheet.METADATA });
        Workbook wb = exporter.createWorkbook();
        wb.write(fos);
    } catch (IOException e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : MdAttributeMultiPointDAOIF(com.runwaysdk.gis.dataaccess.MdAttributeMultiPointDAOIF) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder) Transaction(org.geotools.data.Transaction) Date(java.util.Date) MdAttributeBooleanDAOIF(com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF) LoggerFactory(org.slf4j.LoggerFactory) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) SimpleFeatureStore(org.geotools.data.simple.SimpleFeatureStore) SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) PipedInputStream(java.io.PipedInputStream) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Map(java.util.Map) MdAttributeCharacterDAOIF(com.runwaysdk.dataaccess.MdAttributeCharacterDAOIF) ShapefileDataStore(org.geotools.data.shapefile.ShapefileDataStore) ZipEntry(java.util.zip.ZipEntry) MdAttributeGeometryDAOIF(com.runwaysdk.gis.dataaccess.MdAttributeGeometryDAOIF) MdAttributeTextDAOIF(com.runwaysdk.dataaccess.MdAttributeTextDAOIF) MasterList(net.geoprism.registry.MasterList) BusinessQuery(com.runwaysdk.business.BusinessQuery) MasterListVersion(net.geoprism.registry.MasterListVersion) UnsupportedOperationException(com.amazonaws.services.kms.model.UnsupportedOperationException) DefaultGeographicCRS(org.geotools.referencing.crs.DefaultGeographicCRS) MdAttributeLongDAOIF(com.runwaysdk.dataaccess.MdAttributeLongDAOIF) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) MdAttributeLineStringDAOIF(com.runwaysdk.gis.dataaccess.MdAttributeLineStringDAOIF) MdAttributeDateDAOIF(com.runwaysdk.dataaccess.MdAttributeDateDAOIF) ZipOutputStream(java.util.zip.ZipOutputStream) ListFeatureCollection(org.geotools.data.collection.ListFeatureCollection) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) MdAttributeMultiPolygonDAOIF(com.runwaysdk.gis.dataaccess.MdAttributeMultiPolygonDAOIF) HashMap(java.util.HashMap) ShapefileDataStoreFactory(org.geotools.data.shapefile.ShapefileDataStoreFactory) FeatureCollection(org.geotools.feature.FeatureCollection) MdAttributeDoubleDAOIF(com.runwaysdk.dataaccess.MdAttributeDoubleDAOIF) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) LineString(com.vividsolutions.jts.geom.LineString) Point(com.vividsolutions.jts.geom.Point) ArrayList(java.util.ArrayList) SimpleFeatureSource(org.geotools.data.simple.SimpleFeatureSource) MdAttributeMultiLineStringDAOIF(com.runwaysdk.gis.dataaccess.MdAttributeMultiLineStringDAOIF) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF) DefaultAttribute(org.commongeoregistry.adapter.constants.DefaultAttribute) Charset(java.nio.charset.Charset) SessionPredicate(net.geoprism.gis.geoserver.SessionPredicate) MasterListExcelExporter(net.geoprism.registry.excel.MasterListExcelExporter) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) VaultProperties(com.runwaysdk.constants.VaultProperties) Logger(org.slf4j.Logger) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) MdAttributeDateTimeDAOIF(com.runwaysdk.dataaccess.MdAttributeDateTimeDAOIF) FileInputStream(java.io.FileInputStream) PipedOutputStream(java.io.PipedOutputStream) RegistryConstants(net.geoprism.registry.RegistryConstants) File(java.io.File) OIterator(com.runwaysdk.query.OIterator) Workbook(org.apache.poi.ss.usermodel.Workbook) MdAttributePolygonDAOIF(com.runwaysdk.gis.dataaccess.MdAttributePolygonDAOIF) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) Business(com.runwaysdk.business.Business) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) DefaultTransaction(org.geotools.data.DefaultTransaction) MdAttributePointDAOIF(com.runwaysdk.gis.dataaccess.MdAttributePointDAOIF) MasterListExcelExporterSheet(net.geoprism.registry.excel.MasterListExcelExporter.MasterListExcelExporterSheet) InputStream(java.io.InputStream) Polygon(com.vividsolutions.jts.geom.Polygon) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) FileOutputStream(java.io.FileOutputStream) MasterListExcelExporter(net.geoprism.registry.excel.MasterListExcelExporter) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) IOException(java.io.IOException) File(java.io.File) Workbook(org.apache.poi.ss.usermodel.Workbook) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Aggregations

UnsupportedOperationException (com.amazonaws.services.kms.model.UnsupportedOperationException)1 Business (com.runwaysdk.business.Business)1 BusinessQuery (com.runwaysdk.business.BusinessQuery)1 VaultProperties (com.runwaysdk.constants.VaultProperties)1 MdAttributeBooleanDAOIF (com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF)1 MdAttributeCharacterDAOIF (com.runwaysdk.dataaccess.MdAttributeCharacterDAOIF)1 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)1 MdAttributeDateDAOIF (com.runwaysdk.dataaccess.MdAttributeDateDAOIF)1 MdAttributeDateTimeDAOIF (com.runwaysdk.dataaccess.MdAttributeDateTimeDAOIF)1 MdAttributeDoubleDAOIF (com.runwaysdk.dataaccess.MdAttributeDoubleDAOIF)1 MdAttributeLongDAOIF (com.runwaysdk.dataaccess.MdAttributeLongDAOIF)1 MdAttributeTextDAOIF (com.runwaysdk.dataaccess.MdAttributeTextDAOIF)1 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 MdAttributeGeometryDAOIF (com.runwaysdk.gis.dataaccess.MdAttributeGeometryDAOIF)1 MdAttributeLineStringDAOIF (com.runwaysdk.gis.dataaccess.MdAttributeLineStringDAOIF)1 MdAttributeMultiLineStringDAOIF (com.runwaysdk.gis.dataaccess.MdAttributeMultiLineStringDAOIF)1 MdAttributeMultiPointDAOIF (com.runwaysdk.gis.dataaccess.MdAttributeMultiPointDAOIF)1 MdAttributeMultiPolygonDAOIF (com.runwaysdk.gis.dataaccess.MdAttributeMultiPolygonDAOIF)1