Search in sources :

Example 6 with GraphQuery

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

the class PatchLastUpdateDate method doIt.

@Transaction
private void doIt() {
    Date date = new Date();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
    MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(GeoVertex.LASTUPDATEDATE);
    MdAttributeDAOIF createDate = mdVertex.definesAttribute(GeoVertex.CREATEDATE);
    long pageSize = 1000;
    long count = 0;
    do {
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT FROM " + mdVertex.getDBClassName());
        builder.append(" WHERE " + mdAttribute.getColumnName() + " IS NULL");
        builder.append(" OR " + createDate.getColumnName() + " IS NULL");
        builder.append(" ORDER BY oid");
        builder.append(" SKIP " + 0 + " LIMIT " + pageSize);
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
        List<VertexObject> results = query.getResults();
        for (VertexObject result : results) {
            result.setValue(GeoVertex.LASTUPDATEDATE, date);
            result.setValue(GeoVertex.CREATEDATE, date);
            result.apply();
        }
        count = this.getCount();
    } while (count > 0);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 7 with GraphQuery

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

the class DHIS2SynchronizationManager method query.

private List<VertexServerGeoObject> query(ServerGeoObjectType got, long skip, long pageSize) {
    MdVertexDAOIF mdVertex = got.getMdVertex();
    MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
    statement.append(" SKIP " + skip + " LIMIT " + pageSize);
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    List<VertexObject> vObjects = query.getResults();
    List<VertexServerGeoObject> response = new LinkedList<VertexServerGeoObject>();
    for (VertexObject vObject : vObjects) {
        VertexServerGeoObject vSGO = new VertexServerGeoObject(got, vObject);
        vSGO.setDate(this.date);
        response.add(vSGO);
    }
    return response;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) LinkedList(java.util.LinkedList)

Example 8 with GraphQuery

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

the class GeoObjectJsonExporter method query.

public List<VertexServerGeoObject> query() {
    MdVertexDAOIF mdVertex = got.getMdVertex();
    MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    if (this.since != null) {
        statement.append(" WHERE " + mdAttribute.getColumnName() + " >= :lastUpdateDate");
    }
    statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
    if (this.pageSize != null && this.pageNumber != null && this.pageSize != -1 && this.pageNumber != -1) {
        statement.append(" SKIP " + ((pageNumber - 1) * pageSize) + " LIMIT " + this.pageSize);
    }
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    if (this.since != null) {
        query.setParameter("lastUpdateDate", this.since);
    }
    List<VertexObject> vObjects = query.getResults();
    List<VertexServerGeoObject> response = new LinkedList<VertexServerGeoObject>();
    for (VertexObject vObject : vObjects) {
        VertexServerGeoObject vSGO = new VertexServerGeoObject(got, vObject);
        vSGO.setDate(ValueOverTime.INFINITY_END_DATE);
        response.add(vSGO);
    }
    return response;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) LinkedList(java.util.LinkedList)

Example 9 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery 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 10 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery 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)

Aggregations

GraphQuery (com.runwaysdk.business.graph.GraphQuery)55 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)34 VertexObject (com.runwaysdk.business.graph.VertexObject)29 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)23 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)17 EdgeObject (com.runwaysdk.business.graph.EdgeObject)16 LineString (com.vividsolutions.jts.geom.LineString)11 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)11 LinkedList (java.util.LinkedList)11 JsonObject (com.google.gson.JsonObject)10 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)9 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)9 HashedMap (org.apache.commons.collections4.map.HashedMap)8 JsonArray (com.google.gson.JsonArray)7 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)7 List (java.util.List)7 Page (net.geoprism.registry.view.Page)7 AbstractClassification (com.runwaysdk.system.AbstractClassification)6 HashMap (java.util.HashMap)6 Collectors (java.util.stream.Collectors)6