Search in sources :

Example 1 with AttributeLocalType

use of org.commongeoregistry.adapter.metadata.AttributeLocalType in project geoprism-registry by terraframe.

the class ListTypeVersion method createMdAttributeFromAttributeType.

protected static void createMdAttributeFromAttributeType(TableMetadata metadata, AttributeType attributeType, ServerGeoObjectType type, Collection<Locale> locales) {
    MdBusiness mdBusiness = metadata.getMdBusiness();
    if (!(attributeType instanceof AttributeTermType || attributeType instanceof AttributeClassificationType || attributeType instanceof AttributeLocalType)) {
        MdAttributeConcrete mdAttribute = null;
        if (attributeType.getType().equals(AttributeCharacterType.TYPE)) {
            mdAttribute = new MdAttributeCharacter();
            MdAttributeCharacter mdAttributeCharacter = (MdAttributeCharacter) mdAttribute;
            mdAttributeCharacter.setDatabaseSize(MdAttributeCharacterInfo.MAX_CHARACTER_SIZE);
        } else if (attributeType.getType().equals(AttributeDateType.TYPE)) {
            mdAttribute = new MdAttributeDateTime();
        } else if (attributeType.getType().equals(AttributeIntegerType.TYPE)) {
            mdAttribute = new MdAttributeLong();
        } else if (attributeType.getType().equals(AttributeFloatType.TYPE)) {
            AttributeFloatType attributeFloatType = (AttributeFloatType) attributeType;
            mdAttribute = new MdAttributeDouble();
            mdAttribute.setValue(MdAttributeDoubleInfo.LENGTH, Integer.toString(attributeFloatType.getPrecision()));
            mdAttribute.setValue(MdAttributeDoubleInfo.DECIMAL, Integer.toString(attributeFloatType.getScale()));
        } else if (attributeType.getType().equals(AttributeBooleanType.TYPE)) {
            mdAttribute = new MdAttributeBoolean();
        } else {
            throw new UnsupportedOperationException("Unsupported type [" + attributeType.getType() + "]");
        }
        mdAttribute.setAttributeName(attributeType.getName());
        LocalizedValueConverter.populate(mdAttribute.getDisplayLabel(), attributeType.getLabel());
        LocalizedValueConverter.populate(mdAttribute.getDescription(), attributeType.getDescription());
        mdAttribute.setDefiningMdClass(mdBusiness);
        mdAttribute.apply();
    } else if (attributeType instanceof AttributeTermType || attributeType instanceof AttributeClassificationType) {
        MdAttributeCharacter cloneAttribute = new MdAttributeCharacter();
        cloneAttribute.setValue(MdAttributeConcreteInfo.NAME, attributeType.getName());
        cloneAttribute.setValue(MdAttributeCharacterInfo.SIZE, "255");
        cloneAttribute.addIndexType(MdAttributeIndices.NON_UNIQUE_INDEX);
        LocalizedValueConverter.populate(cloneAttribute.getDisplayLabel(), attributeType.getLabel());
        LocalizedValueConverter.populate(cloneAttribute.getDescription(), attributeType.getDescription());
        cloneAttribute.setDefiningMdClass(mdBusiness);
        cloneAttribute.apply();
        metadata.addPair(cloneAttribute, cloneAttribute);
        MdAttributeCharacter mdAttributeDefaultLocale = new MdAttributeCharacter();
        mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.NAME, attributeType.getName() + DEFAULT_LOCALE);
        mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
        mdAttributeDefaultLocale.setDefiningMdClass(mdBusiness);
        LocalizedValueConverter.populate(mdAttributeDefaultLocale.getDisplayLabel(), attributeType.getLabel(), " (defaultLocale)");
        LocalizedValueConverter.populate(mdAttributeDefaultLocale.getDescription(), attributeType.getDescription(), " (defaultLocale)");
        mdAttributeDefaultLocale.apply();
        metadata.addPair(mdAttributeDefaultLocale, cloneAttribute);
        for (Locale locale : locales) {
            MdAttributeCharacter mdAttributeLocale = new MdAttributeCharacter();
            mdAttributeLocale.setValue(MdAttributeCharacterInfo.NAME, attributeType.getName() + locale.toString());
            mdAttributeLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
            mdAttributeLocale.setDefiningMdClass(mdBusiness);
            LocalizedValueConverter.populate(mdAttributeLocale.getDisplayLabel(), attributeType.getLabel(), " (" + locale.toString() + ")");
            LocalizedValueConverter.populate(mdAttributeLocale.getDescription(), attributeType.getDescription());
            mdAttributeLocale.apply();
            metadata.addPair(mdAttributeLocale, cloneAttribute);
        }
    // MdAttributeUUID mdAttributeOid = new MdAttributeUUID();
    // mdAttributeOid.setValue(MdAttributeConcreteInfo.NAME,
    // attributeType.getName() + "Oid");
    // AbstractBuilder.populate(mdAttributeOid.getDisplayLabel(),
    // attributeType.getLabel());
    // AbstractBuilder.populate(mdAttributeOid.getDescription(),
    // attributeType.getDescription());
    // mdAttributeOid.setDefiningMdClass(mdBusiness);
    // mdAttributeOid.apply();
    } else if (attributeType instanceof AttributeLocalType) {
        boolean isDisplayLabel = attributeType.getName().equals(DefaultAttribute.DISPLAY_LABEL.getName());
        MdAttributeCharacter mdAttributeDefaultLocale = new MdAttributeCharacter();
        mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.NAME, attributeType.getName() + DEFAULT_LOCALE);
        mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
        mdAttributeDefaultLocale.setDefiningMdClass(mdBusiness);
        LocalizedValueConverter.populate(mdAttributeDefaultLocale.getDisplayLabel(), isDisplayLabel ? type.getLabel() : attributeType.getLabel(), " (defaultLocale)");
        LocalizedValueConverter.populate(mdAttributeDefaultLocale.getDescription(), attributeType.getDescription(), " (defaultLocale)");
        mdAttributeDefaultLocale.apply();
        for (Locale locale : locales) {
            MdAttributeCharacter mdAttributeLocale = new MdAttributeCharacter();
            mdAttributeLocale.setValue(MdAttributeCharacterInfo.NAME, attributeType.getName() + locale.toString());
            mdAttributeLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
            mdAttributeLocale.setDefiningMdClass(mdBusiness);
            LocalizedValueConverter.populate(mdAttributeLocale.getDisplayLabel(), isDisplayLabel ? type.getLabel() : attributeType.getLabel(), " (" + locale.toString() + ")");
            LocalizedValueConverter.populate(mdAttributeLocale.getDescription(), attributeType.getDescription());
            mdAttributeLocale.apply();
        }
    }
}
Also used : Locale(java.util.Locale) MdAttributeCharacter(com.runwaysdk.system.metadata.MdAttributeCharacter) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdAttributeDateTime(com.runwaysdk.system.metadata.MdAttributeDateTime) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) MdAttributeDouble(com.runwaysdk.system.metadata.MdAttributeDouble) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) MdAttributeLong(com.runwaysdk.system.metadata.MdAttributeLong) UnsupportedOperationException(com.amazonaws.services.kms.model.UnsupportedOperationException)

