Search in sources :

Example 1 with Classification

use of net.geoprism.registry.model.Classification 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 2 with Classification

use of net.geoprism.registry.model.Classification in project geoprism-registry by terraframe.

the class VertexServerGeoObject method populate.

@SuppressWarnings("unchecked")
@Override
public void populate(GeoObjectOverTime goTime) {
    Map<String, AttributeType> attributes = goTime.getType().getAttributeMap();
    attributes.forEach((attributeName, attribute) -> {
        if (attributeName.equals(DefaultAttribute.INVALID.getName()) || attributeName.equals(DefaultAttribute.CODE.getName()) || attributeName.equals(DefaultAttribute.UID.getName()) || attributeName.equals(GeoVertex.LASTUPDATEDATE) || attributeName.equals(GeoVertex.CREATEDATE)) {
        // Ignore the attributes
        } else // }
        if (attributeName.equals(DefaultAttribute.DISPLAY_LABEL.getName())) {
            this.getValuesOverTime(attributeName).clear();
            for (ValueOverTimeDTO votDTO : goTime.getAllValues(attributeName)) {
                LocalizedValue label = (LocalizedValue) votDTO.getValue();
                this.setDisplayLabel(label, votDTO.getStartDate(), votDTO.getEndDate());
            }
        } else if (this.vertex.hasAttribute(attributeName) && !this.vertex.getMdAttributeDAO(attributeName).isSystem()) {
            this.getValuesOverTime(attributeName).clear();
            ValueOverTimeCollectionDTO collection = goTime.getAllValues(attributeName);
            for (ValueOverTimeDTO votDTO : collection) {
                if (attribute instanceof AttributeTermType) {
                    Iterator<String> it = (Iterator<String>) votDTO.getValue();
                    if (it.hasNext()) {
                        String code = it.next();
                        Term root = ((AttributeTermType) attribute).getRootTerm();
                        String parent = TermConverter.buildClassifierKeyFromTermCode(root.getCode());
                        String classifierKey = Classifier.buildKey(parent, code);
                        Classifier classifier = Classifier.getByKey(classifierKey);
                        this.vertex.setValue(attributeName, classifier.getOid(), votDTO.getStartDate(), votDTO.getEndDate());
                    } else {
                        this.vertex.setValue(attributeName, (String) null, votDTO.getStartDate(), votDTO.getEndDate());
                    }
                } else if (attribute instanceof AttributeClassificationType) {
                    String value = (String) votDTO.getValue();
                    if (value != null) {
                        Classification classification = Classification.get((AttributeClassificationType) attribute, value);
                        this.vertex.setValue(attributeName, classification.getVertex(), votDTO.getStartDate(), votDTO.getEndDate());
                    } else {
                        this.vertex.setValue(attributeName, (String) null, this.date, this.date);
                    }
                } else {
                    Object value = votDTO.getValue();
                    if (value != null) {
                        this.vertex.setValue(attributeName, value, votDTO.getStartDate(), votDTO.getEndDate());
                    } else {
                        this.vertex.setValue(attributeName, (String) null, votDTO.getStartDate(), votDTO.getEndDate());
                    }
                }
            }
        }
    });
    this.getValuesOverTime(this.getGeometryAttributeName()).clear();
    for (ValueOverTimeDTO votDTO : goTime.getAllValues(DefaultAttribute.GEOMETRY.getName())) {
        Geometry geom = goTime.getGeometry(votDTO.getStartDate());
        this.setGeometry(geom, votDTO.getStartDate(), votDTO.getEndDate());
    }
    this.setUid(goTime.getUid());
    this.setCode(goTime.getCode());
    this.setInvalid(goTime.getInvalid());
}
Also used : ValueOverTimeCollectionDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO) ValueOverTimeDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeDTO) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) Term(org.commongeoregistry.adapter.Term) Classifier(net.geoprism.ontology.Classifier) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) Geometry(com.vividsolutions.jts.geom.Geometry) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Classification(net.geoprism.registry.model.Classification) AbstractClassification(com.runwaysdk.system.AbstractClassification) Iterator(java.util.Iterator) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) AbstractServerGeoObject(net.geoprism.registry.model.AbstractServerGeoObject) GraphObject(com.runwaysdk.business.graph.GraphObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 3 with Classification

use of net.geoprism.registry.model.Classification in project geoprism-registry by terraframe.

the class ClassificationService method apply.

@Request(RequestType.SESSION)
public JsonObject apply(String sessionId, String classificationCode, String parentCode, JsonObject object, boolean isNew) {
    ClassificationType type = ClassificationType.getByCode(classificationCode);
    Classification parent = parentCode != null ? Classification.get(type, parentCode) : null;
    Classification classification = Classification.construct(type, object, isNew);
    classification.populate(object);
    classification.apply(parent);
    // Return the refreshed copy of the geoObject
    return classification.toJSON();
}
Also used : Classification(net.geoprism.registry.model.Classification) ClassificationType(net.geoprism.registry.model.ClassificationType) Request(com.runwaysdk.session.Request)

Example 4 with Classification

use of net.geoprism.registry.model.Classification in project geoprism-registry by terraframe.

the class ClassificationService method move.

@Request(RequestType.SESSION)
public void move(String sessionId, String classificationCode, String code, String parentCode) {
    ClassificationType type = ClassificationType.getByCode(classificationCode);
    Classification classification = Classification.get(type, code);
    Classification newParent = Classification.get(type, parentCode);
    classification.move(newParent);
}
Also used : Classification(net.geoprism.registry.model.Classification) ClassificationType(net.geoprism.registry.model.ClassificationType) Request(com.runwaysdk.session.Request)

Example 5 with Classification

use of net.geoprism.registry.model.Classification in project geoprism-registry by terraframe.

the class ClassificationService method getAncestorTree.

@Request(RequestType.SESSION)
public JsonObject getAncestorTree(String sessionId, String classificationCode, String rootCode, String code, Integer pageSize) {
    ClassificationType type = ClassificationType.getByCode(classificationCode);
    Classification child = Classification.get(type, code);
    return child.getAncestorTree(rootCode, pageSize).toJSON();
}
Also used : Classification(net.geoprism.registry.model.Classification) ClassificationType(net.geoprism.registry.model.ClassificationType) Request(com.runwaysdk.session.Request)

Aggregations

Classification (net.geoprism.registry.model.Classification)27 Request (com.runwaysdk.session.Request)19 ClassificationType (net.geoprism.registry.model.ClassificationType)14 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)9 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)8 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)8 Classifier (net.geoprism.ontology.Classifier)7 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)7 Term (org.commongeoregistry.adapter.Term)6 AbstractClassification (com.runwaysdk.system.AbstractClassification)5 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)5 JsonObject (com.google.gson.JsonObject)4 EdgeObject (com.runwaysdk.business.graph.EdgeObject)4 GraphObject (com.runwaysdk.business.graph.GraphObject)4 VertexObject (com.runwaysdk.business.graph.VertexObject)4 LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 Test (org.junit.Test)4 JsonArray (com.google.gson.JsonArray)3 MdClassificationDAOIF (com.runwaysdk.dataaccess.MdClassificationDAOIF)3