Search in sources :

Example 21 with EdgeObject

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

the class UndirectedGraphStrategy method getParentCollection.

private Set<ValueOverTime> getParentCollection(VertexServerGeoObject geoObject) {
    Set<ValueOverTime> set = new TreeSet<ValueOverTime>(new Comparator<ValueOverTime>() {

        @Override
        public int compare(ValueOverTime o1, ValueOverTime o2) {
            return o1.getOid().compareTo(o2.getOid());
        }
    });
    SortedSet<EdgeObject> edges = this.getParentEdges(geoObject);
    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);
        set.add(new ValueOverTime(edge.getOid(), startDate, endDate, parent));
    }
    return set;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) VertexObject(com.runwaysdk.business.graph.VertexObject) TreeSet(java.util.TreeSet) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Date(java.util.Date)

Example 22 with EdgeObject

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

the class UndirectedGraphStrategy method addParent.

@SuppressWarnings("unchecked")
@Override
public <T extends ServerGraphNode> T addParent(VertexServerGeoObject geoObject, VertexServerGeoObject parent, Date startDate, Date endDate) {
    if (this.isCycle(geoObject, parent, startDate, endDate)) {
        throw new UnsupportedOperationException("Cyclic graph is not supported");
    }
    if (this.getEdges(geoObject, parent, startDate, endDate).size() > 0) {
        throw new UnsupportedOperationException("Duplicate edge");
    }
    Set<ValueOverTime> votc = this.getParentCollection(geoObject);
    votc.add(new ValueOverTime(startDate, endDate, parent));
    SortedSet<EdgeObject> newEdges = this.setParentCollection(geoObject, votc);
    ServerParentGraphNode node = new ServerParentGraphNode(geoObject, this.type, startDate, endDate, null);
    node.addParent(new ServerParentGraphNode(parent, this.type, startDate, endDate, newEdges.first().getOid()));
    return (T) node;
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode)

Example 23 with EdgeObject

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

the class UndirectedGraphStrategy method getChildren.

private ServerChildGraphNode getChildren(VertexServerGeoObject source, Boolean recursive, Date date, TreeSet<String> visited) {
    ServerChildGraphNode tnRoot = new ServerChildGraphNode(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 vertexType = ServerGeoObjectType.get(mdVertex);
        VertexServerGeoObject target = new VertexServerGeoObject(vertexType, vertex, date);
        if (!source.getUid().equals(target.getUid())) {
            ServerChildGraphNode tnParent;
            if (recursive && !visited.contains(target.getUid())) {
                visited.add(target.getUid());
                tnParent = this.getChildren(target, recursive, date, visited);
                tnParent.setOid(edge.getOid());
            } else {
                tnParent = new ServerChildGraphNode(target, this.type, date, null, edge.getOid());
            }
            tnRoot.addChild(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) ServerChildGraphNode(net.geoprism.registry.model.ServerChildGraphNode) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject)

Example 24 with EdgeObject

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

the class VertexServerGeoObject method getEdges.

public SortedSet<EdgeObject> getEdges(ServerHierarchyType hierarchyType) {
    TreeSet<EdgeObject> set = new TreeSet<EdgeObject>(new EdgeComparator());
    String statement = "SELECT expand(inE('" + hierarchyType.getMdEdge().getDBClassName() + "'))";
    statement += " FROM :child";
    GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement);
    query.setParameter("child", this.getVertex().getRID());
    set.addAll(query.getResults());
    return set;
}
Also used : EdgeObject(com.runwaysdk.business.graph.EdgeObject) TreeSet(java.util.TreeSet) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 25 with EdgeObject

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

the class VertexServerGeoObject method removeParent.

@Override
public void removeParent(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType, Date startDate, Date endDate) {
    EdgeObject edge = this.getEdge(parent, hierarchyType, startDate, endDate);
    edge.delete();
// 
// this.getVertex().removeParent( ( (VertexComponent) parent ).getVertex(), hierarchyType.getMdEdge());
}
Also used : EdgeObject(com.runwaysdk.business.graph.EdgeObject)

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