Search in sources :

Example 1 with MdEdgeDAOIF

use of com.runwaysdk.dataaccess.MdEdgeDAOIF 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 2 with MdEdgeDAOIF

use of com.runwaysdk.dataaccess.MdEdgeDAOIF in project geoprism-registry by terraframe.

the class VertexServerGeoObject method getExternalIdEdge.

private EdgeObject getExternalIdEdge(ExternalSystem system) {
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(GeoVertex.EXTERNAL_ID);
    String statement = "SELECT expand(inE('" + mdEdge.getDBClassName() + "')[out = :parent])";
    statement += " FROM :child";
    GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement);
    query.setParameter("parent", system.getRID());
    query.setParameter("child", this.getVertex().getRID());
    return query.getSingleResult();
}
Also used : MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) 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 3 with MdEdgeDAOIF

use of com.runwaysdk.dataaccess.MdEdgeDAOIF 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)

Example 4 with MdEdgeDAOIF

use of com.runwaysdk.dataaccess.MdEdgeDAOIF in project geoprism-registry by terraframe.

the class AttributeValueRestriction method subquery.

@Override
public void subquery(StringBuilder statement, Map<String, Object> parameters, String parameterName) {
    String columnName = mdAttribute.getColumnName() + "_cot";
    statement.append("(" + columnName + " CONTAINS (");
    statement.append(":date BETWEEN startDate AND endDate AND ");
    if (this.mdAttribute instanceof MdAttributeClassificationDAOIF && operation.equalsIgnoreCase("eq")) {
        MdClassificationDAOIF mdClassification = ((MdAttributeClassificationDAOIF) this.mdAttribute).getMdClassificationDAOIF();
        MdEdgeDAOIF mdEdge = mdClassification.getReferenceMdEdgeDAO();
        statement.append("value IN ( TRAVERSE out(\"" + mdEdge.getDBClassName() + "\") FROM :" + parameterName + ")");
    } else {
        statement.append("value = :" + parameterName);
    }
    // Close CONTAINS parentheses
    statement.append(")");
    // Close CONDITION parentheses
    statement.append(")");
    parameters.put(parameterName, this.value);
    parameters.put("date", this.date);
}
Also used : MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF)

Example 5 with MdEdgeDAOIF

use of com.runwaysdk.dataaccess.MdEdgeDAOIF in project geoprism-registry by terraframe.

the class VertexExternalIdRestriction method restrict.

@Override
public void restrict(StringBuilder statement, Map<String, Object> parameters) {
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(GeoVertex.EXTERNAL_ID);
    statement.append("}.inE('" + mdEdge.getDBClassName() + "'){where: (id = :id AND out = :out)");
    parameters.put("out", this.system.getRID());
    parameters.put("id", this.externalId);
}
Also used : MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF)

Aggregations

MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)15 GraphQuery (com.runwaysdk.business.graph.GraphQuery)7 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)7 EdgeObject (com.runwaysdk.business.graph.EdgeObject)5 VertexObject (com.runwaysdk.business.graph.VertexObject)5 LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)4 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)4 GraphObject (com.runwaysdk.business.graph.GraphObject)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 Point (com.vividsolutions.jts.geom.Point)3 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 MdClassificationDAOIF (com.runwaysdk.dataaccess.MdClassificationDAOIF)2 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 Request (com.runwaysdk.session.Request)2 Date (java.util.Date)2 AbstractServerGeoObject (net.geoprism.registry.model.AbstractServerGeoObject)2 HashedMap (org.apache.commons.collections4.map.HashedMap)2 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)2