Search in sources :

Example 11 with CorrespondencePartUnit

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

the class CorrespondencePartUnitDeserializer method deserialize.

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

Example 12 with CorrespondencePartUnit

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

the class CorrespondencePartHateoasController method updateCorrespondencePartUnit.

// Update a CorrespondencePartUnit with given values
// PUT [contextPath][api]/casehandling/korrespondansepartenhet/{systemId}
@ApiOperation(value = "Updates a CorrespondencePartUnit identified by a given systemId", notes = "Returns the newly updated correspondencePartUnit", response = CorrespondencePartUnitHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartUnit " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartUnitHateoas.class), @ApiResponse(code = 201, message = "CorrespondencePartUnit " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartUnitHateoas.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 CorrespondencePartUnit"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = CORRESPONDENCE_PART_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CorrespondencePartUnitHateoas> updateCorrespondencePartUnit(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of correspondencePartUnit to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CorrespondencePartUnit", value = "Incoming correspondencePartUnit object", required = true) @RequestBody CorrespondencePartUnit correspondencePartUnit) throws NikitaException {
    validateForUpdate(correspondencePartUnit);
    CorrespondencePartUnit updatedCorrespondencePartUnit = correspondencePartService.updateCorrespondencePartUnit(systemID, parseETAG(request.getHeader(ETAG)), correspondencePartUnit);
    CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(updatedCorrespondencePartUnit);
    correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCorrespondencePartUnit));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCorrespondencePartUnit.getVersion().toString()).body(correspondencePartUnitHateoas);
}
Also used : CorrespondencePartUnitHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas) Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartUnit(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with CorrespondencePartUnit

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

the class CorrespondencePartUnitHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject correspondencePartHateoas, JsonGenerator jgen) throws IOException {
    CorrespondencePartUnit correspondencePart = (CorrespondencePartUnit) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printCorrespondencePartUnit(jgen, correspondencePart);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, correspondencePartHateoas.getLinks(correspondencePart));
    jgen.writeEndObject();
}
Also used : CorrespondencePartUnit(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)

Example 14 with CorrespondencePartUnit

use of nikita.common.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 15 with CorrespondencePartUnit

use of nikita.common.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)

Aggregations

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