use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method getRegistryEntryOrThrow.
/**
* Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
* If you call this, be aware that you will only ever get a valid RegistryEntry back. If there is no valid
* RegistryEntry, an exception is thrown
*
* @param registryEntrySystemId
* @return
*/
protected RegistryEntry getRegistryEntryOrThrow(@NotNull String registryEntrySystemId) {
RegistryEntry registryEntry = registryEntryRepository.findBySystemIdOrderBySystemId(registryEntrySystemId);
if (registryEntry == null) {
String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntry, using systemId " + registryEntrySystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return registryEntry;
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method createCorrespondencePartInternalAssociatedWithRegistryEntry.
@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.getReferenceCorrespondencePart().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartInternal(correspondencePart);
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryImportService method createDocumentDescriptionAssociatedWithRegistryEntry.
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
DocumentDescription persistedDocumentDescription = null;
RegistryEntry registryEntry = registryEntryRepository.findBySystemIdOrderBySystemId(systemID);
if (registryEntry == null) {
String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntry, using registryEntrySystemId " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new TreeSet<>();
documentDescription.setReferenceRecord(records);
}
records.add(registryEntry);
persistedDocumentDescription = documentDescriptionImportService.save(documentDescription);
}
return persistedDocumentDescription;
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method findRegistryEntryAssociatedWithCaseFileBySystemId.
// Retrieve all RegistryEntry associated with a casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}/journalpost
@ApiOperation(value = "Retrieves all RegistryEntry associated with a CaseFile identified by systemId", response = RegistryEntry.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry list returned", response = RegistryEntryHateoas.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + REGISTRY_ENTRY, method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findRegistryEntryAssociatedWithCaseFileBySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
CaseFile caseFile = caseFileService.findBySystemIdOrderBySystemId(caseFileSystemId);
if (caseFile == null) {
throw new NoarkEntityNotFoundException(caseFileSystemId);
}
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(new ArrayList<>(caseFile.getReferenceRecord()));
registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
use of nikita.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method createDefaultRegistryEntry.
// API - All GET Requests (CRUD - READ)
// Create a RegistryEntry object with default values
// GET [contextPath][api]/casehandling/mappe/SYSTEM_ID/ny-journalpost
@ApiOperation(value = "Create a RegistryEntry with default values", response = RegistryEntry.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry returned", response = RegistryEntry.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_REGISTRY_ENTRY, method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> createDefaultRegistryEntry(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response) {
RegistryEntry defaultRegistryEntry = new RegistryEntry();
defaultRegistryEntry.setDescription(TEST_DESCRIPTION);
defaultRegistryEntry.setTitle(TEST_TITLE);
defaultRegistryEntry.setDocumentDate(new Date());
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(defaultRegistryEntry);
registryEntryHateoasHandler.addLinksOnNew(registryEntryHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
Aggregations