Search in sources :

Example 1 with OrganizationConverter

use of net.geoprism.registry.conversion.OrganizationConverter 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 2 with OrganizationConverter

use of net.geoprism.registry.conversion.OrganizationConverter in project geoprism-registry by terraframe.

the class RegistryService method createOrganization.

/**
 * Creates a {@link OrganizationDTO} from the given JSON.
 *
 * @param sessionId
 * @param json
 *          JSON of the {@link OrganizationDTO} to be created.
 * @return newly created {@link OrganizationDTO}
 */
@Request(RequestType.SESSION)
public OrganizationDTO createOrganization(String sessionId, String json) {
    OrganizationDTO organizationDTO = OrganizationDTO.fromJSON(json);
    final Organization org = new OrganizationConverter().create(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)

Aggregations

Request (com.runwaysdk.session.Request)2 Organization (net.geoprism.registry.Organization)2 OrganizationConverter (net.geoprism.registry.conversion.OrganizationConverter)2 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)2 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)2