Search in sources :

Example 6 with Request

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();
    }
}
Also used : ValueQuery(com.runwaysdk.query.ValueQuery) Condition(com.runwaysdk.query.Condition) JsonObject(com.google.gson.JsonObject) SortOrder(com.runwaysdk.query.OrderBy.SortOrder) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) RequestType(com.runwaysdk.session.RequestType) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) Set(java.util.Set) ValueObject(com.runwaysdk.dataaccess.ValueObject) LocalizedValueStoreQuery(com.runwaysdk.localization.LocalizedValueStoreQuery) MdAttributeDateTimeUtil(com.runwaysdk.constants.MdAttributeDateTimeUtil) Collectors(java.util.stream.Collectors) Request(com.runwaysdk.session.Request) RolesQuery(com.runwaysdk.system.RolesQuery) DefaultConfiguration(net.geoprism.DefaultConfiguration) ETLService(net.geoprism.registry.etl.ETLService) OIterator(com.runwaysdk.query.OIterator) Page(net.geoprism.registry.view.Page) ValueQuery(com.runwaysdk.query.ValueQuery) List(java.util.List) Condition(com.runwaysdk.query.Condition) JsonWrapper(net.geoprism.registry.view.JsonWrapper) QueryFactory(com.runwaysdk.query.QueryFactory) Session(com.runwaysdk.session.Session) TaskStatus(net.geoprism.registry.task.Task.TaskStatus) QueryFactory(com.runwaysdk.query.QueryFactory) JsonObject(com.google.gson.JsonObject) JsonWrapper(net.geoprism.registry.view.JsonWrapper) RolesQuery(com.runwaysdk.system.RolesQuery) ValueObject(com.runwaysdk.dataaccess.ValueObject) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) LocalizedValueStoreQuery(com.runwaysdk.localization.LocalizedValueStoreQuery) Request(com.runwaysdk.session.Request)

Example 7 with Request

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<>());
}
Also used : GraphRequest(com.runwaysdk.dataaccess.graph.GraphRequest) GraphDBService(com.runwaysdk.dataaccess.graph.GraphDBService) GraphRequest(com.runwaysdk.dataaccess.graph.GraphRequest) Request(com.runwaysdk.session.Request)

Example 8 with Request

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);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Example 9 with Request

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 10 with Request

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;
}
Also used : DHIS2TransportServiceIF(net.geoprism.registry.etl.export.dhis2.DHIS2TransportServiceIF) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) JsonObject(com.google.gson.JsonObject) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)340 Test (org.junit.Test)145 JsonObject (com.google.gson.JsonObject)85 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)73 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)73 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)53 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)40 JsonArray (com.google.gson.JsonArray)36 Date (java.util.Date)33 ChangeRequest (net.geoprism.registry.action.ChangeRequest)32 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)31 QueryFactory (com.runwaysdk.query.QueryFactory)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)26 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)22 ListType (net.geoprism.registry.ListType)21 SimpleDateFormat (java.text.SimpleDateFormat)19 Classification (net.geoprism.registry.model.Classification)19 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)19 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17