use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method findOneCorrespondencePartInternalBySystemId.
// Get a CorrespondencePartInternal identified by systemID
// GET [contextPath][api]/casehandling/korrespondansepartintern/{systemId}
@ApiOperation(value = "Retrieves a single CorrespondencePartInternal entity given a systemId", response = CorrespondencePartInternal.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartInternal returned", response = CorrespondencePartInternal.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_INTERNAL + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CorrespondencePartInternalHateoas> findOneCorrespondencePartInternalBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the correspondencePartInternal to retrieve", required = true) @PathVariable("systemID") final String correspondencePartInternalSystemId) {
CorrespondencePartInternal correspondencePartInternal = (CorrespondencePartInternal) correspondencePartService.findBySystemIdOrderBySystemId(correspondencePartInternalSystemId);
CorrespondencePartInternalHateoas correspondencePartInternalHateoas = new CorrespondencePartInternalHateoas(correspondencePartInternal);
correspondencePartHateoasHandler.addLinks(correspondencePartInternalHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartInternal.getVersion().toString()).body(correspondencePartInternalHateoas);
}
use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartService method updateCorrespondencePartInternal.
@Override
public CorrespondencePartInternal updateCorrespondencePartInternal(String systemId, Long version, CorrespondencePartInternal incomingCorrespondencePart) {
CorrespondencePartInternal existingCorrespondencePart = (CorrespondencePartInternal) getCorrespondencePartOrThrow(systemId);
// Copy all the values you are allowed to copy ....
existingCorrespondencePart.setAdministrativeUnit(incomingCorrespondencePart.getAdministrativeUnit());
existingCorrespondencePart.setCaseHandler(incomingCorrespondencePart.getCaseHandler());
existingCorrespondencePart.setReferenceAdministrativeUnit(incomingCorrespondencePart.getReferenceAdministrativeUnit());
existingCorrespondencePart.setReferenceCaseHandler(incomingCorrespondencePart.getReferenceCaseHandler());
existingCorrespondencePart.setVersion(version);
correspondencePartRepository.save(existingCorrespondencePart);
return existingCorrespondencePart;
}
use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method createDocumentDescriptionAssociatedWithRegistryEntry.
/*
TODO: Temp disabled!
private void associateCorrespondencePartTypeWithCorrespondencePart(@NotNull CorrespondencePart correspondencePart) {
CorrespondencePartType incomingCorrespondencePartType = correspondencePart.getCorrespondencePartType();
// It should never get this far with a null value
// It should be rejected at controller level
// The incoming CorrespondencePartType will not have @id field set. Therefore, we have to look it up
// in the database and make sure the proper CorrespondencePartType is associated with the CorrespondencePart
if (incomingCorrespondencePartType != null && incomingCorrespondencePartType.getCode() != null) {
CorrespondencePartType actualCorrespondencePartType =
correspondencePartTypeRepository.findByCode(incomingCorrespondencePartType.getCode());
if (actualCorrespondencePartType != null) {
correspondencePart.setCorrespondencePartType(actualCorrespondencePartType);
}
}
}
TODO: Temp disabled!
@Override
public List<CorrespondencePartPerson> getCorrespondencePartPersonAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartPerson();
}
@Override
public List<CorrespondencePartInternal> getCorrespondencePartInternalAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartInternal();
}
@Override
public List<CorrespondencePartUnit> getCorrespondencePartUnitAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartUnit();
}
*/
/* @Override
public CorrespondencePartPerson createCorrespondencePartPersonAssociatedWithRegistryEntry(
String systemID, CorrespondencePartPerson correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
TODO: Temp disabled!
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.getReferenceCorrespondencePartPerson().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartPerson(correspondencePart);
return null;
}
*/
/*
TODO: Temp disabled!
@Override
public CorrespondencePartInternal createCorrespondencePartInternalAssociatedWithRegistryEntry(
String systemID, CorrespondencePartInternal correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartInternal().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartInternal(correspondencePart);
}
@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.getReferenceCorrespondencePartUnit().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartUnit(correspondencePart);
}
*/
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
ArrayList<Record> records = (ArrayList<Record>) documentDescription.getReferenceRecord();
// It should always be instaniated ... check this ...
if (records == null) {
records = new ArrayList<>();
documentDescription.setReferenceRecord(records);
}
records.add(registryEntry);
return documentDescriptionService.save(documentDescription);
}
use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method updateCorrespondencePartInternal.
// Update a CorrespondencePartInternal with given values
// PUT [contextPath][api]/casehandling/korrespondansepartintern/{systemId}
@ApiOperation(value = "Updates a CorrespondencePartInternal identified by a given systemId", notes = "Returns the newly updated correspondencePartInternal", response = CorrespondencePartInternalHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartInternal " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartInternalHateoas.class), @ApiResponse(code = 201, message = "CorrespondencePartInternal " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartInternalHateoas.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 CorrespondencePartInternal"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = CORRESPONDENCE_PART_INTERNAL + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CorrespondencePartInternalHateoas> updateCorrespondencePartInternal(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of correspondencePartInternal to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CorrespondencePartInternal", value = "Incoming correspondencePartInternal object", required = true) @RequestBody CorrespondencePartInternal correspondencePartInternal) throws NikitaException {
validateForUpdate(correspondencePartInternal);
CorrespondencePartInternal updatedCorrespondencePartInternal = correspondencePartService.updateCorrespondencePartInternal(systemID, parseETAG(request.getHeader(ETAG)), correspondencePartInternal);
CorrespondencePartInternalHateoas correspondencePartInternalHateoas = new CorrespondencePartInternalHateoas(updatedCorrespondencePartInternal);
correspondencePartHateoasHandler.addLinks(correspondencePartInternalHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCorrespondencePartInternal));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCorrespondencePartInternal.getVersion().toString()).body(correspondencePartInternalHateoas);
}
use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method findOneCorrespondencePartInternalBySystemId.
// Get a CorrespondencePartInternal identified by systemID
// GET [contextPath][api]/casehandling/korrespondansepartintern/{systemId}
@ApiOperation(value = "Retrieves a single CorrespondencePartInternal entity given a systemId", response = CorrespondencePartInternal.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartInternal returned", response = CorrespondencePartInternal.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_INTERNAL + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CorrespondencePartInternalHateoas> findOneCorrespondencePartInternalBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the correspondencePartInternal to retrieve", required = true) @PathVariable("systemID") final String correspondencePartInternalSystemId) {
CorrespondencePartInternal correspondencePartInternal = (CorrespondencePartInternal) correspondencePartService.findBySystemId(correspondencePartInternalSystemId);
CorrespondencePartInternalHateoas correspondencePartInternalHateoas = new CorrespondencePartInternalHateoas(correspondencePartInternal);
correspondencePartHateoasHandler.addLinks(correspondencePartInternalHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartInternal.getVersion().toString()).body(correspondencePartInternalHateoas);
}
Aggregations