Search in sources :

Example 21 with RegistryEntry

use of nikita.common.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);
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 22 with RegistryEntry

use of nikita.common.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;
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) TreeSet(java.util.TreeSet) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) Record(nikita.model.noark5.v4.Record) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 23 with RegistryEntry

use of nikita.common.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);
}
Also used : RegistryEntryHateoas(nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 24 with RegistryEntry

use of nikita.common.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);
}
Also used : RegistryEntryHateoas(nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) Date(java.util.Date) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 25 with RegistryEntry

use of nikita.common.model.noark5.v4.casehandling.RegistryEntry in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryHateoasController method deleteRecordBySystemId.

// Delete a Record identified by systemID
// DELETE [contextPath][api]/casehandling/journalpost/{systemId}/
@ApiOperation(value = "Deletes a single RegistryEntry entity identified by systemID", response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = String.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, method = RequestMethod.DELETE)
public ResponseEntity<String> deleteRecordBySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
    RegistryEntry registryEntry = registryEntryService.findBySystemIdOrderBySystemId(systemID);
    registryEntryService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, registryEntry));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(CommonUtils.WebUtils.getSuccessStatusStringForDelete());
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

RegistryEntry (nikita.model.noark5.v4.casehandling.RegistryEntry)18 Counted (com.codahale.metrics.annotation.Counted)14 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)13 Timed (com.codahale.metrics.annotation.Timed)7 Authorisation (nikita.webapp.security.Authorisation)6 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)6 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)4 Date (java.util.Date)3 RegistryEntryHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas)3 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)3 RegistryEntryHateoas (nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)2