use of com.runwaysdk.dataaccess.MdAttributeDAOIF 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.dataaccess.MdAttributeDAOIF 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.dataaccess.MdAttributeDAOIF 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.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class ServerGeoObjectType method deleteMdAttributeFromAttributeType.
/**
* Delete the {@link MdAttributeConcreteDAOIF} from the given {
*
* @param type
* TODO
* @param mdBusiness
* @param attributeName
*/
@Transaction
public void deleteMdAttributeFromAttributeType(String attributeName) {
MdAttributeConcreteDAOIF mdAttributeConcreteDAOIF = getMdAttribute(this.mdBusiness, attributeName);
if (mdAttributeConcreteDAOIF != null) {
if (mdAttributeConcreteDAOIF instanceof MdAttributeTermDAOIF || mdAttributeConcreteDAOIF instanceof MdAttributeMultiTermDAOIF) {
String attributeTermKey = TermConverter.buildtAtttributeKey(this.mdBusiness.getTypeName(), mdAttributeConcreteDAOIF.definesAttribute());
try {
Classifier attributeTerm = Classifier.getByKey(attributeTermKey);
attributeTerm.delete();
} catch (DataNotFoundException e) {
}
}
mdAttributeConcreteDAOIF.getBusinessDAO().delete();
Optional<AttributeType> optional = this.type.getAttribute(attributeName);
if (optional.isPresent()) {
ListType.deleteMdAttribute(this.universal, optional.get());
}
}
MdAttributeDAOIF mdAttributeDAO = this.mdVertex.definesAttribute(attributeName);
if (mdAttributeDAO != null) {
mdAttributeDAO.getBusinessDAO().delete();
}
}
use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class AbstractGraphPageQuery method getPage.
public Page<T> getPage() {
int pageSize = 10;
int pageNumber = 1;
Long count = this.getCount();
final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(this.type);
StringBuilder statement = new StringBuilder();
statement.append("SELECT ");
this.addSelectAttributes(mdVertex, statement);
statement.append(" FROM " + mdVertex.getDBClassName() + "");
Map<String, Object> parameters = new HashMap<String, Object>();
if (criteria.has("filters")) {
JsonObject filters = criteria.get("filters").getAsJsonObject();
this.addCriteria(mdVertex, filters, statement, parameters);
}
if (criteria.has("sortField") && criteria.has("sortOrder")) {
String field = criteria.get("sortField").getAsString();
SortOrder order = criteria.get("sortOrder").getAsInt() == 1 ? SortOrder.ASC : SortOrder.DESC;
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(field);
statement.append(" ORDER BY " + this.getColumnName(mdAttribute) + " " + order.name());
} else if (criteria.has("multiSortMeta")) {
JsonArray sorts = criteria.get("multiSortMeta").getAsJsonArray();
for (int i = 0; i < sorts.size(); i++) {
JsonObject sort = sorts.get(i).getAsJsonObject();
String field = sort.get("field").getAsString();
SortOrder order = sort.get("order").getAsInt() == 1 ? SortOrder.ASC : SortOrder.DESC;
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(field);
if (i == 0) {
statement.append(" ORDER BY " + this.getColumnName(mdAttribute) + " " + order.name());
} else {
statement.append(", " + this.getColumnName(mdAttribute) + " " + order.name());
}
}
}
if (criteria.has("first") && criteria.has("rows")) {
int first = criteria.get("first").getAsInt();
int rows = criteria.get("rows").getAsInt();
statement.append(" SKIP " + first + " LIMIT " + rows);
pageNumber = (first / rows) + 1;
}
final GraphQuery<K> query = new GraphQuery<K>(statement.toString(), parameters);
return new Page<T>(count, pageNumber, pageSize, this.getResults(query));
}
Aggregations