Search in sources :

Example 1 with CorrespondencePartPersonHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartHateoasController method findOneCorrespondencePartPersonBySystemId.

// API - All GET Requests (CRUD - READ)
// Get a CorrespondencePartPerson identified by systemID
// GET [contextPath][api]/casehandling/korrespondansepartperson/{systemId}
@ApiOperation(value = "Retrieves a single CorrespondencePartPerson entity given a systemId", response = CorrespondencePartPerson.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartPerson returned", response = CorrespondencePartPerson.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_PERSON + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CorrespondencePartPersonHateoas> findOneCorrespondencePartPersonBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the correspondencePartPerson to retrieve", required = true) @PathVariable("systemID") final String correspondencePartPersonSystemId) {
    CorrespondencePartPerson correspondencePartPerson = (CorrespondencePartPerson) correspondencePartService.findBySystemIdOrderBySystemId(correspondencePartPersonSystemId);
    CorrespondencePartPersonHateoas correspondencePartPersonHateoas = new CorrespondencePartPersonHateoas(correspondencePartPerson);
    correspondencePartHateoasHandler.addLinks(correspondencePartPersonHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartPerson.getVersion().toString()).body(correspondencePartPersonHateoas);
}
Also used : CorrespondencePartPerson(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson) CorrespondencePartPersonHateoas(nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with CorrespondencePartPersonHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartHateoasController method updateCorrespondencePartPerson.

// Update a CorrespondencePartPerson with given values
// PUT [contextPath][api]/casehandling/korrespondansepartperson/{systemId}
@ApiOperation(value = "Updates a CorrespondencePartPerson identified by a given systemId", notes = "Returns the newly updated correspondencePartPerson", response = CorrespondencePartPersonHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartPerson " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartPersonHateoas.class), @ApiResponse(code = 201, message = "CorrespondencePartPerson " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartPersonHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type CorrespondencePartPerson"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_PERSON + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CorrespondencePartPersonHateoas> updateCorrespondencePartPerson(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of correspondencePartPerson to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CorrespondencePartPerson", value = "Incoming correspondencePartPerson object", required = true) @RequestBody CorrespondencePartPerson correspondencePartPerson) throws NikitaException {
    validateForUpdate(correspondencePartPerson);
    CorrespondencePartPerson updatedCorrespondencePartPerson = correspondencePartService.updateCorrespondencePartPerson(systemID, parseETAG(request.getHeader(ETAG)), correspondencePartPerson);
    CorrespondencePartPersonHateoas correspondencePartPersonHateoas = new CorrespondencePartPersonHateoas(updatedCorrespondencePartPerson);
    correspondencePartHateoasHandler.addLinks(correspondencePartPersonHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCorrespondencePartPerson));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCorrespondencePartPerson.getVersion().toString()).body(correspondencePartPersonHateoas);
}
Also used : CorrespondencePartPerson(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson) CorrespondencePartPersonHateoas(nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) AfterNoarkEntityUpdatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with CorrespondencePartPersonHateoas

use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryHateoasController method getCorrespondencePartPersonTemplate.

// Create a suggested CorrespondencePartPerson (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartperson
@ApiOperation(value = "Suggests the contents of a new CorrespondencePart object", notes = "Returns a pre-filled CorrespondencePart object" + " with values relevant for the logged-in user", response = CorrespondencePartPersonHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartPersonHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_PERSON })
public ResponseEntity<CorrespondencePartPersonHateoas> getCorrespondencePartPersonTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartPerson suggestedCorrespondencePart = new CorrespondencePartPerson();
    CorrespondencePartType correspondencePartType = correspondencePartTypeService.findByCode(CORRESPONDENCE_PART_CODE_EA);
    if (correspondencePartType == null) {
        throw new NikitaException("Internal error, metadata missing. [" + CORRESPONDENCE_PART_CODE_EA + "] returns no value");
    }
    suggestedCorrespondencePart.setCorrespondencePartType(correspondencePartType);
    PostalAddress postalAddress = new PostalAddress();
    postalAddress.setAddressType(POSTAL_ADDRESS);
    postalAddress.setAddressLine1("ADRL1: 742 Evergreen Terrace");
    postalAddress.setAddressLine2("ADRL2: 742 Evergreen Terrace");
    postalAddress.setAddressLine3("ADRL3: 742 Evergreen Terrace");
    postalAddress.setCountryCode("US");
    postalAddress.setPostalNumber(new PostalNumber("12345"));
    postalAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setPostalAddress(postalAddress);
    ResidingAddress residingAddress = new ResidingAddress();
    residingAddress.setAddressType(RESIDING_ADDRESS);
    residingAddress.setAddressLine1("ADRL1: 743 Evergreen Terrace");
    residingAddress.setAddressLine2("ADRL2: 743 Evergreen Terrace");
    residingAddress.setAddressLine3("ADRL3: 743 Evergreen Terrace");
    residingAddress.setCountryCode("US");
    residingAddress.setPostalNumber(new PostalNumber("12345"));
    residingAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setResidingAddress(residingAddress);
    suggestedCorrespondencePart.setSocialSecurityNumber("09088512345");
    suggestedCorrespondencePart.setdNumber("dddddd1234");
    ContactInformation contactInformation = new ContactInformation();
    contactInformation.setEmailAddress("nikita@example.com");
    contactInformation.setMobileTelephoneNumber("123456789");
    contactInformation.setTelephoneNumber("987654321");
    suggestedCorrespondencePart.setContactInformation(contactInformation);
    suggestedCorrespondencePart.setName("Frank Grimes");
    CorrespondencePartPersonHateoas correspondencePartHateoas = new CorrespondencePartPersonHateoas(suggestedCorrespondencePart);
    correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(correspondencePartHateoas);
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)3 Timed (com.codahale.metrics.annotation.Timed)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)3 CorrespondencePartPerson (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)2 CorrespondencePartPersonHateoas (nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas)2 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)1 NikitaException (nikita.util.exceptions.NikitaException)1 AfterNoarkEntityUpdatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1