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