use of nikita.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 {
CorrespondencePartUnit correspondencePartUnit = new CorrespondencePartUnit();
ObjectNode objectNode = mapper.readTree(jsonParser);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(correspondencePartUnit, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseCorrespondencePartUnitEntity(correspondencePartUnit, objectNode);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The korrespondansepartenhet you tried to create is malformed. The " + "following fields are not recognised as korrespondansepartenhet fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return correspondencePartUnit;
}
use of nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method createCorrespondencePartUnitAssociatedWithRegistryEntry.
@Override
public CorrespondencePartUnit createCorrespondencePartUnitAssociatedWithRegistryEntry(String systemID, CorrespondencePartUnit 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 businessAddress = correspondencePart.getBusinessAddress();
if (null != businessAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(businessAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(businessAddress);
}
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.createNewCorrespondencePartUnit(correspondencePart);
}
use of nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartService method deleteCorrespondencePartUnit.
@Override
public void deleteCorrespondencePartUnit(@NotNull String code) {
CorrespondencePartUnit correspondencePartUnit = (CorrespondencePartUnit) getCorrespondencePartOrThrow(code);
correspondencePartRepository.delete(correspondencePartUnit);
}
use of nikita.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
@Timed
@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, request, 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);
}
use of nikita.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();
}
Aggregations