use of com.runwaysdk.session.Request 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.session.Request in project geoprism-registry by terraframe.
the class CreateEventSequencePatch method doIt.
@Request
private void doIt() {
StringBuilder statement = new StringBuilder();
statement.append("CREATE SEQUENCE " + TransitionEvent.EVENT_SEQUENCE + " TYPE ORDERED");
GraphDBService service = GraphDBService.getInstance();
GraphRequest graphRequest = service.getGraphDBRequest();
service.command(graphRequest, statement.toString(), new HashedMap<>());
}
use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.
the class CurationService method curate.
@Request(RequestType.SESSION)
public JsonObject curate(String sessionId, String listTypeVersionId) {
final ListTypeVersion version = ListTypeVersion.get(listTypeVersionId);
final ListType listType = version.getListType();
final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
final String orgCode = listType.getOrganization().getCode();
this.checkPermissions(orgCode, serverGOT);
ListCurationJob job = new ListCurationJob();
job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
job.apply();
ListCurationHistory history = job.start(version);
return this.serializeHistory(history, GeoprismUser.get(job.getRunAsUser().getOid()), job);
}
use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.
the class ChangeRequestTestDataGenerator method deleteAllChangeRequests.
@Request
public static void deleteAllChangeRequests() {
ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
OIterator<? extends ChangeRequest> it = crq.getIterator();
while (it.hasNext()) {
it.next().delete();
}
}
use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.
the class DHIS2FeatureService method getSystemCapabilities.
@Request(RequestType.SESSION)
public JsonObject getSystemCapabilities(String sessionId, String systemJSON) {
JsonObject capabilities = new JsonObject();
JsonObject jo = JsonParser.parseString(systemJSON).getAsJsonObject();
ExternalSystem system = ExternalSystem.desieralize(jo);
if (system instanceof DHIS2ExternalSystem) {
DHIS2ExternalSystem dhis2System = (DHIS2ExternalSystem) system;
DHIS2TransportServiceIF dhis2 = getTransportService(dhis2System);
String version = dhis2.getVersionRemoteServer();
if (ArrayUtils.contains(DHIS2FeatureService.OAUTH_INCOMPATIBLE_VERSIONS, version)) {
capabilities.addProperty("oauth", false);
} else {
capabilities.addProperty("oauth", true);
}
} else if (system instanceof FhirExternalSystem) {
capabilities.addProperty("oauth", true);
} else {
capabilities.addProperty("oauth", false);
}
return capabilities;
}
Aggregations