Search in sources :

Example 1 with MdAttributeConcreteDAOIF

use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.

the class BusinessType method deleteMdAttributeFromAttributeType.

/**
 * Delete the {@link MdAttributeConcreteDAOIF} from the given {
 *
 * @param type
 *          TODO
 * @param mdBusiness
 * @param attributeName
 */
@Transaction
public void deleteMdAttributeFromAttributeType(String attributeName) {
    MdAttributeConcreteDAOIF mdAttributeConcreteDAOIF = ServerGeoObjectType.getMdAttribute(this.getMdVertex(), attributeName);
    if (mdAttributeConcreteDAOIF != null) {
        if (mdAttributeConcreteDAOIF instanceof MdAttributeTermDAOIF || mdAttributeConcreteDAOIF instanceof MdAttributeMultiTermDAOIF) {
            String attributeTermKey = TermConverter.buildtAtttributeKey(this.getMdVertex().getTypeName(), mdAttributeConcreteDAOIF.definesAttribute());
            try {
                Classifier attributeTerm = Classifier.getByKey(attributeTermKey);
                attributeTerm.delete();
            } catch (DataNotFoundException e) {
            }
        }
        mdAttributeConcreteDAOIF.getBusinessDAO().delete();
    }
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdAttributeTermDAOIF(com.runwaysdk.dataaccess.MdAttributeTermDAOIF) Classifier(net.geoprism.ontology.Classifier) MdAttributeMultiTermDAOIF(com.runwaysdk.dataaccess.MdAttributeMultiTermDAOIF) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with MdAttributeConcreteDAOIF

use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF 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 3 with MdAttributeConcreteDAOIF

use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF 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 4 with MdAttributeConcreteDAOIF

use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.

the class ListTypeVersion method record.

public JsonObject record(String uid) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    NumberFormat numberFormat = NumberFormat.getInstance(Session.getCurrentLocale());
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
    List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributes();
    BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
    query.WHERE(query.get(DefaultAttribute.UID.getName()).EQ(uid));
    JsonObject record = new JsonObject();
    record.addProperty("recordType", "LIST");
    record.addProperty("version", this.getOid());
    record.add("typeLabel", LocalizedValueConverter.convert(this.getListType().getDisplayLabel()).toJSON());
    record.add("attributes", this.getAttributesAsJson());
    try (OIterator<Business> iterator = query.getIterator()) {
        if (iterator.hasNext()) {
            Business row = iterator.next();
            JsonObject object = new JsonObject();
            object.addProperty(ORIGINAL_OID, row.getValue(ORIGINAL_OID));
            for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
                if (this.isValid(mdAttribute)) {
                    String attributeName = mdAttribute.definesAttribute();
                    Object value = row.getObjectValue(attributeName);
                    if (value != null) {
                        if (value instanceof Double) {
                            object.addProperty(mdAttribute.definesAttribute(), numberFormat.format((Double) value));
                        } else if (value instanceof Number) {
                            object.addProperty(mdAttribute.definesAttribute(), (Number) value);
                        } else if (value instanceof Boolean) {
                            object.addProperty(mdAttribute.definesAttribute(), (Boolean) value);
                        } else if (value instanceof String) {
                            object.addProperty(mdAttribute.definesAttribute(), (String) value);
                        } else if (value instanceof Character) {
                            object.addProperty(mdAttribute.definesAttribute(), (Character) value);
                        } else if (value instanceof Date) {
                            object.addProperty(mdAttribute.definesAttribute(), format.format((Date) value));
                        }
                    }
                }
            }
            record.add("data", object);
        }
    }
    JsonArray bbox = this.bbox(uid);
    if (bbox == null || bbox.size() == 0) {
        bbox = this.bbox(null);
    }
    record.add("bbox", bbox);
    return record;
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdAttributeCharacter(com.runwaysdk.system.metadata.MdAttributeCharacter) JsonObject(com.google.gson.JsonObject) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) MdAttributeDouble(com.runwaysdk.system.metadata.MdAttributeDouble) Date(java.util.Date) JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) ValueObject(com.runwaysdk.dataaccess.ValueObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) AttributeBoolean(com.runwaysdk.query.AttributeBoolean) SimpleDateFormat(java.text.SimpleDateFormat) NumberFormat(java.text.NumberFormat) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 5 with MdAttributeConcreteDAOIF

use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.

the class ListTypeVersion method removeAttribute.

private void removeAttribute(MdBusinessDAOIF mdBusiness, String name) {
    MdAttributeConcreteDAOIF mdAttribute = mdBusiness.definesAttribute(name);
    if (mdAttribute != null) {
        ListTypeAttributeGroup.remove(mdAttribute);
        mdAttribute.getBusinessDAO().delete();
    }
}
Also used : MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Aggregations

MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)36 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)18 JsonObject (com.google.gson.JsonObject)16 Date (java.util.Date)12 BusinessQuery (com.runwaysdk.business.BusinessQuery)11 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)11 Point (com.vividsolutions.jts.geom.Point)11 SimpleDateFormat (java.text.SimpleDateFormat)11 JsonArray (com.google.gson.JsonArray)10 MdAttributePointDAOIF (com.runwaysdk.gis.dataaccess.MdAttributePointDAOIF)10 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)9 MdAttributeLineString (com.runwaysdk.system.gis.metadata.MdAttributeLineString)9 MdAttributeMultiLineString (com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString)9 IOException (java.io.IOException)9 ParseException (java.text.ParseException)9 Locale (java.util.Locale)9 Business (com.runwaysdk.business.Business)8 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)8 InputStream (java.io.InputStream)8 List (java.util.List)8