Search in sources :

Example 6 with CorrespondencePartUnit

use of nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartService method updateCorrespondencePartUnit.

@Override
public CorrespondencePartUnit updateCorrespondencePartUnit(String systemId, Long version, CorrespondencePartUnit incomingCorrespondencePart) {
    CorrespondencePartUnit existingCorrespondencePart = (CorrespondencePartUnit) getCorrespondencePartOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    existingCorrespondencePart.setBusinessAddress(incomingCorrespondencePart.getBusinessAddress());
    existingCorrespondencePart.setPostalAddress(incomingCorrespondencePart.getPostalAddress());
    existingCorrespondencePart.setContactInformation(incomingCorrespondencePart.getContactInformation());
    existingCorrespondencePart.setContactPerson(incomingCorrespondencePart.getContactPerson());
    existingCorrespondencePart.setOrganisationNumber(incomingCorrespondencePart.getOrganisationNumber());
    existingCorrespondencePart.setName(incomingCorrespondencePart.getName());
    existingCorrespondencePart.setVersion(version);
    correspondencePartRepository.save(existingCorrespondencePart);
    return existingCorrespondencePart;
}
Also used : CorrespondencePartUnit(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)

Example 7 with CorrespondencePartUnit

use of nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartHateoasController method findOneCorrespondencePartUnitBySystemId.

// Get a CorrespondencePartPerson identified by systemID
// GET [contextPath][api]/casehandling/korrespondansepartenhet/{systemId}
@ApiOperation(value = "Retrieves a single CorrespondencePartUnit entity given a systemId", response = CorrespondencePartUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartUnit returned", response = CorrespondencePartUnit.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_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CorrespondencePartUnitHateoas> findOneCorrespondencePartUnitBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the correspondencePartUnit to retrieve", required = true) @PathVariable("systemID") final String correspondencePartUnitSystemId) {
    CorrespondencePartUnit correspondencePartUnit = (CorrespondencePartUnit) correspondencePartService.findBySystemIdOrderBySystemId(correspondencePartUnitSystemId);
    CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(correspondencePartUnit);
    correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartUnit.getVersion().toString()).body(correspondencePartUnitHateoas);
}
Also used : CorrespondencePartUnitHateoas(nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CorrespondencePartUnit(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 8 with CorrespondencePartUnit

use of nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryHateoasController method getCorrespondencePartUnitTemplate.

// Create a suggested CorrespondencePartUnit (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartenhet
@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 = CorrespondencePartUnitHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartUnitHateoas.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_UNIT })
public ResponseEntity<CorrespondencePartUnitHateoas> getCorrespondencePartUnitTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartUnit suggestedCorrespondencePart = new CorrespondencePartUnit();
    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: 744 Evergreen Terrace");
    postalAddress.setAddressLine2("ADRL2: 744 Evergreen Terrace");
    postalAddress.setAddressLine3("ADRL3: 744 Evergreen Terrace");
    postalAddress.setCountryCode("US");
    postalAddress.setPostalNumber(new PostalNumber("12345"));
    postalAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setPostalAddress(postalAddress);
    BusinessAddress businessAddress = new BusinessAddress();
    businessAddress.setAddressType(BUSINESS_ADDRESS);
    businessAddress.setAddressLine1("ADRL1: 745 Evergreen Terrace");
    businessAddress.setAddressLine2("ADRL2: 745 Evergreen Terrace");
    businessAddress.setAddressLine3("ADRL3: 745 Evergreen Terrace");
    businessAddress.setCountryCode("US");
    businessAddress.setPostalNumber(new PostalNumber("12345"));
    businessAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setBusinessAddress(businessAddress);
    suggestedCorrespondencePart.setContactPerson("Frank Contact Person Grimes");
    ContactInformation contactInformation = new ContactInformation();
    contactInformation.setEmailAddress("nikita@example.com");
    contactInformation.setMobileTelephoneNumber("123456789");
    contactInformation.setTelephoneNumber("987654321");
    suggestedCorrespondencePart.setContactInformation(contactInformation);
    suggestedCorrespondencePart.setName("Frank Grimes");
    CorrespondencePartUnitHateoas correspondencePartHateoas = new CorrespondencePartUnitHateoas(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

CorrespondencePartUnit (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)6 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 CorrespondencePartUnitHateoas (nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 RegistryEntry (nikita.model.noark5.v4.casehandling.RegistryEntry)1 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)1 NikitaException (nikita.util.exceptions.NikitaException)1 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)1 AfterNoarkEntityUpdatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1