use of com.runwaysdk.mvc.Endpoint 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.Endpoint 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.Endpoint 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.Endpoint in project geoprism-registry by terraframe.
the class RegistrySessionController method login.
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF login(ServletRequestIF req, @RequestParamter(name = "username", required = true) String username, @RequestParamter(name = "password", required = true) String password) throws JSONException {
if (username != null) {
username = username.trim();
}
Locale[] locales = this.getLocales(req);
// Locale sessionLocale = req.getLocale();
//
// JSONArray installedLocalesArr = new JSONArray();
// Collection<Locale> installedLocales = LocalizationFacade.getInstalledLocales();
// for (Locale loc : installedLocales)
// {
// JSONObject locObj = new JSONObject();
// locObj.put("language", loc.getDisplayLanguage(sessionLocale));
// locObj.put("country", loc.getDisplayCountry(sessionLocale));
// locObj.put("name", loc.getDisplayName(sessionLocale));
// locObj.put("variant", loc.getDisplayVariant(sessionLocale));
//
// installedLocalesArr.put(locObj);
// }
ClientRequestIF clientRequest = loginWithLocales(req, username, password, locales);
JSONArray jaLocales = new JSONArray(ServiceFactory.getRegistryService().getLocales(clientRequest.getSessionId()).toString());
JsonArray roles = JsonParser.parseString(RoleViewDTO.getCurrentRoles(clientRequest)).getAsJsonArray();
JsonArray roleDisplayLabels = JsonParser.parseString(RoleViewDTO.getCurrentRoleDisplayLabels(clientRequest)).getAsJsonArray();
JsonObject cookieValue = new JsonObject();
cookieValue.addProperty("loggedIn", clientRequest.isLoggedIn());
cookieValue.add("roles", roles);
cookieValue.add("roleDisplayLabels", roleDisplayLabels);
cookieValue.addProperty("userName", username);
cookieValue.addProperty("version", ClientConfigurationService.getServerVersion());
CookieResponse response = new CookieResponse("user", -1, cookieValue.toString());
response.set("installedLocales", jaLocales);
return response;
}
use of com.runwaysdk.mvc.Endpoint 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