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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations