Search in sources :

Example 71 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class SynchronizationConfigService method remove.

@Request(RequestType.SESSION)
public void remove(String sessionId, String oid) {
    SynchronizationConfig config = SynchronizationConfig.get(oid);
    Organization organization = config.getOrganization();
    ServiceFactory.getRolePermissionService().enforceRA(organization.getCode());
    config.delete();
}
Also used : Organization(net.geoprism.registry.Organization) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) Request(com.runwaysdk.session.Request)

Example 72 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class SynchronizationConfigService method run.

@Request(RequestType.SESSION)
public JsonObject run(String sessionId, String oid) {
    SynchronizationConfig config = SynchronizationConfig.get(oid);
    ServiceFactory.getRolePermissionService().enforceRA(config.getOrganization().getCode());
    List<? extends DataExportJob> jobs = config.getJobs();
    DataExportJob job = jobs.get(0);
    job.appLock();
    job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
    job.apply();
    ExportHistory hist = job.start(config);
    GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
    return serializeHistory(hist, user, job);
}
Also used : ExportHistory(net.geoprism.registry.etl.export.ExportHistory) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) GeoprismUser(net.geoprism.GeoprismUser) DataExportJob(net.geoprism.registry.etl.export.DataExportJob) Request(com.runwaysdk.session.Request)

Example 73 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class SynchronizationConfigService method edit.

@Request(RequestType.SESSION)
public JsonObject edit(String sessionId, String oid) {
    JsonObject response = new JsonObject();
    if (oid != null && oid.length() > 0) {
        SynchronizationConfig config = SynchronizationConfig.lock(oid);
        response.add("config", config.toJSON());
    }
    JsonArray orgs = new JsonArray();
    List<Organization> organizations = Organization.getUserAdminOrganizations();
    for (Organization organization : organizations) {
        JsonArray hierarchies = new JsonArray();
        List<ServerHierarchyType> sHierachies = ServerHierarchyType.getForOrganization(organization);
        for (ServerHierarchyType hierarchy : sHierachies) {
            JsonObject object = new JsonObject();
            object.addProperty("label", hierarchy.getDisplayLabel().getValue());
            object.addProperty("code", hierarchy.getCode());
            hierarchies.add(object);
        }
        JsonArray systems = new JsonArray();
        List<ExternalSystem> esystems = ExternalSystem.getForOrganization(organization);
        for (ExternalSystem system : esystems) {
            if (system.isExportSupported()) {
                LocalizedValue label = LocalizedValueConverter.convert(system.getEmbeddedComponent(ExternalSystem.LABEL));
                JsonObject object = new JsonObject();
                object.addProperty("label", label.getValue());
                object.addProperty("oid", system.getOid());
                object.addProperty("type", system.getMdClass().getTypeName());
                systems.add(object);
            }
        }
        JsonObject object = new JsonObject();
        object.addProperty("label", organization.getDisplayLabel().getValue());
        object.addProperty("code", organization.getCode());
        object.add("hierarchies", hierarchies);
        object.add("systems", systems);
        orgs.add(object);
    }
    response.add("orgs", orgs);
    return response;
}
Also used : JsonArray(com.google.gson.JsonArray) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Organization(net.geoprism.registry.Organization) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) JsonObject(com.google.gson.JsonObject) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) Request(com.runwaysdk.session.Request)

Example 74 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class UndirectedGraphTypeService method create.

@Request(RequestType.SESSION)
public JsonObject create(String sessionId, String json) {
    JsonObject object = JsonParser.parseString(json).getAsJsonObject();
    UndirectedGraphType type = UndirectedGraphType.create(object);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    return type.toJSON();
}
Also used : JsonObject(com.google.gson.JsonObject) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 75 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class UndirectedGraphTypeService method remove.

@Request(RequestType.SESSION)
public void remove(String sessionId, String code) {
    UndirectedGraphType type = UndirectedGraphType.getByCode(code);
    type.delete();
}
Also used : UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) 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