use of com.runwaysdk.query.OIterator in project geoprism-registry by terraframe.
the class BusinessType method getAll.
public static JsonArray getAll() {
JsonArray response = new JsonArray();
Organization.getOrganizations().stream().filter(o -> Organization.isMember(o)).forEach(org -> {
BusinessTypeQuery query = new BusinessTypeQuery(new QueryFactory());
query.WHERE(query.getOrganization().EQ(org));
query.ORDER_BY_DESC(query.getDisplayLabel().localize());
try (OIterator<? extends BusinessType> it = query.getIterator()) {
while (it.hasNext()) {
BusinessType type = it.next();
response.add(type.toJSON());
}
}
});
return response;
}
use of com.runwaysdk.query.OIterator in project geoprism-registry by terraframe.
the class ListType method listForType.
public static JsonObject listForType(String typeCode) {
ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
Organization org = type.getOrganization();
final boolean isMember = Organization.isMember(org);
ListTypeQuery query = new ListTypeQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(type.getUniversal()));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
final JsonArray lists = new JsonArray();
try (OIterator<? extends ListType> it = query.getIterator()) {
it.getAll().stream().sorted((a, b) -> {
return a.getDisplayLabel().getValue().compareTo(b.getDisplayLabel().getValue());
}).filter(f -> {
return true;
}).forEach(list -> {
// 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()));
// object.addProperty("write", list.doesActorHaveWritePermission());
// object.addProperty("read", list.doesActorHaveReadPermission());
//
lists.add(list.toJSON());
});
}
JsonObject object = new JsonObject();
object.addProperty("orgCode", org.getCode());
object.addProperty("orgLabel", org.getDisplayLabel().getValue());
object.addProperty("typeCode", type.getCode());
object.addProperty("typeLabel", type.getLabel().getValue());
object.addProperty("geometryType", type.getGeometryType().name());
object.addProperty("write", doesActorHaveWritePermissions(type));
object.add("lists", lists);
return object;
}
use of com.runwaysdk.query.OIterator in project geoprism-registry by terraframe.
the class ListType method list.
public static JsonArray list() {
JsonArray response = new JsonArray();
ListTypeQuery query = new ListTypeQuery(new QueryFactory());
try (OIterator<? extends ListType> it = query.getIterator()) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
it.getAll().stream().filter(list -> list.doesActorHaveReadPermission()).sorted((a, b) -> {
return a.getDisplayLabel().getValue().compareTo(b.getDisplayLabel().getValue());
}).forEach(list -> {
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);
});
}
return response;
}
use of com.runwaysdk.query.OIterator in project geoprism-registry by terraframe.
the class ETLService method getActiveImports.
@Request(RequestType.SESSION)
public JsonObject getActiveImports(String sessionId, int pageSize, int pageNumber, String sortAttr, boolean isAscending) {
JsonArray ja = new JsonArray();
QueryFactory qf = new QueryFactory();
ImportHistoryQuery ihq = new ImportHistoryQuery(qf);
ihq.WHERE(ihq.getStatus().containsExactly(AllJobStatus.RUNNING).OR(ihq.getStatus().containsExactly(AllJobStatus.NEW)).OR(ihq.getStatus().containsExactly(AllJobStatus.QUEUED)).OR(ihq.getStatus().containsExactly(AllJobStatus.FEEDBACK)));
this.filterHistoryQueryBasedOnPermissions(ihq);
ihq.restrictRows(pageSize, pageNumber);
ihq.ORDER_BY(ihq.get(sortAttr), isAscending ? SortOrder.ASC : SortOrder.DESC);
try (OIterator<? extends ImportHistory> it = ihq.getIterator()) {
List<JsonWrapper> results = it.getAll().stream().map(hist -> {
DataImportJob job = (DataImportJob) hist.getAllJob().getAll().get(0);
GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
return new JsonWrapper(serializeHistory(hist, user, job));
}).collect(Collectors.toList());
return new Page<JsonWrapper>(ihq.getCount(), ihq.getPageNumber(), ihq.getPageSize(), results).toJSON();
}
}
use of com.runwaysdk.query.OIterator 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();
}
}
Aggregations