Search in sources :

Example 1 with CorrespondencePartPerson

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

the class RegistryEntryService method createCorrespondencePartPersonAssociatedWithRegistryEntry.

@Override
public CorrespondencePartPerson createCorrespondencePartPersonAssociatedWithRegistryEntry(String systemID, CorrespondencePartPerson correspondencePart) {
    RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
    associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
    ContactInformation contactInformation = correspondencePart.getContactInformation();
    if (null != contactInformation) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
    }
    SimpleAddress postalAddress = correspondencePart.getPostalAddress();
    if (null != postalAddress) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
    }
    SimpleAddress residingAddress = correspondencePart.getResidingAddress();
    if (null != residingAddress) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(residingAddress);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(residingAddress);
    }
    NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
    NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
    // bidirectional relationship @ManyToMany, set both sides of relationship
    registryEntry.getReferenceCorrespondencePart().add(correspondencePart);
    correspondencePart.getReferenceRegistryEntry().add(registryEntry);
    return correspondencePartService.createNewCorrespondencePartPerson(correspondencePart);
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 2 with CorrespondencePartPerson

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

the class CorrespondencePartService method deleteCorrespondencePartPerson.

@Override
public void deleteCorrespondencePartPerson(@NotNull String code) {
    CorrespondencePartPerson correspondencePartPerson = (CorrespondencePartPerson) getCorrespondencePartOrThrow(code);
    correspondencePartRepository.delete(correspondencePartPerson);
}
Also used : CorrespondencePartPerson(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)

Example 3 with CorrespondencePartPerson

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson 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 4 with CorrespondencePartPerson

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson 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 5 with CorrespondencePartPerson

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

the class CorrespondencePartPersonDeserializer method deserialize.

@Override
public CorrespondencePartPerson deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    CorrespondencePartPerson correspondencePart = new CorrespondencePartPerson();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(correspondencePart, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseCorrespondencePartPersonEntity(correspondencePart, objectNode);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The korrespondansepartperson you tried to create is malformed. The " + "following fields are not recognised as korrespondansepartperson fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return correspondencePart;
}
Also used : CorrespondencePartPerson(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)7 ApiOperation (io.swagger.annotations.ApiOperation)7 ApiResponses (io.swagger.annotations.ApiResponses)7 CorrespondencePartPerson (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)6 Timed (com.codahale.metrics.annotation.Timed)4 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)4 CorrespondencePartPerson (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)3 Authorisation (nikita.webapp.security.Authorisation)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 CorrespondencePartPersonHateoas (nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas)2 ArrayList (java.util.ArrayList)1 Record (nikita.common.model.noark5.v4.Record)1 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)1 CorrespondencePartUnit (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)1 CorrespondencePartPersonHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CorrespondencePartPersonHateoas)1 CorrespondencePartUnitHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas)1 CorrespondencePartType (nikita.common.model.noark5.v4.metadata.CorrespondencePartType)1 NikitaException (nikita.common.util.exceptions.NikitaException)1 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)1 RegistryEntry (nikita.model.noark5.v4.casehandling.RegistryEntry)1