use of com.runwaysdk.dataaccess.ValueObject 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;
}
use of com.runwaysdk.dataaccess.ValueObject in project geoprism-registry by terraframe.
the class UserInfo method serializePage.
private static JSONObject serializePage(Integer pageSize, Integer pageNumber, JSONArray externalSystems, ValueQuery vQuery) {
JSONArray results = new JSONArray();
OIterator<ValueObject> it = vQuery.getIterator(pageSize, pageNumber);
try {
while (it.hasNext()) {
ValueObject vObject = it.next();
JSONObject result = new JSONObject();
result.put(GeoprismUser.OID, vObject.getValue(GeoprismUser.OID));
result.put(GeoprismUser.USERNAME, vObject.getValue(GeoprismUser.USERNAME));
result.put(GeoprismUser.FIRSTNAME, vObject.getValue(GeoprismUser.FIRSTNAME));
result.put(GeoprismUser.LASTNAME, vObject.getValue(GeoprismUser.LASTNAME));
result.put(GeoprismUser.PHONENUMBER, vObject.getValue(GeoprismUser.PHONENUMBER));
result.put(GeoprismUser.EMAIL, vObject.getValue(GeoprismUser.EMAIL));
result.put(GeoprismUser.INACTIVE, AttributeBoolean.getBooleanValue((AttributeBooleanIF) vObject.getAttributeIF(GeoprismUser.INACTIVE)));
result.put(UserInfo.ALTFIRSTNAME, vObject.getValue(UserInfo.ALTFIRSTNAME));
result.put(UserInfo.ALTLASTNAME, vObject.getValue(UserInfo.ALTLASTNAME));
result.put(UserInfo.ALTPHONENUMBER, vObject.getValue(UserInfo.ALTPHONENUMBER));
result.put(UserInfo.POSITION, vObject.getValue(UserInfo.POSITION));
result.put(UserInfo.EXTERNALSYSTEMOID, vObject.getValue(UserInfo.EXTERNALSYSTEMOID));
results.put(result);
}
} finally {
it.close();
}
JSONObject page = new JSONObject();
page.put("resultSet", results);
page.put("count", vQuery.getCount());
page.put("pageNumber", pageNumber);
page.put("pageSize", pageSize);
page.put("externalSystems", externalSystems);
return page;
}
use of com.runwaysdk.dataaccess.ValueObject in project geoprism-registry by terraframe.
the class TaskService method getTasksForCurrentUser.
@Request(RequestType.SESSION)
public static JsonObject getTasksForCurrentUser(String sessionId, String orderBy, int pageNum, int pageSize, String whereStatus) {
QueryFactory qf = new QueryFactory();
ValueQuery vq = new ValueQuery(qf);
TaskHasRoleQuery thrq = new TaskHasRoleQuery(vq);
TaskQuery tq = new TaskQuery(vq);
vq.WHERE(thrq.getParent().EQ(tq));
if (whereStatus != null) {
vq.WHERE(tq.getStatus().EQ(whereStatus));
}
RolesQuery rq = new RolesQuery(vq);
vq.WHERE(thrq.getChild().EQ(rq));
Condition cond = null;
// Map<String, String> roles = Session.getCurrentSession().getUserRoles();
Set<RoleDAOIF> roles = Session.getCurrentSession().getUser().assignedRoles();
// for (String roleName : roles.keySet())
for (RoleDAOIF role : roles) {
String roleName = role.getRoleName();
if (roleName.equals(DefaultConfiguration.ADMIN)) {
continue;
}
if (cond == null) {
cond = rq.getRoleName().EQ(roleName);
} else {
cond = cond.OR(rq.getRoleName().EQ(roleName));
}
}
vq.WHERE(cond);
LocalizedValueStoreQuery lvsqTemplate = new LocalizedValueStoreQuery(vq);
vq.WHERE(tq.getTemplate().EQ(lvsqTemplate));
LocalizedValueStoreQuery lvsqTitle = new LocalizedValueStoreQuery(vq);
vq.WHERE(tq.getTitle().EQ(lvsqTitle));
vq.SELECT(tq.getOid("oid"));
vq.SELECT(lvsqTemplate.getStoreKey("templateKey"));
vq.SELECT(tq.getMessage().localize("msg"));
vq.SELECT(lvsqTitle.getStoreValue().localize("title"));
vq.SELECT(tq.getStatus("status"));
vq.SELECT(tq.getCreateDate("createDate"));
vq.SELECT(tq.getLastUpdateDate("completedDate"));
vq.ORDER_BY(tq.get(orderBy), SortOrder.DESC);
vq.restrictRows(pageSize, pageNum);
try (OIterator<ValueObject> it = vq.getIterator()) {
List<JsonWrapper> results = it.getAll().stream().map(vo -> {
JsonObject jo = new JsonObject();
jo.addProperty("id", vo.getValue("oid"));
jo.addProperty("templateKey", vo.getValue("templateKey"));
jo.addProperty("msg", vo.getValue("msg"));
jo.addProperty("title", vo.getValue("title"));
jo.addProperty("status", vo.getValue("status"));
jo.addProperty("createDate", ETLService.formatDate(MdAttributeDateTimeUtil.getTypeSafeValue(vo.getValue("createDate"))));
jo.addProperty("completedDate", vo.getValue("status").equals(TaskStatus.RESOLVED.name()) ? ETLService.formatDate(MdAttributeDateTimeUtil.getTypeSafeValue(vo.getValue("completedDate"))) : null);
return new JsonWrapper(jo);
}).collect(Collectors.toList());
return new Page<JsonWrapper>(vq.getCount(), pageNum, pageSize, results).toJSON();
}
}
use of com.runwaysdk.dataaccess.ValueObject 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.dataaccess.ValueObject 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;
}
Aggregations