Search in sources :

Example 6 with EdgeObject

use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.

the class UndirectedGraphStrategy method getParents.

private ServerParentGraphNode getParents(VertexServerGeoObject source, Boolean recursive, Date date, TreeSet<String> visited) {
    ServerParentGraphNode tnRoot = new ServerParentGraphNode(source, this.type, date, null, null);
    List<EdgeObject> edges = this.getEdges(source, date);
    for (EdgeObject edge : edges) {
        Object sourceRid = source.getVertex().getRID();
        final VertexObject vertex = edge.getChild().getRID().equals(sourceRid) ? edge.getParent() : edge.getChild();
        MdVertexDAOIF mdVertex = (MdVertexDAOIF) vertex.getMdClass();
        ServerGeoObjectType targetType = ServerGeoObjectType.get(mdVertex);
        VertexServerGeoObject target = new VertexServerGeoObject(targetType, vertex, date);
        if (!target.getUid().equals(source.getUid())) {
            ServerParentGraphNode tnParent;
            if (recursive & !visited.contains(target.getUid())) {
                visited.add(target.getUid());
                tnParent = this.getParents(target, recursive, date, visited);
                tnParent.setOid(edge.getOid());
            } else {
                tnParent = new ServerParentGraphNode(target, this.type, date, null, edge.getOid());
            }
            tnRoot.addParent(tnParent);
        }
    }
    return tnRoot;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode)

Example 7 with EdgeObject

use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.

the class VertexServerGeoObject method createExternalId.

@Override
public void createExternalId(ExternalSystem system, String id, ImportStrategy importStrategy) {
    if (importStrategy.equals(ImportStrategy.NEW_ONLY)) {
        EdgeObject edge = this.getVertex().addParent(system, GeoVertex.EXTERNAL_ID);
        edge.setValue("id", id);
        edge.apply();
    } else {
        EdgeObject edge = this.getExternalIdEdge(system);
        if (edge == null) {
            edge = this.getVertex().addParent(system, GeoVertex.EXTERNAL_ID);
        }
        edge.setValue("id", id);
        edge.apply();
    }
}
Also used : EdgeObject(com.runwaysdk.business.graph.EdgeObject)

Example 8 with EdgeObject

use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.

the class VertexServerGeoObject method internalGetChildGeoObjects.

private static ServerChildTreeNode internalGetChildGeoObjects(VertexServerGeoObject parent, String[] childrenTypes, Boolean recursive, ServerHierarchyType htIn, Date date) {
    ServerChildTreeNode tnRoot = new ServerChildTreeNode(parent, htIn, date, null, null);
    Map<String, Object> parameters = new HashedMap<String, Object>();
    parameters.put("rid", parent.getVertex().getRID());
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT EXPAND(outE(");
    if (htIn != null) {
        statement.append("'" + htIn.getMdEdge().getDBClassName() + "'");
    }
    statement.append(")");
    if (childrenTypes != null && childrenTypes.length > 0) {
        statement.append("[");
        for (int i = 0; i < childrenTypes.length; i++) {
            ServerGeoObjectType type = ServerGeoObjectType.get(childrenTypes[i]);
            final String paramName = "p" + Integer.toString(i);
            if (i > 0) {
                statement.append(" OR ");
            }
            statement.append("in.@class = :" + paramName);
            parameters.put(paramName, type.getMdVertex().getDBClassName());
        }
        statement.append("]");
    }
    statement.append(") FROM :rid");
    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)) {
            VertexObject childVertex = edge.getChild();
            MdVertexDAOIF mdVertex = (MdVertexDAOIF) childVertex.getMdClass();
            ServerHierarchyType ht = ServerHierarchyType.get(mdEdge);
            ServerGeoObjectType childType = ServerGeoObjectType.get(mdVertex);
            VertexServerGeoObject child = new VertexServerGeoObject(childType, childVertex, date);
            ServerChildTreeNode tnChild;
            if (recursive) {
                tnChild = internalGetChildGeoObjects(child, childrenTypes, recursive, ht, date);
            } else {
                tnChild = new ServerChildTreeNode(child, ht, date, null, edge.getOid());
            }
            tnRoot.addChild(tnChild);
        }
    }
    return tnRoot;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerChildTreeNode(net.geoprism.registry.model.ServerChildTreeNode) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) Point(com.vividsolutions.jts.geom.Point) 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) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 9 with EdgeObject

use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.

the class VertexServerGeoObject method getEdge.

public EdgeObject getEdge(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType, Date startDate, Date endDate) {
    String statement = "SELECT FROM " + hierarchyType.getMdEdge().getDBClassName();
    statement += " WHERE out = :parent";
    statement += " AND in = :child";
    if (startDate != null) {
        statement += " AND startDate = :startDate";
    }
    if (endDate != null) {
        statement += " AND endDate = :endDate";
    }
    GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement);
    query.setParameter("parent", ((VertexComponent) parent).getVertex().getRID());
    query.setParameter("child", this.getVertex().getRID());
    if (startDate != null) {
        query.setParameter("startDate", startDate);
    }
    if (endDate != null) {
        query.setParameter("endDate", endDate);
    }
    return query.getSingleResult();
}
Also used : EdgeObject(com.runwaysdk.business.graph.EdgeObject) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 10 with EdgeObject

use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.

the class VertexServerGeoObject method getParentCollection.

public ValueOverTimeCollection getParentCollection(ServerHierarchyType hierarchyType) {
    ValueOverTimeCollection votc = new ValueOverTimeCollection();
    SortedSet<EdgeObject> edges = this.getEdges(hierarchyType);
    for (EdgeObject edge : edges) {
        final Date startDate = edge.getObjectValue(GeoVertex.START_DATE);
        final Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
        VertexObject parentVertex = edge.getParent();
        MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
        ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
        VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, startDate);
        votc.add(new ValueOverTime(edge.getOid(), startDate, endDate, parent));
    }
    return votc;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Date(java.util.Date) LocalDate(java.time.LocalDate)

Aggregations

EdgeObject (com.runwaysdk.business.graph.EdgeObject)31 VertexObject (com.runwaysdk.business.graph.VertexObject)15 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)15 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)15 GraphQuery (com.runwaysdk.business.graph.GraphQuery)11 Date (java.util.Date)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)9 LineString (com.vividsolutions.jts.geom.LineString)7 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)7 TreeSet (java.util.TreeSet)7 HashedMap (org.apache.commons.collections4.map.HashedMap)7 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)6 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)5 ServerParentGraphNode (net.geoprism.registry.model.ServerParentGraphNode)5 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)5 GraphObject (com.runwaysdk.business.graph.GraphObject)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 Point (com.vividsolutions.jts.geom.Point)3 LocalDate (java.time.LocalDate)3 AbstractServerGeoObject (net.geoprism.registry.model.AbstractServerGeoObject)3