Search in sources :

Example 1 with ListTypeExcelExporter

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

the class GeoRegistryUtil method exportListTypeExcel.

@Transaction
public static InputStream exportListTypeExcel(String oid, String json) {
    ListTypeVersion version = ListTypeVersion.get(oid);
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(version.getMdBusinessOid());
    JsonObject criteria = (json != null) ? JsonParser.parseString(json).getAsJsonObject() : new JsonObject();
    List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> version.isValid(mdAttribute)).collect(Collectors.toList());
    if (json.contains("invalid")) {
        mdAttributes = mdAttributes.stream().filter(mdAttribute -> !mdAttribute.definesAttribute().equals("invalid")).collect(Collectors.toList());
    }
    try {
        ListTypeExcelExporter exporter = new ListTypeExcelExporter(version, mdBusiness, mdAttributes, null, criteria);
        return exporter.export();
    } catch (IOException e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : JsonObject(com.google.gson.JsonObject) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) SimpleDateFormat(java.text.SimpleDateFormat) Authenticate(com.runwaysdk.business.rbac.Authenticate) JsonParser(com.google.gson.JsonParser) ClassificationType(net.geoprism.registry.model.ClassificationType) ServiceFactory(net.geoprism.registry.service.ServiceFactory) TemporalAccessor(java.time.temporal.TemporalAccessor) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF) MasterListExcelExporter(net.geoprism.registry.excel.MasterListExcelExporter) ListTypeShapefileExporter(net.geoprism.registry.shapefile.ListTypeShapefileExporter) ParseException(java.text.ParseException) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) TimeZone(java.util.TimeZone) IOException(java.io.IOException) ListTypeExcelExporter(net.geoprism.registry.excel.ListTypeExcelExporter) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) List(java.util.List) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) DateTimeFormatter(java.time.format.DateTimeFormatter) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) MasterListShapefileExporter(net.geoprism.registry.shapefile.MasterListShapefileExporter) XMLImporter(net.geoprism.registry.xml.XMLImporter) RegistryAdapter(org.commongeoregistry.adapter.RegistryAdapter) InputStream(java.io.InputStream) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) JsonObject(com.google.gson.JsonObject) ListTypeExcelExporter(net.geoprism.registry.excel.ListTypeExcelExporter) IOException(java.io.IOException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with ListTypeExcelExporter

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

the class ListTypeShapefileExporter 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());
    try {
        File file = new File(directory, "metadata.xlsx");
        FileOutputStream fos = new FileOutputStream(file);
        ListTypeExcelExporter exporter = new ListTypeExcelExporter(this.version, mdBusiness, mdAttributes, new ListTypeExcelExporterSheet[] { ListTypeExcelExporterSheet.DICTIONARY, ListTypeExcelExporterSheet.METADATA }, criteria);
        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) JsonObject(com.google.gson.JsonObject) 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) MdAttributeFloatDAOIF(com.runwaysdk.dataaccess.MdAttributeFloatDAOIF) 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) BusinessQuery(com.runwaysdk.business.BusinessQuery) UnsupportedOperationException(com.amazonaws.services.kms.model.UnsupportedOperationException) ListTypeExcelExporter(net.geoprism.registry.excel.ListTypeExcelExporter) 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) ListTypeExcelExporterSheet(net.geoprism.registry.excel.ListTypeExcelExporter.ListTypeExcelExporterSheet) 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) 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) ListType(net.geoprism.registry.ListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) OIterator(com.runwaysdk.query.OIterator) MdAttributeIntegerDAOIF(com.runwaysdk.dataaccess.MdAttributeIntegerDAOIF) 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) InputStream(java.io.InputStream) Polygon(com.vividsolutions.jts.geom.Polygon) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) FileOutputStream(java.io.FileOutputStream) ListTypeExcelExporter(net.geoprism.registry.excel.ListTypeExcelExporter) IOException(java.io.IOException) File(java.io.File) Workbook(org.apache.poi.ss.usermodel.Workbook) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Aggregations

JsonObject (com.google.gson.JsonObject)2 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)2 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 UnsupportedOperationException (com.amazonaws.services.kms.model.UnsupportedOperationException)1 JsonParser (com.google.gson.JsonParser)1 Business (com.runwaysdk.business.Business)1 BusinessQuery (com.runwaysdk.business.BusinessQuery)1 Authenticate (com.runwaysdk.business.rbac.Authenticate)1 VaultProperties (com.runwaysdk.constants.VaultProperties)1 MdAttributeBooleanDAOIF (com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF)1 MdAttributeCharacterDAOIF (com.runwaysdk.dataaccess.MdAttributeCharacterDAOIF)1 MdAttributeDateDAOIF (com.runwaysdk.dataaccess.MdAttributeDateDAOIF)1 MdAttributeDateTimeDAOIF (com.runwaysdk.dataaccess.MdAttributeDateTimeDAOIF)1 MdAttributeDoubleDAOIF (com.runwaysdk.dataaccess.MdAttributeDoubleDAOIF)1 MdAttributeFloatDAOIF (com.runwaysdk.dataaccess.MdAttributeFloatDAOIF)1 MdAttributeIntegerDAOIF (com.runwaysdk.dataaccess.MdAttributeIntegerDAOIF)1