use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListTypeVersion method bbox.
public JsonArray bbox(String uid) {
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
String tableName = mdBusiness.getTableName();
// collect all the views and extend the bounding box
ValueQuery union = new ValueQuery(new QueryFactory());
union.SELECT(union.aSQLClob(GeoserverFacade.GEOM_COLUMN, GeoserverFacade.GEOM_COLUMN, GeoserverFacade.GEOM_COLUMN));
union.FROM(tableName, tableName);
if (uid != null && uid.length() > 0) {
MdAttributeConcreteDAOIF attribute = mdBusiness.definesAttribute(DefaultAttribute.UID.getName());
String columName = attribute.getColumnName();
union.WHERE(union.aSQLCharacter(columName, columName).EQ(uid));
}
ValueQuery collected = new ValueQuery(union.getQueryFactory());
collected.SELECT(collected.aSQLAggregateClob("collected", "st_collect(" + GeoserverFacade.GEOM_COLUMN + ")", "collected"));
collected.FROM("(" + union.getSQL() + ")", "unioned");
ValueQuery outer = new ValueQuery(union.getQueryFactory());
outer.SELECT(union.aSQLAggregateDouble("minx", "st_xmin(collected)"), union.aSQLAggregateDouble("miny", "st_ymin(collected)"), union.aSQLAggregateDouble("maxx", "st_xmax(collected)"), union.aSQLAggregateDouble("maxy", "st_ymax(collected)"));
outer.FROM("(" + collected.getSQL() + ")", "collected");
try (OIterator<? extends ValueObject> iter = outer.getIterator()) {
ValueObject o = iter.next();
try {
JsonArray bboxArr = new JsonArray();
bboxArr.add(Double.parseDouble(o.getValue("minx")));
bboxArr.add(Double.parseDouble(o.getValue("miny")));
bboxArr.add(Double.parseDouble(o.getValue("maxx")));
bboxArr.add(Double.parseDouble(o.getValue("maxy")));
return bboxArr;
} catch (JSONException ex) {
throw new ProgrammingErrorException(ex);
}
} catch (Exception e) {
return null;
// throw new NoLayerDataException();
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListTypeVersion method buildQuery.
public BusinessQuery buildQuery(String filterJson) {
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
Map<MdAttributeConcreteDAOIF, Condition> conditionMap = this.buildQueryConditionsFromFilter(filterJson, null, query, mdBusiness);
for (Condition condition : conditionMap.values()) {
query.WHERE(condition);
}
return query;
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ListTypeVersion method values.
public JsonArray values(String value, String attributeName, JsonObject criteria) {
ValueQuery vQuery = new ValueQuery(new QueryFactory());
BusinessQuery query = new ListTypeVersionPageQuery(this, criteria, true, false).getQuery(vQuery);
DateFormat filterFormat = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
filterFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
JsonArray results = new JsonArray();
vQuery.SELECT_DISTINCT(query.get(attributeName, "label"));
vQuery.FROM(query);
if (value != null && value.length() > 0) {
vQuery.WHERE(F.UPPER(query.aCharacter(attributeName)).LIKEi("%" + value.toUpperCase() + "%"));
}
try (OIterator<ValueObject> it = vQuery.getIterator(100, 1)) {
while (it.hasNext()) {
ValueObject vObject = it.next();
results.add(vObject.getValue("label"));
// JsonObject result = new JsonObject();
// result.addProperty("label", vObject.getValue("label"));
// result.addProperty("value", vObject.getValue("value"));
//
// results.add(result);
}
}
return results;
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterList method create.
@Transaction
public static MasterList create(JsonObject object) {
MasterList list = MasterList.fromJSON(object);
if (Session.getCurrentSession() != null && Session.getCurrentSession().getUser() != null) {
list.enforceActorHasPermission(Operation.CREATE);
}
if (list.getIsMaster() != null && list.getIsMaster()) {
Universal universal = list.getUniversal();
MasterListQuery query = new MasterListQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(universal));
query.AND(query.getOrganization().EQ(list.getOrganization()));
query.AND(query.getIsMaster().EQ(true));
if (!list.isNew()) {
query.AND(query.getOid().NE(list.getOid()));
}
if (query.getCount() > 0) {
DuplicateMasterListException ex = new DuplicateMasterListException();
ex.setGeoObjectType(universal.getDisplayLabel().getValue());
throw ex;
}
}
list.apply();
return list;
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class MasterList method getJobs.
public List<MasterListJob> getJobs() {
MasterListJobQuery query = new MasterListJobQuery(new QueryFactory());
query.WHERE(query.getMasterList().EQ(this));
try (OIterator<? extends MasterListJob> it = query.getIterator()) {
return new LinkedList<MasterListJob>(it.getAll());
}
}
Aggregations