Search in sources :

Example 21 with CustomSerializer

use of org.commongeoregistry.adapter.metadata.CustomSerializer in project geoprism-registry by terraframe.

the class RegistryController method submitNewOrganization.

/**
 * Submit new organization.
 *
 * @param sessionId
 * @param json
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "orgainization/create")
public ResponseIF submitNewOrganization(ClientRequestIF request, @RequestParamter(name = "json", required = true) String json) {
    OrganizationDTO org = this.registryService.createOrganization(request.getSessionId(), json);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(org.toJSON(serializer));
}
Also used : CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 22 with CustomSerializer

use of org.commongeoregistry.adapter.metadata.CustomSerializer in project geoprism-registry by terraframe.

the class RegistryController method initSettings.

@Endpoint(url = "init-settings", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF initSettings(ClientRequestIF request) throws ParseException {
    OrganizationDTO[] orgs = this.registryService.getOrganizations(request.getSessionId(), null);
    JsonArray jaLocales = this.registryService.getLocales(request.getSessionId());
    JsonObject esPage = new ExternalSystemService().page(request.getSessionId(), 1, 10);
    JsonObject sraPage = JsonParser.parseString(AccountService.getInstance().getSRAs(request.getSessionId(), 1, 10)).getAsJsonObject();
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonObject settingsView = new JsonObject();
    JsonArray orgsJson = new JsonArray();
    for (OrganizationDTO org : orgs) {
        orgsJson.add(org.toJSON(serializer));
    }
    settingsView.add("organizations", orgsJson);
    settingsView.add("locales", jaLocales);
    settingsView.add("externalSystems", esPage);
    settingsView.add("sras", sraPage);
    return new RestBodyResponse(settingsView);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) ExternalSystemService(net.geoprism.registry.service.ExternalSystemService) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 23 with CustomSerializer

use of org.commongeoregistry.adapter.metadata.CustomSerializer in project geoprism-registry by terraframe.

the class RegistryController method addToHierarchy.

/**
 * Adds the {@link GeoObjectType} with the given child code to the parent
 * {@link GeoObjectType} with the given code for the given
 * {@link HierarchyType} code.
 *
 * @param sessionId
 * @param hierarchyCode
 *          code of the {@link HierarchyType} the child is being added to.
 * @param parentGeoObjectTypeCode
 *          parent {@link GeoObjectType}.
 * @param childGeoObjectTypeCode
 *          child {@link GeoObjectType}.
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_ADD)
public ResponseIF addToHierarchy(ClientRequestIF request, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "parentGeoObjectTypeCode", required = true) String parentGeoObjectTypeCode, @RequestParamter(name = "childGeoObjectTypeCode", required = true) String childGeoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().addToHierarchy(request.getSessionId(), hierarchyCode, parentGeoObjectTypeCode, childGeoObjectTypeCode);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(ht.toJSON(serializer));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 24 with CustomSerializer

use of org.commongeoregistry.adapter.metadata.CustomSerializer in project geoprism-registry by terraframe.

the class RegistryController method getHierarchyTypes.

/**
 * Returns an array of {@link HierarchyType} that define the given list of
 * types. If no types are provided then all will be returned.
 *
 * @param types
 *          A serialized json array of HierarchyType codes that will be
 *          retrieved.
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_GET_ALL)
public ResponseIF getHierarchyTypes(ClientRequestIF request, @RequestParamter(name = "types") String types, @RequestParamter(name = "context") String context) {
    String[] aTypes = null;
    if (types != null) {
        JSONArray jaTypes = new JSONArray(types);
        aTypes = new String[jaTypes.length()];
        for (int i = 0; i < jaTypes.length(); i++) {
            aTypes[i] = jaTypes.getString(i);
        }
    }
    PermissionContext pContext = PermissionContext.get(context);
    HierarchyType[] hts = ServiceFactory.getHierarchyService().getHierarchyTypes(request.getSessionId(), aTypes, pContext);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonArray jarray = new JsonArray();
    for (int i = 0; i < hts.length; ++i) {
        jarray.add(hts[i].toJSON(serializer));
    }
    return new RestBodyResponse(jarray);
}
Also used : JsonArray(com.google.gson.JsonArray) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) JSONArray(org.json.JSONArray) PermissionContext(net.geoprism.registry.permission.PermissionContext) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 25 with CustomSerializer

use of org.commongeoregistry.adapter.metadata.CustomSerializer in project geoprism-registry by terraframe.

the class RegistryController method search.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobject/search")
public ResponseIF search(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARAM_TYPE_CODE, required = true) String typeCode, @RequestParamter(name = "text", required = true) String text, @RequestParamter(name = "date", required = true) String date) throws JSONException, ParseException {
    List<GeoObject> results = this.registryService.search(request.getSessionId(), typeCode, text, GeoRegistryUtil.parseDate(date, true));
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonArray response = new JsonArray();
    for (GeoObject result : results) {
        response.add(result.toJSON(serializer));
    }
    return new RestBodyResponse(response);
}
Also used : JsonArray(com.google.gson.JsonArray) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)29 Endpoint (com.runwaysdk.mvc.Endpoint)25 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)25 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)12 JsonArray (com.google.gson.JsonArray)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)7 JsonObject (com.google.gson.JsonObject)5 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)5 Request (com.runwaysdk.session.Request)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 Date (java.util.Date)2 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)2 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)2 JSONArray (org.json.JSONArray)2 Locale (java.util.Locale)1 BadServerUriException (net.geoprism.dhis2.dhis2adapter.exception.BadServerUriException)1 HTTPException (net.geoprism.dhis2.dhis2adapter.exception.HTTPException)1 InvalidLoginException (net.geoprism.dhis2.dhis2adapter.exception.InvalidLoginException)1 UnexpectedResponseException (net.geoprism.dhis2.dhis2adapter.exception.UnexpectedResponseException)1 OrganisationUnitGroup (net.geoprism.dhis2.dhis2adapter.response.model.OrganisationUnitGroup)1