use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterList method list.
public static JsonArray list() {
JsonArray response = new JsonArray();
MasterListQuery query = new MasterListQuery(new QueryFactory());
query.ORDER_BY_DESC(query.getDisplayLabel().localize());
OIterator<? extends MasterList> it = query.getIterator();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
while (it.hasNext()) {
MasterList list = it.next();
JsonObject object = new JsonObject();
object.addProperty("label", list.getDisplayLabel().getValue());
object.addProperty("oid", list.getOid());
object.addProperty("createDate", format.format(list.getCreateDate()));
object.addProperty("lasteUpdateDate", format.format(list.getLastUpdateDate()));
response.add(object);
}
} finally {
it.close();
}
return response;
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterList method markAllAsInvalid.
@Transaction
public static void markAllAsInvalid(ServerHierarchyType hierarchyType, ServerGeoObjectType type) {
MasterListQuery query = new MasterListQuery(new QueryFactory());
query.WHERE(query.getValid().EQ((Boolean) null));
query.OR(query.getValid().EQ(true));
try (OIterator<? extends MasterList> iterator = query.getIterator()) {
while (iterator.hasNext()) {
MasterList masterlist = iterator.next();
if (hierarchyType != null && type != null) {
masterlist.markAsInvalid(hierarchyType, type);
} else if (hierarchyType != null) {
masterlist.markAsInvalid(hierarchyType);
} else if (type != null) {
masterlist.markAsInvalid(type);
}
}
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterList method deleteMdAttribute.
public static void deleteMdAttribute(Universal universal, AttributeType attributeType) {
MasterListQuery query = new MasterListQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(universal));
List<? extends MasterList> lists = query.getIterator().getAll();
for (MasterList list : lists) {
list.removeAttributeType(attributeType);
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterListAttributeGroup method remove.
public static void remove(MdAttributeConcreteDAOIF mdAttribute) {
MasterListAttributeGroupQuery query = new MasterListAttributeGroupQuery(new QueryFactory());
query.WHERE(query.getTargetAttribute().EQ(mdAttribute.getOid()));
query.OR(query.getSourceAttribute().EQ(mdAttribute.getOid()));
OIterator<? extends MasterListAttributeGroup> it = query.getIterator();
try {
List<? extends MasterListAttributeGroup> groups = it.getAll();
for (MasterListAttributeGroup group : groups) {
group.delete();
}
} finally {
it.close();
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterListVersion method values.
public JsonArray values(String value, String attributeName, String valueAttribute, String filterJson) {
DateFormat filterFormat = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
filterFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
JsonArray results = new JsonArray();
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
ValueQuery vQuery = new ValueQuery(new QueryFactory());
BusinessQuery query = new BusinessQuery(vQuery, mdBusiness.definesType());
vQuery.SELECT_DISTINCT(query.get(attributeName, "label"), query.get(valueAttribute, "value"));
vQuery.FROM(query);
Map<MdAttributeConcreteDAOIF, Condition> conditionMap = this.buildQueryConditionsFromFilter(filterJson, attributeName, query, mdBusiness);
for (Condition condition : conditionMap.values()) {
vQuery.WHERE(condition);
}
if (value != null && value.length() > 0) {
vQuery.WHERE(query.aCharacter(attributeName).LIKEi("%" + value + "%"));
}
vQuery.ORDER_BY_ASC(query.get(attributeName));
OIterator<ValueObject> it = vQuery.getIterator(100, 1);
try {
while (it.hasNext()) {
ValueObject vObject = it.next();
JsonObject result = new JsonObject();
result.addProperty("label", vObject.getValue("label"));
result.addProperty("value", vObject.getValue("value"));
results.add(result);
}
} finally {
it.close();
}
return results;
}
Aggregations