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