Search in sources :

Example 6 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 {
    StringBuilder errors = new StringBuilder();
    CorrespondencePartPerson correspondencePart = new CorrespondencePartPerson();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(correspondencePart, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseCorrespondencePartPersonEntity(correspondencePart, objectNode, errors);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The korrespondansepartperson you tried to create is malformed. The " + "following fields are not recognised as korrespondansepartperson fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    if (0 < errors.length())
        throw new NikitaMalformedInputDataException(errors.toString());
    return correspondencePart;
}
Also used : CorrespondencePartPerson(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NikitaMalformedInputDataException(nikita.common.util.exceptions.NikitaMalformedInputDataException)

Example 7 with CorrespondencePartPerson

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson 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
@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.findBySystemId(correspondencePartUnitSystemId);
    CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(correspondencePartUnit);
    correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartUnit.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) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 8 with CorrespondencePartPerson

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson 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
@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, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(correspondencePartHateoas);
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 9 with CorrespondencePartPerson

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

the class CorrespondencePartPersonHateoasSerializer method serializeNoarkEntity.

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

Example 10 with CorrespondencePartPerson

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

the class CorrespondencePartService method updateCorrespondencePartPerson.

@Override
public CorrespondencePartPerson updateCorrespondencePartPerson(String systemId, Long version, CorrespondencePartPerson incomingCorrespondencePart) {
    CorrespondencePartPerson existingCorrespondencePart = (CorrespondencePartPerson) getCorrespondencePartOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    existingCorrespondencePart.setContactInformation(incomingCorrespondencePart.getContactInformation());
    existingCorrespondencePart.setdNumber(incomingCorrespondencePart.getdNumber());
    existingCorrespondencePart.setName(incomingCorrespondencePart.getName());
    existingCorrespondencePart.setSocialSecurityNumber(incomingCorrespondencePart.getSocialSecurityNumber());
    existingCorrespondencePart.setPostalAddress(incomingCorrespondencePart.getPostalAddress());
    existingCorrespondencePart.setResidingAddress(incomingCorrespondencePart.getResidingAddress());
    existingCorrespondencePart.setVersion(version);
    correspondencePartRepository.save(existingCorrespondencePart);
    return existingCorrespondencePart;
}
Also used : CorrespondencePartPerson(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)

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