Example 2 with AttributeLocalType

use of org.commongeoregistry.adapter.metadata.AttributeLocalType in project geoprism-registry by terraframe.

the class ListTypeVersion method publish.

private void publish(ListType listType, ServerGeoObjectType type, ServerGeoObjectIF go, Business business, Collection<AttributeType> attributes, Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap, Set<ServerHierarchyType> hierarchiesOfSubTypes, Collection<Locale> locales) {
    VertexServerGeoObject vertexGo = (VertexServerGeoObject) go;
    business.setValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME, go.getGeometry());
    for (AttributeType attribute : attributes) {
        String name = attribute.getName();
        business.setValue(ORIGINAL_OID, go.getRunwayId());
        if (this.isValid(attribute)) {
            Object value = go.getValue(name, this.getForDate());
            if (value != null) {
                if (value instanceof LocalizedValue && ((LocalizedValue) value).isNull()) {
                    continue;
                }
                if (attribute instanceof AttributeTermType) {
                    Classifier classifier = (Classifier) value;
                    Term term = ((AttributeTermType) attribute).getTermByCode(classifier.getClassifierId()).get();
                    LocalizedValue label = term.getLabel();
                    this.setValue(business, name, term.getCode());
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeClassificationType) {
                    String classificationTypeCode = ((AttributeClassificationType) attribute).getClassificationType();
                    ClassificationType classificationType = ClassificationType.getByCode(classificationTypeCode);
                    Classification classification = Classification.getByOid(classificationType, (String) value);
                    LocalizedValue label = classification.getDisplayLabel();
                    this.setValue(business, name, classification.getCode());
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeLocalType) {
                    LocalizedValue label = (LocalizedValue) value;
                    String defaultLocale = label.getValue(LocalizedValue.DEFAULT_LOCALE);
                    if (defaultLocale == null) {
                        defaultLocale = "";
                    }
                    this.setValue(business, name + DEFAULT_LOCALE, defaultLocale);
                    for (Locale locale : locales) {
                        String localeValue = label.getValue(locale);
                        if (localeValue == null) {
                            localeValue = "";
                        }
                        this.setValue(business, name + locale.toString(), localeValue);
                    }
                } else {
                    this.setValue(business, name, value);
                }
            }
        }
    }
    Set<Entry<ServerHierarchyType, List<ServerGeoObjectType>>> entries = ancestorMap.entrySet();
    for (Entry<ServerHierarchyType, List<ServerGeoObjectType>> entry : entries) {
        ServerHierarchyType hierarchy = entry.getKey();
        Map<String, LocationInfo> map = vertexGo.getAncestorMap(hierarchy, entry.getValue());
        Set<Entry<String, LocationInfo>> locations = map.entrySet();
        for (Entry<String, LocationInfo> location : locations) {
            String pCode = location.getKey();
            LocationInfo vObject = location.getValue();
            if (vObject != null) {
                String attributeName = hierarchy.getCode().toLowerCase() + pCode.toLowerCase();
                this.setValue(business, attributeName, vObject.getCode());
                this.setValue(business, attributeName + DEFAULT_LOCALE, vObject.getLabel());
                for (Locale locale : locales) {
                    this.setValue(business, attributeName + locale.toString(), vObject.getLabel(locale));
                }
            }
        }
    }
    for (ServerHierarchyType hierarchy : hierarchiesOfSubTypes) {
        ServerParentTreeNode node = go.getParentsForHierarchy(hierarchy, false, this.getForDate());
        List<ServerParentTreeNode> parents = node.getParents();
        if (parents.size() > 0) {
            ServerParentTreeNode parent = parents.get(0);
            String attributeName = hierarchy.getCode().toLowerCase();
            ServerGeoObjectIF geoObject = parent.getGeoObject();
            LocalizedValue label = geoObject.getDisplayLabel();
            this.setValue(business, attributeName, geoObject.getCode());
            this.setValue(business, attributeName + DEFAULT_LOCALE, label.getValue(DEFAULT_LOCALE));
            for (Locale locale : locales) {
                this.setValue(business, attributeName + locale.toString(), label.getValue(locale));
            }
        }
    }
    if (type.getGeometryType().equals(GeometryType.MULTIPOINT) || type.getGeometryType().equals(GeometryType.POINT) && listType.getIncludeLatLong()) {
        Geometry geom = vertexGo.getGeometry();
        if (geom instanceof MultiPoint) {
            MultiPoint mp = (MultiPoint) geom;
            Coordinate[] coords = mp.getCoordinates();
            Coordinate firstCoord = coords[0];
            this.setValue(business, "latitude", String.valueOf(firstCoord.y));
            this.setValue(business, "longitude", String.valueOf(firstCoord.x));
        } else if (geom instanceof Point) {
            Point point = (Point) geom;
            Coordinate firstCoord = point.getCoordinate();
            this.setValue(business, "latitude", String.valueOf(firstCoord.y));
            this.setValue(business, "longitude", String.valueOf(firstCoord.x));
        }
    }
    business.apply();
}
Also used : Locale(java.util.Locale) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) Classifier(net.geoprism.ontology.Classifier) Entry(java.util.Map.Entry) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Classification(net.geoprism.registry.model.Classification) List(java.util.List) LinkedList(java.util.LinkedList) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Term(org.commongeoregistry.adapter.Term) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Point(com.vividsolutions.jts.geom.Point) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) ClassificationType(net.geoprism.registry.model.ClassificationType) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) LocationInfo(net.geoprism.registry.model.LocationInfo) Geometry(com.vividsolutions.jts.geom.Geometry) MdAttributeGeometry(com.runwaysdk.system.gis.metadata.MdAttributeGeometry) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) Coordinate(com.vividsolutions.jts.geom.Coordinate) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) JsonObject(com.google.gson.JsonObject) ValueObject(com.runwaysdk.dataaccess.ValueObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 3 with AttributeLocalType

use of org.commongeoregistry.adapter.metadata.AttributeLocalType in project geoprism-registry by terraframe.

the class MasterListVersion method publish.

private void publish(ServerGeoObjectIF go, Business business, Collection<AttributeType> attributes, Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap, Set<ServerHierarchyType> hierarchiesOfSubTypes, Collection<Locale> locales) {
    VertexServerGeoObject vertexGo = (VertexServerGeoObject) go;
    boolean hasData = false;
    business.setValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME, go.getGeometry());
    for (AttributeType attribute : attributes) {
        String name = attribute.getName();
        business.setValue(ORIGINAL_OID, go.getRunwayId());
        if (this.isValid(attribute)) {
            Object value = go.getValue(name, this.getForDate());
            if (value != null) {
                if (value instanceof LocalizedValue && ((LocalizedValue) value).isNull()) {
                    continue;
                }
                if (!name.equals(DefaultAttribute.CODE.getName()) && !name.equals(DefaultAttribute.INVALID.getName()) && attribute.isChangeOverTime() && (!name.equals(DefaultAttribute.EXISTS.getName()) || (value instanceof Boolean && ((Boolean) value)))) {
                    hasData = true;
                }
                if (attribute instanceof AttributeTermType) {
                    Classifier classifier = (Classifier) value;
                    Term term = ((AttributeTermType) attribute).getTermByCode(classifier.getClassifierId()).get();
                    LocalizedValue label = term.getLabel();
                    this.setValue(business, name, term.getCode());
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeClassificationType) {
                    String classificationType = ((AttributeClassificationType) attribute).getClassificationType();
                    MdClassificationDAOIF mdClassificationDAO = MdClassificationDAO.getMdClassificationDAO(classificationType);
                    MdVertexDAOIF mdVertexDAO = mdClassificationDAO.getReferenceMdVertexDAO();
                    VertexObject classification = VertexObject.get(mdVertexDAO, (String) value);
                    LocalizedValue label = LocalizedValueConverter.convert(classification.getEmbeddedComponent(AbstractClassification.DISPLAYLABEL));
                    this.setValue(business, name, classification.getObjectValue(AbstractClassification.CODE));
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeLocalType) {
                    LocalizedValue label = (LocalizedValue) value;
                    String defaultLocale = label.getValue(LocalizedValue.DEFAULT_LOCALE);
                    if (defaultLocale == null) {
                        defaultLocale = "";
                    }
                    this.setValue(business, name + DEFAULT_LOCALE, defaultLocale);
                    for (Locale locale : locales) {
                        String localeValue = label.getValue(locale);
                        if (localeValue == null) {
                            localeValue = "";
                        }
                        this.setValue(business, name + locale.toString(), localeValue);
                    }
                } else {
                    this.setValue(business, name, value);
                }
            }
        }
    }
    if (hasData) {
        Set<Entry<ServerHierarchyType, List<ServerGeoObjectType>>> entries = ancestorMap.entrySet();
        for (Entry<ServerHierarchyType, List<ServerGeoObjectType>> entry : entries) {
            ServerHierarchyType hierarchy = entry.getKey();
            Map<String, LocationInfo> map = vertexGo.getAncestorMap(hierarchy, entry.getValue());
            Set<Entry<String, LocationInfo>> locations = map.entrySet();
            for (Entry<String, LocationInfo> location : locations) {
                String pCode = location.getKey();
                LocationInfo vObject = location.getValue();
                if (vObject != null) {
                    String attributeName = hierarchy.getCode().toLowerCase() + pCode.toLowerCase();
                    this.setValue(business, attributeName, vObject.getCode());
                    this.setValue(business, attributeName + DEFAULT_LOCALE, vObject.getLabel());
                    for (Locale locale : locales) {
                        this.setValue(business, attributeName + locale.toString(), vObject.getLabel(locale));
                    }
                }
            }
        }
        for (ServerHierarchyType hierarchy : hierarchiesOfSubTypes) {
            ServerParentTreeNode node = go.getParentsForHierarchy(hierarchy, false, this.getForDate());
            List<ServerParentTreeNode> parents = node.getParents();
            if (parents.size() > 0) {
                ServerParentTreeNode parent = parents.get(0);
                String attributeName = hierarchy.getCode().toLowerCase();
                ServerGeoObjectIF geoObject = parent.getGeoObject();
                LocalizedValue label = geoObject.getDisplayLabel();
                this.setValue(business, attributeName, geoObject.getCode());
                this.setValue(business, attributeName + DEFAULT_LOCALE, label.getValue(DEFAULT_LOCALE));
                for (Locale locale : locales) {
                    this.setValue(business, attributeName + locale.toString(), label.getValue(locale));
                }
            }
        }
        business.apply();
    }
}
Also used : Locale(java.util.Locale) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) Classifier(net.geoprism.ontology.Classifier) MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) Entry(java.util.Map.Entry) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) AttributeBoolean(com.runwaysdk.query.AttributeBoolean) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Term(org.commongeoregistry.adapter.Term) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) LocationInfo(net.geoprism.registry.model.LocationInfo) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) VertexObject(com.runwaysdk.business.graph.VertexObject) JsonObject(com.google.gson.JsonObject) ValueObject(com.runwaysdk.dataaccess.ValueObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 4 with AttributeLocalType

use of org.commongeoregistry.adapter.metadata.AttributeLocalType in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporter method features.

public FeatureCollection<SimpleFeatureType, SimpleFeature> features(SimpleFeatureType featureType) {
    final int BLOCK_SIZE = 2000;
    List<SimpleFeature> features = new ArrayList<SimpleFeature>();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
    VertexServerGeoObject prev = null;
    do {
        final VertexSelectGeoObjectQuery query = new VertexSelectGeoObjectQuery(type, this.date, prev);
        query.setLimit(BLOCK_SIZE);
        final List<VertexServerGeoObject> objects = query.getResults();
        prev = null;
        for (VertexServerGeoObject object : objects) {
            if (!object.getInvalid()) {
                builder.set(GEOM, object.getGeometry());
                this.attributes.forEach(attribute -> {
                    String name = attribute.getName();
                    String columnName = this.getColumnName(name);
                    Object value = attribute.isChangeOverTime() ? object.getValue(name, this.date) : object.getValue(name);
                    if (attribute instanceof AttributeTermType) {
                        builder.set(columnName, GeoObjectUtil.convertToTermString((AttributeTermType) attribute, value));
                    } else if (attribute instanceof AttributeClassificationType) {
                        builder.set(columnName, GeoObjectUtil.convertToTermString((AttributeClassificationType) attribute, value));
                    } else if (attribute instanceof AttributeLocalType) {
                        builder.set(columnName, ((LocalizedValue) value).getValue());
                    } else {
                        builder.set(columnName, value);
                    }
                });
                AttributeType attribute = this.getType().getAttribute(DefaultAttribute.DISPLAY_LABEL.getName()).get();
                LocalizedValue label = object.getDisplayLabel(this.date);
                builder.set(this.getColumnName(attribute.getName() + " " + MdAttributeLocalInfo.DEFAULT_LOCALE), label.getValue(LocalizedValue.DEFAULT_LOCALE));
                for (Locale locale : locales) {
                    builder.set(this.getColumnName(attribute.getName() + " " + locale.toString()), label.getValue(locale));
                }
                SimpleFeature feature = builder.buildFeature(object.getCode());
                features.add(feature);
            }
            prev = object;
            Thread.yield();
        }
    } while (prev != null);
    return new ListFeatureCollection(featureType, features);
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) SimpleFeature(org.opengis.feature.simple.SimpleFeature) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) ListFeatureCollection(org.geotools.data.collection.ListFeatureCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) VertexSelectGeoObjectQuery(net.geoprism.registry.query.graph.VertexSelectGeoObjectQuery) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Example 5 with AttributeLocalType

