use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method getChildGeoObjects.
/**
* Get children of the given GeoObject
*
* @pre @post
*
* @param parentUid
* UID of the parent object for which the call fetches
* children. @param childrentTypes An array of GeoObjectType names of
* the types of children GeoObjects to fetch. If blank then return
* children of all types. @param recursive TRUE if recursive children
* of the given parent with the given types should be returned, FALSE
* if only single level children should be returned.
*
* @returns @throws
*/
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_GET_CHILDREN)
public ResponseIF getChildGeoObjects(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENTCODE, required = true) String parentCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_PARENT_TYPE_CODE, required = true) String parentTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_DATE, required = true) String date, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_CHILDREN_TYPES) String childrenTypes, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_CHILDREN_PARAM_RECURSIVE, required = true) Boolean recursive) {
String[] aChildTypes = null;
if (childrenTypes != null) {
JSONArray jaChildTypes = new JSONArray(childrenTypes);
aChildTypes = new String[jaChildTypes.length()];
for (int i = 0; i < jaChildTypes.length(); i++) {
aChildTypes[i] = jaChildTypes.getString(i);
}
}
TreeNode tn = this.registryService.getChildGeoObjects(request.getSessionId(), parentCode, parentTypeCode, aChildTypes, recursive, GeoRegistryUtil.parseDate(date, true));
return new RestBodyResponse(tn.toJSON());
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectSuggestions.
/**
* Returns an array of (label, entityId) pairs that under the given
* parent/hierarchy and have the given label.
*
* @throws ParseException
*
* @pre
* @post
*
* @returns @throws
*/
@Endpoint(url = "geoobject/suggestions", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getGeoObjectSuggestions(ClientRequestIF request, @RequestParamter(name = "text") String text, @RequestParamter(name = "type", required = true) String type, @RequestParamter(name = "parent") String parent, @RequestParamter(name = "parentTypeCode") String parentTypeCode, @RequestParamter(name = "hierarchy") String hierarchy, @RequestParamter(name = "startDate") String startDateString, @RequestParamter(name = "endDate") String endDateString) {
Date startDate = (startDateString != null && startDateString.length() > 0) ? GeoRegistryUtil.parseDate(startDateString, true) : null;
Date endDate = (endDateString != null && endDateString.length() > 0) ? GeoRegistryUtil.parseDate(endDateString, true) : null;
JsonArray response = this.registryService.getGeoObjectSuggestions(request.getSessionId(), text, type, parent, parentTypeCode, hierarchy, startDate, endDate);
return new RestBodyResponse(response);
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method updateGeoObject.
/**
* Update a new GeoObject in the Common Geo-Registry
*
* @pre
* @post
*
* @param geoObject
* in GeoJSON format to be updated.
* @throws ParseException
*
* @returns
* @throws //TODO
*/
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_UPDATE)
public ResponseIF updateGeoObject(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_UPDATE_PARAM_GEOOBJECT) String jGeoObj, @RequestParamter(name = "startDate") String startDateString, @RequestParamter(name = "endDate") String endDateString) throws ParseException {
Date startDate = (startDateString != null && startDateString.length() > 0) ? GeoRegistryUtil.parseDate(startDateString, true) : null;
Date endDate = (endDateString != null && endDateString.length() > 0) ? GeoRegistryUtil.parseDate(endDateString, true) : null;
GeoObject geoObject = this.registryService.updateGeoObject(request.getSessionId(), jGeoObj, startDate, endDate);
CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
return new RestBodyResponse(geoObject.toJSON(serializer));
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method manage.
@Endpoint(method = ServletMethod.GET)
public ResponseIF manage() {
ViewResponse resp = new ViewResponse(JSP_DIR + INDEX_JSP);
String customFont = GeoregistryProperties.getCustomFont();
if (customFont != null && customFont.length() > 0) {
resp.set("customFont", customFont);
}
return resp;
}
use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.
the class RegistryController method listGeoObjectTypes.
/**
* Returns an array of (label, code) pairs that define all of the geo object
* types in the system.
*
* @pre
* @post
*
* @returns @throws
*/
@Endpoint(url = "geoobjecttype/list-types", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF listGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = "includeAbstractTypes", required = true) Boolean includeAbstractTypes) {
GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), null, null, PermissionContext.READ);
Arrays.sort(gots, new Comparator<GeoObjectType>() {
@Override
public int compare(GeoObjectType o1, GeoObjectType o2) {
return o1.getLabel().getValue().compareTo(o2.getLabel().getValue());
}
});
JsonArray jarray = new JsonArray();
for (int i = 0; i < gots.length; ++i) {
GeoObjectType geoObjectType = gots[i];
if (!geoObjectType.getCode().equals("ROOT") && (includeAbstractTypes || !geoObjectType.getIsAbstract())) {
JsonObject type = new JsonObject();
type.addProperty("label", geoObjectType.getLabel().getValue());
type.addProperty("code", geoObjectType.getCode());
type.addProperty("orgCode", geoObjectType.getOrganizationCode());
type.addProperty("superTypeCode", geoObjectType.getSuperTypeCode());
jarray.add(type);
}
}
return new RestBodyResponse(jarray);
}
Aggregations