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);
}
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));
}
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);
}
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);
}
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);
}
Aggregations