use of org.commongeoregistry.adapter.metadata.AttributeLocalType in project geoprism-registry by terraframe.

the class UpdateValueOverTimeView method persistValue.

private void persistValue(ValueOverTime vot, UpdateChangeOverTimeAttributeView cotView, VertexServerGeoObject go, List<ValueOverTime> looseVotc) {
    if (this.newValue == null) {
        return;
    }
    if (cotView.getAttributeName().equals("geometry")) {
        Geometry convertedValue = null;
        if (!this.newValue.isJsonNull()) {
            GeoJSONReader reader = new GeoJSONReader();
            convertedValue = reader.read(this.newValue.toString());
            if (!go.isValidGeometry(convertedValue)) {
                GeometryTypeException ex = new GeometryTypeException();
                ex.setActualType(convertedValue.getGeometryType());
                ex.setExpectedType(go.getType().getGeometryType().name());
                throw ex;
            }
        }
        if (vot != null) {
            vot.setValue(convertedValue);
        } else {
            looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, convertedValue));
        }
    } else {
        ServerGeoObjectType type = go.getType();
        AttributeType attype = type.getAttribute(cotView.getAttributeName()).get();
        if (attype instanceof AttributeLocalType) {
            LocalizedValue convertedValue = null;
            if (!this.newValue.isJsonNull()) {
                convertedValue = LocalizedValue.fromJSON(this.newValue.getAsJsonObject());
            }
            final Set<Locale> locales = LocalizationFacade.getInstalledLocales();
            if (vot != null) {
                if (convertedValue != null) {
                    GraphObjectDAO votEmbeddedValue = (GraphObjectDAO) vot.getValue();
                    votEmbeddedValue.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, convertedValue.getValue(MdAttributeLocalInfo.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        if (convertedValue.contains(locale)) {
                            votEmbeddedValue.setValue(locale.toString(), convertedValue.getValue(locale));
                        }
                    }
                } else {
                    vot.setValue(null);
                }
            } else {
                if (convertedValue != null) {
                    MdAttributeEmbeddedDAOIF mdAttrEmbedded = (MdAttributeEmbeddedDAOIF) go.getMdAttributeDAO(attype.getName());
                    VertexObjectDAO votEmbeddedValue = VertexObjectDAO.newInstance((MdVertexDAOIF) mdAttrEmbedded.getEmbeddedMdClassDAOIF());
                    votEmbeddedValue.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, convertedValue.getValue(MdAttributeLocalInfo.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        if (convertedValue.contains(locale)) {
                            votEmbeddedValue.setValue(locale.toString(), convertedValue.getValue(locale));
                        }
                    }
                    looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, votEmbeddedValue));
                } else {
                    looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, null));
                }
            }
        } else // else if (attype.getName().equals(DefaultAttribute.EXISTS.getName()))
        // {
        // if (this.newValue.isJsonNull())
        // {
        // if (vot != null)
        // {
        // vot.setValue(null);
        // }
        // else
        // {
        // looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate,
        // null));
        // }
        // }
        // else
        // {
        // JsonArray ja = this.newValue.getAsJsonArray();
        // 
        // if (ja.size() > 0)
        // {
        // String code = ja.get(0).getAsString();
        // 
        // if (code == null || code.length() == 0)
        // {
        // if (vot != null)
        // {
        // vot.setValue(null);
        // }
        // else
        // {
        // looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate,
        // null));
        // }
        // }
        // else
        // {
        // Term value = ( (AttributeTermType) attype ).getTermByCode(code).get();
        // GeoObjectStatus gos =
        // ConversionService.getInstance().termToGeoObjectStatus(value);
        // 
        // if (vot != null)
        // {
        // vot.setValue(gos.getOid());
        // }
        // else
        // {
        // looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate,
        // gos.getOid()));
        // }
        // }
        // }
        // }
        // }
        {
            Object convertedValue = null;
            if (!this.newValue.isJsonNull()) {
                if (attype instanceof AttributeDateType) {
                    long epoch = this.newValue.getAsLong();
                    convertedValue = new Date(epoch);
                } else if (attype instanceof AttributeTermType) {
                    JsonArray ja = this.newValue.getAsJsonArray();
                    if (ja.size() > 0) {
                        String code = ja.get(0).getAsString();
                        Term root = ((AttributeTermType) attype).getRootTerm();
                        String parent = TermConverter.buildClassifierKeyFromTermCode(root.getCode());
                        String classifierKey = Classifier.buildKey(parent, code);
                        Classifier classifier = Classifier.getByKey(classifierKey);
                        convertedValue = classifier.getOid();
                    }
                } else if (attype instanceof AttributeClassificationType) {
                    JsonObject object = this.newValue.getAsJsonObject();
                    String code = object.get("code").getAsString();
                    Classification classification = Classification.get((AttributeClassificationType) attype, code);
                    convertedValue = new AttributeGraphRef.ID(classification.getOid(), classification.getVertex().getRID());
                } else if (attype instanceof AttributeBooleanType) {
                    convertedValue = this.newValue.getAsBoolean();
                } else if (attype instanceof AttributeFloatType) {
                    convertedValue = this.newValue.getAsDouble();
                } else if (attype instanceof AttributeIntegerType) {
                    convertedValue = this.newValue.getAsLong();
                } else {
                    convertedValue = this.newValue.getAsString();
                }
            }
            if (vot != null) {
                vot.setValue(convertedValue);
            } else {
                looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, convertedValue));
            }
        }
    }
}
Also used : Locale(java.util.Locale) AttributeIntegerType(org.commongeoregistry.adapter.metadata.AttributeIntegerType) JsonObject(com.google.gson.JsonObject) Classifier(net.geoprism.ontology.Classifier) AttributeDateType(org.commongeoregistry.adapter.metadata.AttributeDateType) AttributeFloatType(org.commongeoregistry.adapter.metadata.AttributeFloatType) AttributeGraphRef(com.runwaysdk.dataaccess.graph.attributes.AttributeGraphRef) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Classification(net.geoprism.registry.model.Classification) AttributeBooleanType(org.commongeoregistry.adapter.metadata.AttributeBooleanType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeEmbeddedDAOIF(com.runwaysdk.dataaccess.MdAttributeEmbeddedDAOIF) GeometryTypeException(net.geoprism.registry.GeometryTypeException) Term(org.commongeoregistry.adapter.Term) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) Date(java.util.Date) Geometry(com.vividsolutions.jts.geom.Geometry) JsonArray(com.google.gson.JsonArray) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) GeoJSONReader(org.wololo.jts2geojson.GeoJSONReader) GraphObjectDAO(com.runwaysdk.dataaccess.graph.GraphObjectDAO) VertexObjectDAO(com.runwaysdk.dataaccess.graph.VertexObjectDAO) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Aggregations

AttributeLocalType (org.commongeoregistry.adapter.metadata.AttributeLocalType)12 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)12 Locale (java.util.Locale)9 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)9 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)8 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)7 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)7 JsonObject (com.google.gson.JsonObject)5 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)4 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)4 Term (org.commongeoregistry.adapter.Term)4 AttributeFloatType (org.commongeoregistry.adapter.metadata.AttributeFloatType)4 MdAttributeBoolean (com.runwaysdk.system.metadata.MdAttributeBoolean)3 Point (com.vividsolutions.jts.geom.Point)3 Classifier (net.geoprism.ontology.Classifier)3 LocationInfo (net.geoprism.registry.model.LocationInfo)3 JsonArray (com.google.gson.JsonArray)2 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)2 ValueObject (com.runwaysdk.dataaccess.ValueObject)2 Request (com.runwaysdk.session.Request)2