Search in sources :

Example 1 with ServerParentTreeNode

use of net.geoprism.registry.model.ServerParentTreeNode 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 ServerParentTreeNode

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

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

the class VertexServerGeoObject method addParent.

@Override
public ServerParentTreeNode addParent(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType) {
    if (!hierarchyType.getUniversalType().equals(AllowedIn.CLASS)) {
        hierarchyType.validateUniversalRelationship(this.getType(), parent.getType());
    }
    String edgeOid = null;
    if (this.getVertex().isNew() || !this.exists(parent, hierarchyType, null, null)) {
        EdgeObject edge = this.getVertex().addParent(((VertexComponent) parent).getVertex(), hierarchyType.getMdEdge());
        edge.apply();
        edgeOid = edge.getOid();
    }
    ServerParentTreeNode node = new ServerParentTreeNode(this, hierarchyType, this.date, null, null);
    node.addParent(new ServerParentTreeNode(parent, hierarchyType, this.date, null, edgeOid));
    return node;
}
Also used : ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) EdgeObject(com.runwaysdk.business.graph.EdgeObject) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString)

Example 4 with ServerParentTreeNode

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

the class VertexServerGeoObject method setParents.

@Override
public void setParents(ServerParentTreeNodeOverTime parentsOverTime) {
    parentsOverTime.enforceUserHasPermissionSetParents(this.getType().getCode(), false);
    final Collection<ServerHierarchyType> hierarchyTypes = parentsOverTime.getHierarchies();
    for (ServerHierarchyType hierarchyType : hierarchyTypes) {
        final List<ServerParentTreeNode> entries = parentsOverTime.getEntries(hierarchyType);
        this.removeAllEdges(hierarchyType);
        final TreeSet<EdgeObject> edges = new TreeSet<EdgeObject>(new EdgeComparator());
        for (ServerParentTreeNode entry : entries) {
            final ServerGeoObjectIF parent = entry.getGeoObject();
            EdgeObject newEdge = this.getVertex().addParent(((VertexComponent) parent).getVertex(), hierarchyType.getMdEdge());
            newEdge.setValue(GeoVertex.START_DATE, entry.getStartDate());
            newEdge.setValue(GeoVertex.END_DATE, entry.getEndDate());
            edges.add(newEdge);
        }
        for (EdgeObject e : edges) {
            e.apply();
        }
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) EdgeObject(com.runwaysdk.business.graph.EdgeObject) TreeSet(java.util.TreeSet)

Example 5 with ServerParentTreeNode

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

the class VertexServerGeoObject method internalGetParentOverTime.

protected static ServerParentTreeNodeOverTime internalGetParentOverTime(VertexServerGeoObject child, String[] parentTypes, boolean recursive) {
    final ServerGeoObjectType cType = child.getType();
    final List<ServerHierarchyType> hierarchies = cType.getHierarchies();
    ServerParentTreeNodeOverTime response = new ServerParentTreeNodeOverTime(cType);
    for (ServerHierarchyType ht : hierarchies) {
        response.add(ht);
    }
    Map<String, Object> parameters = new HashedMap<String, Object>();
    parameters.put("rid", child.getVertex().getRID());
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT EXPAND(inE()");
    if (parentTypes != null && parentTypes.length > 0) {
        statement.append("[");
        for (int i = 0; i < parentTypes.length; i++) {
            ServerGeoObjectType type = ServerGeoObjectType.get(parentTypes[i]);
            if (i > 0) {
                statement.append(" OR ");
            }
            statement.append("out.@class = :a" + i);
            parameters.put("a" + Integer.toString(i), type.getMdVertex().getDBClassName());
        }
        statement.append("]");
    }
    statement.append(") FROM :rid");
    statement.append(" ORDER BY startDate ASC");
    GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement.toString(), parameters);
    List<EdgeObject> edges = query.getResults();
    for (EdgeObject edge : edges) {
        MdEdgeDAOIF mdEdge = (MdEdgeDAOIF) edge.getMdClass();
        if (HierarchicalRelationshipType.isEdgeAHierarchyType(mdEdge)) {
            ServerHierarchyType ht = ServerHierarchyType.get(mdEdge);
            VertexObject parentVertex = edge.getParent();
            MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
            ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
            Date date = edge.getObjectValue(GeoVertex.START_DATE);
            Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
            String oid = edge.getObjectValue(GeoVertex.OID);
            ServerParentTreeNode tnRoot = new ServerParentTreeNode(child, null, date, null, oid);
            tnRoot.setEndDate(endDate);
            tnRoot.setOid(oid);
            VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, date);
            ServerParentTreeNode tnParent;
            if (recursive) {
                tnParent = internalGetParentGeoObjects(parent, parentTypes, recursive, ht, date);
            } else {
                tnParent = new ServerParentTreeNode(parent, ht, date, null, oid);
            }
            tnRoot.addParent(tnParent);
            response.add(ht, tnRoot);
        }
    }
    return response;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) EdgeObject(com.runwaysdk.business.graph.EdgeObject) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) Point(com.vividsolutions.jts.geom.Point) Date(java.util.Date) LocalDate(java.time.LocalDate) 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) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Aggregations

ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)16 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)9 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)9 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)7 EdgeObject (com.runwaysdk.business.graph.EdgeObject)5 Request (com.runwaysdk.session.Request)5 Entry (java.util.Map.Entry)4 JsonObject (com.google.gson.JsonObject)3 VertexObject (com.runwaysdk.business.graph.VertexObject)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 LineString (com.vividsolutions.jts.geom.LineString)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 Point (com.vividsolutions.jts.geom.Point)3 Date (java.util.Date)3 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)3 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)3 GraphObject (com.runwaysdk.business.graph.GraphObject)2 GraphQuery (com.runwaysdk.business.graph.GraphQuery)2 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)2