Search in sources :

Example 56 with Endpoint

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

the class RegistryController method removeChild.

/**
 * Removes a relationship between @parentUid and @childUid.
 *
 * @pre Both the parent and child have already been persisted / applied
 * @post A relationship will not exist between @parent and @child
 *
 * @returns
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_REMOVE_CHILD)
public ResponseIF removeChild(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENTCODE, required = true) String parentCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENT_TYPE_CODE, required = true) String parentTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_CHILDCODE, required = true) String childCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_CHILD_TYPE_CODE, required = true) String childTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_HIERARCHY_CODE, required = true) String hierarchyRef, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_START_DATE) String startDateString, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_END_DATE) 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;
    ServiceFactory.getGeoObjectService().removeChild(request.getSessionId(), parentCode, parentTypeCode, childCode, childTypeCode, hierarchyRef, startDate, endDate);
    return new RestResponse();
}
Also used : RestResponse(com.runwaysdk.mvc.RestResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 57 with Endpoint

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

the class RegistryController method removeFromHierarchy.

/**
 * Removes the {@link GeoObjectType} with the given child code from 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.GET, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_REMOVE)
public ResponseIF removeFromHierarchy(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().removeFromHierarchy(request.getSessionId(), hierarchyCode, parentGeoObjectTypeCode, childGeoObjectTypeCode, true);
    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 58 with Endpoint

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

the class RegistryController method addChild.

/**
 * Creates a relationship between @parentUid and @childUid.
 *
 * @pre Both the parent and child have already been persisted / applied
 * @post A relationship will exist between @parent and @child
 *
 * @returns ParentTreeNode The new node which was created with the provided
 *          parent.
 * @param startDate TODO
 * @param endDate TODO
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_ADD_CHILD)
public ResponseIF addChild(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENTCODE, required = true) String parentCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_PARENT_TYPE_CODE, required = true) String parentTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_CHILDCODE, required = true) String childCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_CHILD_TYPE_CODE, required = true) String childTypeCode, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_HIERARCHY_CODE, required = true) String hierarchyRef, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_START_DATE) String startDateString, @RequestParamter(name = RegistryUrls.GEO_OBJECT_ADD_CHILD_PARAM_END_DATE) 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;
    ParentTreeNode pn = ServiceFactory.getGeoObjectService().addChild(request.getSessionId(), parentCode, parentTypeCode, childCode, childTypeCode, hierarchyRef, startDate, endDate);
    return new RestBodyResponse(pn.toJSON());
}
Also used : ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 59 with Endpoint

use of com.runwaysdk.mvc.Endpoint 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 60 with Endpoint

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

Aggregations

Endpoint (com.runwaysdk.mvc.Endpoint)68 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)21 JsonObject (com.google.gson.JsonObject)19 JsonArray (com.google.gson.JsonArray)16 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JSONArray (org.json.JSONArray)11 JSONObject (org.json.JSONObject)11 RestResponse (com.runwaysdk.mvc.RestResponse)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 SimpleDateFormat (java.text.SimpleDateFormat)6 InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)5 InputStream (java.io.InputStream)5 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)5 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 Locale (java.util.Locale)3 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3