Search in sources :

Example 1 with MasterListShapefileExporter

use of net.geoprism.registry.shapefile.MasterListShapefileExporter in project geoprism-registry by terraframe.

the class GeoRegistryUtil method exportMasterListShapefile.

@Transaction
public static InputStream exportMasterListShapefile(String oid, String filterJson) {
    MasterListVersion version = MasterListVersion.get(oid);
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(version.getMdBusinessOid());
    List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> version.isValid(mdAttribute)).collect(Collectors.toList());
    if (filterJson.contains("invalid")) {
        mdAttributes = mdAttributes.stream().filter(mdAttribute -> !mdAttribute.definesAttribute().equals("invalid")).collect(Collectors.toList());
    }
    try {
        MasterListShapefileExporter exporter = new MasterListShapefileExporter(version, mdBusiness, mdAttributes, filterJson);
        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) MasterListShapefileExporter(net.geoprism.registry.shapefile.MasterListShapefileExporter) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) IOException(java.io.IOException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with MasterListShapefileExporter

use of net.geoprism.registry.shapefile.MasterListShapefileExporter in project geoprism-registry by terraframe.

the class MasterListVersion method generateShapefile.

public File generateShapefile() {
    String filename = this.getOid() + ".zip";
    final MasterList list = this.getMasterlist();
    final File directory = list.getShapefileDirectory();
    directory.mkdirs();
    final File file = new File(directory, filename);
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
    List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> this.isValid(mdAttribute)).collect(Collectors.toList());
    try {
        MasterListShapefileExporter exporter = new MasterListShapefileExporter(this, mdBusiness, mdAttributes, null);
        try (final InputStream istream = exporter.export()) {
            try (final FileOutputStream fos = new FileOutputStream(file)) {
                IOUtils.copy(istream, fos);
            }
        }
    } catch (IOException e) {
        throw new ProgrammingErrorException(e);
    }
    return file;
}
Also used : MdAttributeBooleanDAOIF(com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF) Authenticate(com.runwaysdk.business.rbac.Authenticate) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) MdAttributeMomentDAOIF(com.runwaysdk.dataaccess.MdAttributeMomentDAOIF) JSONException(org.json.JSONException) Condition(com.runwaysdk.query.Condition) IndexTypes(com.runwaysdk.constants.IndexTypes) GeoJSONWriter(org.wololo.jts2geojson.GeoJSONWriter) TableMetadata(net.geoprism.registry.masterlist.TableMetadata) Map(java.util.Map) AttributeBooleanType(org.commongeoregistry.adapter.metadata.AttributeBooleanType) AttributeBoolean(com.runwaysdk.query.AttributeBoolean) ComponentIF(com.runwaysdk.ComponentIF) ListTypeAttributeComparator(net.geoprism.registry.masterlist.ListTypeAttributeComparator) Set(java.util.Set) BusinessFacade(com.runwaysdk.business.BusinessFacade) IOUtils(org.apache.commons.io.IOUtils) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) JsonArray(com.google.gson.JsonArray) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) GeoserverRemoveWMSCommand(net.geoprism.registry.command.GeoserverRemoveWMSCommand) MdAttributeLong(com.runwaysdk.system.metadata.MdAttributeLong) VertexObject(com.runwaysdk.business.graph.VertexObject) SimpleDateFormat(java.text.SimpleDateFormat) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) JsonParser(com.google.gson.JsonParser) DefaultConfiguration(net.geoprism.DefaultConfiguration) NumberFormat(java.text.NumberFormat) MdAttributeDouble(com.runwaysdk.system.metadata.MdAttributeDouble) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) Calendar(java.util.Calendar) QueryFactory(com.runwaysdk.query.QueryFactory) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) ComponentQuery(com.runwaysdk.query.ComponentQuery) MdAttribute(com.runwaysdk.system.metadata.MdAttribute) MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) AttributeDateType(org.commongeoregistry.adapter.metadata.AttributeDateType) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) Business(com.runwaysdk.business.Business) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MasterListShapefileExporter(net.geoprism.registry.shapefile.MasterListShapefileExporter) BusinessInfo(com.runwaysdk.constants.BusinessInfo) MdAttributePolygon(com.runwaysdk.system.gis.metadata.MdAttributePolygon) JsonObject(com.google.gson.JsonObject) Operation(com.runwaysdk.business.rbac.Operation) Date(java.util.Date) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) ValueObject(com.runwaysdk.dataaccess.ValueObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeBooleanInfo(com.runwaysdk.constants.MdAttributeBooleanInfo) PublishMasterListVersionJobQuery(net.geoprism.registry.etl.PublishMasterListVersionJobQuery) MdTableInfo(com.runwaysdk.constants.MdTableInfo) ValueQuery(com.runwaysdk.query.ValueQuery) MdAttributeShape(com.runwaysdk.system.gis.metadata.MdAttributeShape) Locale(java.util.Locale) Geometry(com.vividsolutions.jts.geom.Geometry) ParseException(java.text.ParseException) AttributeCharacterType(org.commongeoregistry.adapter.metadata.AttributeCharacterType) Database(com.runwaysdk.dataaccess.database.Database) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) DateFormat(java.text.DateFormat) GeoserverFacade(net.geoprism.gis.geoserver.GeoserverFacade) BusinessQuery(com.runwaysdk.business.BusinessQuery) MdAttributeCharacterDAO(com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO) LocationInfo(net.geoprism.registry.model.LocationInfo) Collection(java.util.Collection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) MdAttributeConcreteInfo(com.runwaysdk.constants.MdAttributeConcreteInfo) Collectors(java.util.stream.Collectors) ProgressService(net.geoprism.registry.progress.ProgressService) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) MdAttributeDoubleInfo(com.runwaysdk.constants.MdAttributeDoubleInfo) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) MdAttributeMultiPolygon(com.runwaysdk.system.gis.metadata.MdAttributeMultiPolygon) MdAttributeCharacter(com.runwaysdk.system.metadata.MdAttributeCharacter) Entry(java.util.Map.Entry) MdClassificationDAO(com.runwaysdk.dataaccess.metadata.graph.MdClassificationDAO) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) GeometryType(org.commongeoregistry.adapter.constants.GeometryType) MdAttributeIndices(com.runwaysdk.system.metadata.MdAttributeIndices) AbstractClassification(com.runwaysdk.system.AbstractClassification) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) PublishMasterListVersionJob(net.geoprism.registry.etl.PublishMasterListVersionJob) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) HashMap(java.util.HashMap) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) MdAttributeLocalInfo(com.runwaysdk.constants.MdAttributeLocalInfo) Progress(net.geoprism.registry.progress.Progress) ServiceFactory(net.geoprism.registry.service.ServiceFactory) Classifier(net.geoprism.ontology.Classifier) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF) PublishShapefileJob(net.geoprism.registry.etl.PublishShapefileJob) DefaultAttribute(org.commongeoregistry.adapter.constants.DefaultAttribute) LocalizationFacade(com.runwaysdk.localization.LocalizationFacade) BasicCondition(com.runwaysdk.query.BasicCondition) MdAttributeCharacterInfo(com.runwaysdk.constants.MdAttributeCharacterInfo) GeoserverCreateWMSCommand(net.geoprism.registry.command.GeoserverCreateWMSCommand) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) MdAttributeUUIDDAO(com.runwaysdk.dataaccess.metadata.MdAttributeUUIDDAO) LinkedList(java.util.LinkedList) MdAttributeGeometry(com.runwaysdk.system.gis.metadata.MdAttributeGeometry) MdAttributeDateTime(com.runwaysdk.system.metadata.MdAttributeDateTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdAttributeConcreteDAO(com.runwaysdk.dataaccess.metadata.MdAttributeConcreteDAO) Term(org.commongeoregistry.adapter.Term) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) FileInputStream(java.io.FileInputStream) AttributeIntegerType(org.commongeoregistry.adapter.metadata.AttributeIntegerType) OIterator(com.runwaysdk.query.OIterator) PublishShapefileJobQuery(net.geoprism.registry.etl.PublishShapefileJobQuery) Session(com.runwaysdk.session.Session) MdAttributePointDAOIF(com.runwaysdk.gis.dataaccess.MdAttributePointDAOIF) Collections(java.util.Collections) JSONArray(org.json.JSONArray) InputStream(java.io.InputStream) MasterListShapefileExporter(net.geoprism.registry.shapefile.MasterListShapefileExporter) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) IOException(java.io.IOException) File(java.io.File) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Aggregations

JsonObject (com.google.gson.JsonObject)2 JsonParser (com.google.gson.JsonParser)2 Authenticate (com.runwaysdk.business.rbac.Authenticate)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 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 JsonArray (com.google.gson.JsonArray)1 ComponentIF (com.runwaysdk.ComponentIF)1 Business (com.runwaysdk.business.Business)1 BusinessFacade (com.runwaysdk.business.BusinessFacade)1 BusinessQuery (com.runwaysdk.business.BusinessQuery)1 VertexObject (com.runwaysdk.business.graph.VertexObject)1 Operation (com.runwaysdk.business.rbac.Operation)1 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)1 BusinessInfo (com.runwaysdk.constants.BusinessInfo)1 IndexTypes (com.runwaysdk.constants.IndexTypes)1 MdAttributeBooleanInfo (com.runwaysdk.constants.MdAttributeBooleanInfo)1 MdAttributeCharacterInfo (com.runwaysdk.constants.MdAttributeCharacterInfo)1