Search in sources :

Example 11 with VertexObject

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

the class Classification method getParents.

public List<Classification> getParents() {
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT EXPAND(in('" + this.type.getMdEdge().getDBClassName() + "')");
    statement.append(") FROM :rid");
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    query.setParameter("rid", this.getVertex().getRID());
    List<Classification> results = query.getResults().stream().map(vertex -> {
        return new Classification(this.type, vertex);
    }).collect(Collectors.toList());
    return results;
}
Also used : JsonObject(com.google.gson.JsonObject) Term(org.commongeoregistry.adapter.Term) AbstractClassification(com.runwaysdk.system.AbstractClassification) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) VertexObject(com.runwaysdk.business.graph.VertexObject) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) CannotDeleteClassificationWithChildrenException(net.geoprism.registry.CannotDeleteClassificationWithChildrenException) IOException(java.io.IOException) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) JsonParser(com.google.gson.JsonParser) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) VertexObjectDAO(com.runwaysdk.dataaccess.graph.VertexObjectDAO) ApplicationResource(com.runwaysdk.resource.ApplicationResource) AbstractVertexRestriction(net.geoprism.registry.query.graph.AbstractVertexRestriction) Page(net.geoprism.registry.view.Page) JsonElement(com.google.gson.JsonElement) List(java.util.List) JsonArray(com.google.gson.JsonArray) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) JsonSerializable(net.geoprism.registry.view.JsonSerializable) EdgeObject(com.runwaysdk.business.graph.EdgeObject) InputStream(java.io.InputStream) VertexObject(com.runwaysdk.business.graph.VertexObject) AbstractClassification(com.runwaysdk.system.AbstractClassification) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 12 with VertexObject

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

the class Classification method search.

public static List<Classification> search(ClassificationType type, String rootCode, String text) {
    StringBuilder builder = new StringBuilder();
    if (rootCode != null && rootCode.length() > 0) {
        builder.append("SELECT FROM (TRAVERSE out(\"" + type.getMdEdge().getDBClassName() + "\") FROM :rid) ");
    } else {
        builder.append("SELECT FROM " + type.getMdVertex().getDBClassName());
    }
    if (text != null) {
        builder.append(" WHERE (code.toUpperCase() LIKE :text");
        builder.append(" OR " + AbstractVertexRestriction.localize("displayLabel") + ".toUpperCase() LIKE :text)");
    }
    builder.append(" ORDER BY code");
    builder.append(" LIMIT 10");
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
    if (text != null) {
        query.setParameter("text", "%" + text.toUpperCase() + "%");
    }
    if (rootCode != null && rootCode.length() > 0) {
        Classification root = Classification.get(type, rootCode);
        query.setParameter("rid", root.getVertex().getRID());
    }
    List<Classification> results = query.getResults().stream().map(vertex -> {
        return new Classification(type, vertex);
    }).collect(Collectors.toList());
    return results;
}
Also used : JsonObject(com.google.gson.JsonObject) Term(org.commongeoregistry.adapter.Term) AbstractClassification(com.runwaysdk.system.AbstractClassification) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) VertexObject(com.runwaysdk.business.graph.VertexObject) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) CannotDeleteClassificationWithChildrenException(net.geoprism.registry.CannotDeleteClassificationWithChildrenException) IOException(java.io.IOException) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) JsonParser(com.google.gson.JsonParser) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) VertexObjectDAO(com.runwaysdk.dataaccess.graph.VertexObjectDAO) ApplicationResource(com.runwaysdk.resource.ApplicationResource) AbstractVertexRestriction(net.geoprism.registry.query.graph.AbstractVertexRestriction) Page(net.geoprism.registry.view.Page) JsonElement(com.google.gson.JsonElement) List(java.util.List) JsonArray(com.google.gson.JsonArray) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) JsonSerializable(net.geoprism.registry.view.JsonSerializable) EdgeObject(com.runwaysdk.business.graph.EdgeObject) InputStream(java.io.InputStream) VertexObject(com.runwaysdk.business.graph.VertexObject) AbstractClassification(com.runwaysdk.system.AbstractClassification) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 13 with VertexObject

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

the class DirectedAcyclicGraphStrategy method getChildren.

@SuppressWarnings("unchecked")
@Override
public ServerChildGraphNode getChildren(VertexServerGeoObject parent, Boolean recursive, Date date) {
    ServerChildGraphNode tnRoot = new ServerChildGraphNode(parent, this.type, 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(");
    statement.append("'" + this.type.getMdEdgeDAO().getDBClassName() + "'");
    statement.append(")");
    if (date != null) {
        statement.append("[:date BETWEEN startDate AND endDate]");
        parameters.put("date", date);
    }
    statement.append(") FROM :rid");
    GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement.toString(), parameters);
    List<EdgeObject> edges = query.getResults();
    for (EdgeObject edge : edges) {
        final VertexObject childVertex = edge.getChild();
        MdVertexDAOIF mdVertex = (MdVertexDAOIF) childVertex.getMdClass();
        ServerGeoObjectType childType = ServerGeoObjectType.get(mdVertex);
        VertexServerGeoObject child = new VertexServerGeoObject(childType, childVertex, date);
        ServerChildGraphNode tnParent;
        if (recursive) {
            tnParent = this.getChildren(child, recursive, date);
            tnParent.setOid(edge.getOid());
        } else {
            tnParent = new ServerChildGraphNode(child, 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) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 14 with VertexObject

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

the class DirectedAcyclicGraphStrategy 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 15 with VertexObject

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

the class DirectedAcyclicGraphStrategy method getParents.

@SuppressWarnings("unchecked")
@Override
public ServerParentGraphNode getParents(VertexServerGeoObject child, Boolean recursive, Date date) {
    ServerParentGraphNode tnRoot = new ServerParentGraphNode(child, this.type, date, null, null);
    Map<String, Object> parameters = new HashedMap<String, Object>();
    parameters.put("rid", child.getVertex().getRID());
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT EXPAND( inE(");
    statement.append("'" + this.type.getMdEdgeDAO().getDBClassName() + "'");
    statement.append(")");
    if (date != null) {
        statement.append("[:date BETWEEN startDate AND endDate]");
        parameters.put("date", date);
    }
    statement.append(") FROM :rid");
    GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement.toString(), parameters);
    List<EdgeObject> edges = query.getResults();
    for (EdgeObject edge : edges) {
        final VertexObject parentVertex = edge.getParent();
        MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
        ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
        VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, date);
        ServerParentGraphNode tnParent;
        if (recursive) {
            tnParent = this.getParents(parent, recursive, date);
            tnParent.setOid(edge.getOid());
        } else {
            tnParent = new ServerParentGraphNode(parent, 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) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Aggregations

VertexObject (com.runwaysdk.business.graph.VertexObject)53 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)29 GraphQuery (com.runwaysdk.business.graph.GraphQuery)28 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)23 EdgeObject (com.runwaysdk.business.graph.EdgeObject)20 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)18 LinkedList (java.util.LinkedList)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)9 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)8 Date (java.util.Date)8 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 AbstractClassification (com.runwaysdk.system.AbstractClassification)7 HashedMap (org.apache.commons.collections4.map.HashedMap)7 JsonObject (com.google.gson.JsonObject)6 List (java.util.List)6 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)6 JsonArray (com.google.gson.JsonArray)5 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)5 LineString (com.vividsolutions.jts.geom.LineString)5 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)5