Search in sources :

Example 36 with VertexObject

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

the class BusinessObject method get.

public static BusinessObject get(BusinessType type, String attributeName, Object value) {
    MdVertexDAOIF mdVertex = type.getMdVertexDAO();
    MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(attributeName);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    statement.append(" WHERE " + mdAttribute.getColumnName() + " = :" + attributeName);
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    query.setParameter(attributeName, value);
    VertexObject result = query.getSingleResult();
    if (result != null) {
        return new BusinessObject(result, type);
    }
    return null;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 37 with VertexObject

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

the class Classification method getChildren.

public Page<Classification> getChildren(Integer pageSize, Integer pageNumber) {
    StringBuilder cStatement = new StringBuilder();
    cStatement.append("SELECT out('" + this.type.getMdEdge().getDBClassName() + "').size()");
    cStatement.append(" FROM :rid");
    GraphQuery<Integer> cQuery = new GraphQuery<Integer>(cStatement.toString());
    cQuery.setParameter("rid", this.getVertex().getRID());
    Integer count = cQuery.getSingleResult();
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT EXPAND(out('" + this.type.getMdEdge().getDBClassName() + "')");
    statement.append(") FROM :rid");
    statement.append(" ORDER BY code");
    if (pageSize != null && pageNumber != null) {
        int first = pageSize * (pageNumber - 1);
        int rows = pageSize;
        statement.append(" SKIP " + first + " LIMIT " + rows);
    }
    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 new Page<Classification>(count, pageNumber, pageSize, 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) Page(net.geoprism.registry.view.Page) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 38 with VertexObject

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

the class Classification method getByOid.

public static Classification getByOid(ClassificationType type, String oid) {
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT FROM " + type.getMdVertex().getDBClassName());
    builder.append(" WHERE oid = :oid");
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
    query.setParameter("oid", oid);
    VertexObject result = query.getSingleResult();
    if (result != null) {
        return new Classification(type, result);
    }
    return null;
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) AbstractClassification(com.runwaysdk.system.AbstractClassification) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 39 with VertexObject

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

the class Classification method getAncestors.

public List<Classification> getAncestors(String rootCode) {
    GraphQuery<VertexObject> query = null;
    if (rootCode != null && rootCode.length() > 0) {
        StringBuilder statement = new StringBuilder();
        statement.append("SELECT expand($res)");
        statement.append(" LET $a = (TRAVERSE in(\"" + this.type.getMdEdge().getDBClassName() + "\") FROM :rid WHILE (code != :code))");
        statement.append(", $b = (SELECT FROM " + this.type.getMdVertex().getDBClassName() + " WHERE code = :code)");
        statement.append(", $res = (UNIONALL($a,$b))");
        query = new GraphQuery<VertexObject>(statement.toString());
        query.setParameter("rid", this.vertex.getRID());
        query.setParameter("code", rootCode);
    } else {
        StringBuilder statement = new StringBuilder();
        statement.append("TRAVERSE in(\"" + this.type.getMdEdge().getDBClassName() + "\") FROM :rid");
        query = new GraphQuery<VertexObject>(statement.toString());
        query.setParameter("rid", this.vertex.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)

Example 40 with VertexObject

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

the class Classification method get.

public static Classification get(ClassificationType type, String code) {
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT FROM " + type.getMdVertex().getDBClassName());
    builder.append(" WHERE code = :code");
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
    query.setParameter("code", code);
    VertexObject result = query.getSingleResult();
    if (result != null) {
        return new Classification(type, result);
    }
    return null;
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) AbstractClassification(com.runwaysdk.system.AbstractClassification) 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