use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.
the class TransitionEvent method getAll.
public static List<TransitionEvent> getAll(ServerGeoObjectType type) {
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(TransitionEvent.CLASS);
MdAttributeDAOIF beforeTypeCode = mdVertex.definesAttribute(TransitionEvent.BEFORETYPECODE);
MdAttributeDAOIF afterTypeCode = mdVertex.definesAttribute(TransitionEvent.AFTERTYPECODE);
List<ServerGeoObjectType> types = new LinkedList<ServerGeoObjectType>();
types.add(type);
types.addAll(type.getSubtypes());
List<String> codes = types.stream().map(t -> type.getCode()).collect(Collectors.toList());
StringBuilder statement = new StringBuilder();
statement.append("SELECT FROM " + mdVertex.getDBClassName());
statement.append(" WHERE (" + beforeTypeCode.getColumnName() + " IN :typeCode");
statement.append(" OR " + afterTypeCode.getColumnName() + " IN :typeCode )");
GraphQuery<TransitionEvent> query = new GraphQuery<TransitionEvent>(statement.toString());
query.setParameter("typeCode", codes);
return query.getResults();
}
use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.
the class CRAttributePatch method patchAllGos.
private void patchAllGos() {
for (Universal uni : getUniversals()) {
MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
List<? extends MdAttributeDAOIF> attributes = mdVertex.getAllDefinedMdAttributes();
String[] skipAttrs = new String[] { DefaultAttribute.UID.getName(), "uuid", DefaultAttribute.CODE.getName(), DefaultAttribute.CREATE_DATE.getName(), DefaultAttribute.LAST_UPDATE_DATE.getName(), DefaultAttribute.SEQUENCE.getName(), DefaultAttribute.TYPE.getName(), MdAttributeConcreteInfo.OID, MdAttributeConcreteInfo.SEQUENCE };
StringBuilder statement = new StringBuilder();
statement.append("SELECT FROM " + mdVertex.getDBClassName());
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
List<VertexObject> results = query.getResults();
logger.info("Updating [" + results.size() + "] objects on table [" + mdVertex.getDBClassName() + "].");
for (VertexObject vo : query.getResults()) {
for (MdAttributeDAOIF attr : attributes) {
if (!ArrayUtils.contains(skipAttrs, attr.definesAttribute())) {
ValueOverTimeCollection col = vo.getValuesOverTime(attr.definesAttribute());
for (ValueOverTime vot : col) {
vot.setOid(UUID.randomUUID().toString());
}
}
}
vo.apply();
}
}
}
use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.
the class PatchLastUpdateDate method getCount.
public long getCount() {
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(GeoVertex.LASTUPDATEDATE);
MdAttributeDAOIF createDate = mdVertex.definesAttribute(GeoVertex.CREATEDATE);
StringBuilder builder = new StringBuilder();
builder.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
builder.append(" WHERE " + mdAttribute.getColumnName() + " IS NULL");
builder.append(" OR " + createDate.getColumnName() + " IS NULL");
final GraphQuery<Long> query = new GraphQuery<Long>(builder.toString());
return query.getSingleResult();
}
use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.
the class SearchTablePatch method createRecords.
@Transaction
public void createRecords(SearchService service) {
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
long pageSize = 1000;
long skip = 0;
int count = 0;
do {
StringBuilder builder = new StringBuilder();
builder.append("SELECT FROM " + mdVertex.getDBClassName());
builder.append(" ORDER BY oid");
builder.append(" SKIP " + skip + " LIMIT " + pageSize);
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
ServerGeoObjectType type = ServerGeoObjectType.get((MdVertexDAOIF) result.getMdClass());
service.insert(new VertexServerGeoObject(type, result));
}
skip += pageSize;
count = results.size();
} while (count > 0);
}
use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.
the class GeoObjectJsonExporter method count.
public Long count() {
MdVertexDAOIF mdVertex = got.getMdVertex();
MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
StringBuilder statement = new StringBuilder();
statement.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
if (this.since != null) {
statement.append(" WHERE " + mdAttribute.getColumnName() + " >= :lastUpdateDate");
}
statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
GraphQuery<Long> query = new GraphQuery<Long>(statement.toString());
if (this.since != null) {
query.setParameter("lastUpdateDate", this.since);
}
return query.getSingleResult();
}
Aggregations