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;
}
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);
}
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);
}
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();
}
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;
}
Aggregations