use of net.geoprism.registry.view.JsonWrapper 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 net.geoprism.registry.view.JsonWrapper 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 net.geoprism.registry.view.JsonWrapper in project geoprism-registry by terraframe.
the class SynchronizationConfigService method getJobs.
@Request(RequestType.SESSION)
public JsonObject getJobs(String sessionId, String configId, Integer pageSize, Integer pageNumber) {
QueryFactory qf = new QueryFactory();
DataExportJobQuery jQuery = new DataExportJobQuery(qf);
jQuery.WHERE(jQuery.getConfig().EQ(configId));
ExportHistoryQuery ihq = new ExportHistoryQuery(qf);
ihq.WHERE(ihq.job(jQuery));
ihq.restrictRows(pageSize, pageNumber);
ihq.ORDER_BY_DESC(ihq.getCreateDate());
try (OIterator<? extends ExportHistory> it = ihq.getIterator()) {
LinkedList<JsonWrapper> results = new LinkedList<JsonWrapper>();
while (it.hasNext()) {
ExportHistory hist = it.next();
DataExportJob job = (DataExportJob) hist.getAllJob().getAll().get(0);
GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
results.add(new JsonWrapper(serializeHistory(hist, user, job)));
}
return new Page<JsonWrapper>(ihq.getCount(), pageNumber, pageSize, results).toJSON();
}
}
use of net.geoprism.registry.view.JsonWrapper in project geoprism-registry by terraframe.
the class ETLService method getCompletedImports.
@Request(RequestType.SESSION)
public JsonObject getCompletedImports(String sessionId, int pageSize, int pageNumber, String sortAttr, boolean isAscending) {
QueryFactory qf = new QueryFactory();
ImportHistoryQuery ihq = new ImportHistoryQuery(qf);
ihq.WHERE(ihq.getStatus().containsExactly(AllJobStatus.SUCCESS).OR(ihq.getStatus().containsExactly(AllJobStatus.FAILURE)).OR(ihq.getStatus().containsExactly(AllJobStatus.CANCELED)));
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();
}
}
Aggregations