Search in sources :

Example 1 with OrganizationDTO

use of org.commongeoregistry.adapter.metadata.OrganizationDTO in project geoprism-registry by terraframe.

the class RegistryController method getOrganizations.

/**
 * 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 = "organizations/get-all", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getOrganizations(ClientRequestIF request) throws ParseException {
    OrganizationDTO[] orgs = this.registryService.getOrganizations(request.getSessionId(), null);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonArray orgsJson = new JsonArray();
    for (OrganizationDTO org : orgs) {
        orgsJson.add(org.toJSON(serializer));
    }
    return new RestBodyResponse(orgsJson);
}
Also used : JsonArray(com.google.gson.JsonArray) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 2 with OrganizationDTO

use of org.commongeoregistry.adapter.metadata.OrganizationDTO in project geoprism-registry by terraframe.

the class RegistryController method updateOrganization.

/**
 * Update organization.
 *
 * @param sessionId
 * @param json
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "orgainization/update")
public ResponseIF updateOrganization(ClientRequestIF request, @RequestParamter(name = "json", required = true) String json) {
    OrganizationDTO org = this.registryService.updateOrganization(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 3 with OrganizationDTO

use of org.commongeoregistry.adapter.metadata.OrganizationDTO in project geoprism-registry by terraframe.

the class RegistryService method updateOrganization.

/**
 * Updates the given {@link OrganizationDTO} represented as JSON.
 *
 * @pre given {@link OrganizationDTO} must already exist.
 *
 * @param sessionId
 * @param json
 *          JSON of the {@link OrganizationDTO} to be updated.
 * @return updated {@link OrganizationDTO}
 */
@Request(RequestType.SESSION)
public OrganizationDTO updateOrganization(String sessionId, String json) {
    OrganizationDTO organizationDTO = OrganizationDTO.fromJSON(json);
    final Organization org = new OrganizationConverter().update(organizationDTO);
    // If this did not error out then add to the cache
    ServiceFactory.getMetadataCache().addOrganization(org);
    return ServiceFactory.getAdapter().getMetadataCache().getOrganization(org.getCode()).get();
}
Also used : Organization(net.geoprism.registry.Organization) OrganizationDTO(org.commongeoregistry.adapter.metadata.OrganizationDTO) OrganizationConverter(net.geoprism.registry.conversion.OrganizationConverter) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 4 with OrganizationDTO

use of org.commongeoregistry.adapter.metadata.OrganizationDTO 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 5 with OrganizationDTO

use of org.commongeoregistry.adapter.metadata.OrganizationDTO 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

OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)9 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)5 Endpoint (com.runwaysdk.mvc.Endpoint)4 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)4 Request (com.runwaysdk.session.Request)4 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)4 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)2 Organization (net.geoprism.registry.Organization)2 OrganizationConverter (net.geoprism.registry.conversion.OrganizationConverter)2 LinkedList (java.util.LinkedList)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1 ExternalSystemService (net.geoprism.registry.service.ExternalSystemService)1 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)1 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)1 HierarchyNode (org.commongeoregistry.adapter.metadata.HierarchyNode)1 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)1