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