Search in sources :

Example 46 with RestBodyResponse

use of com.runwaysdk.mvc.RestBodyResponse 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 47 with RestBodyResponse

use of com.runwaysdk.mvc.RestBodyResponse 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 48 with RestBodyResponse

use of com.runwaysdk.mvc.RestBodyResponse 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 49 with RestBodyResponse

use of com.runwaysdk.mvc.RestBodyResponse 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)

Example 50 with RestBodyResponse

use of com.runwaysdk.mvc.RestBodyResponse in project geoprism-registry by terraframe.

the class TermController method getClassifierSuggestions.

@Endpoint(error = ErrorSerialization.JSON)
public ResponseIF getClassifierSuggestions(ClientRequestIF request, @RequestParamter(name = "mdAttributeId", required = true) String mdAttributeId, @RequestParamter(name = "text") String text, @RequestParamter(name = "limit") Integer limit) throws JSONException {
    JSONArray response = new JSONArray();
    ValueQueryDTO query = ClassifierDTO.getClassifierSuggestions(request, mdAttributeId, text, limit);
    List<ValueObjectDTO> results = query.getResultSet();
    for (ValueObjectDTO result : results) {
        JSONObject object = new JSONObject();
        object.put("label", result.getValue(ClassifierDTO.DISPLAYLABEL));
        object.put("value", result.getValue(ClassifierDTO.OID));
        response.put(object);
    }
    return new RestBodyResponse(response);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ValueQueryDTO(com.runwaysdk.business.ValueQueryDTO) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) ValueObjectDTO(com.runwaysdk.business.ValueObjectDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)53 Endpoint (com.runwaysdk.mvc.Endpoint)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)16 JsonObject (com.google.gson.JsonObject)14 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JsonArray (com.google.gson.JsonArray)10 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 JSONArray (org.json.JSONArray)7 JSONObject (org.json.JSONObject)7 SimpleDateFormat (java.text.SimpleDateFormat)5 InputStream (java.io.InputStream)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)3 PermissionContext (net.geoprism.registry.permission.PermissionContext)2 TreeNode (org.commongeoregistry.adapter.dataaccess.TreeNode)2 ValueObjectDTO (com.runwaysdk.business.ValueObjectDTO)1