Search in sources :

Example 21 with CaseFile

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

the class CaseFileHateoasController method deleteCaseFileBySystemId.

// Delete a CaseFile identified by systemID
// DELETE [contextPath][api]/casehandling/saksmappe/{systemId}/
@ApiOperation(value = "Deletes a single CaseFile entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or CaseFile) returned", response = HateoasNoarkObject.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteCaseFileBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to delete", required = true) @PathVariable("systemID") final String systemID) {
    CaseFile caseFile = caseFileService.findBySystemId(systemID);
    NoarkEntity parentEntity = caseFile.chooseParent();
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Series) {
        hateoasNoarkObject = new SeriesHateoas(parentEntity);
        seriesHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else // TODO: Can a casefile have a Class as parent???
    if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could not process " + request.getRequestURI());
    }
    caseFileService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, caseFile));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) Series(nikita.common.model.noark5.v4.Series) NoarkEntity(nikita.common.model.noark5.v4.NoarkEntity) ClassHateoas(nikita.common.model.noark5.v4.hateoas.ClassHateoas) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) HateoasNoarkObject(nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject) Authorisation(nikita.webapp.security.Authorisation) SeriesHateoas(nikita.common.model.noark5.v4.hateoas.SeriesHateoas) Class(nikita.common.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 22 with CaseFile

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

the class CaseFileHateoasController method findAllCaseFile.

@ApiOperation(value = "Retrieves multiple CaseFile entities limited by ownership rights", notes = "The field skip" + "tells how many CaseFile rows of the result set to ignore (starting at 0), while  top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile list found", response = CaseFileHateoas.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(method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findAllCaseFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas((List<INikitaEntity>) (List) caseFileService.findCaseFileByOwnerPaginated(top, skip));
    caseFileHateoasHandler.addLinks(caseFileHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 23 with CaseFile

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

the class CaseFileService method handleUpdate.

// All UPDATE operations
@Override
public CaseFile handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull CaseFile incomingCaseFile) {
    CaseFile existingCaseFile = getCaseFileOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != incomingCaseFile.getDescription()) {
        existingCaseFile.setDescription(incomingCaseFile.getDescription());
    }
    if (null != incomingCaseFile.getTitle()) {
        existingCaseFile.setTitle(incomingCaseFile.getTitle());
    }
    if (null != incomingCaseFile.getAdministrativeUnit()) {
        existingCaseFile.setAdministrativeUnit(incomingCaseFile.getAdministrativeUnit());
    }
    if (null != incomingCaseFile.getRecordsManagementUnit()) {
        existingCaseFile.setRecordsManagementUnit(incomingCaseFile.getRecordsManagementUnit());
    }
    if (null != incomingCaseFile.getCaseResponsible()) {
        existingCaseFile.setCaseResponsible(incomingCaseFile.getCaseResponsible());
    }
    if (null != incomingCaseFile.getCaseSequenceNumber()) {
        existingCaseFile.setCaseSequenceNumber(incomingCaseFile.getCaseSequenceNumber());
    }
    existingCaseFile.setVersion(version);
    caseFileRepository.save(existingCaseFile);
    return existingCaseFile;
}
Also used : CaseFile(nikita.model.noark5.v4.casehandling.CaseFile)

Example 24 with CaseFile

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

the class SeriesImportService method createCaseFileAssociatedWithSeries.

// All CREATE operations
@Override
public CaseFile createCaseFileAssociatedWithSeries(String seriesSystemId, CaseFile caseFile) {
    CaseFile persistedFile = null;
    Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
    if (series == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
        String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
        logger.info(info);
        throw new NoarkEntityEditWhenClosedException(info);
    } else {
        caseFile.setReferenceSeries(series);
        persistedFile = caseFileImportService.save(caseFile);
    }
    return persistedFile;
}
Also used : Series(nikita.model.noark5.v4.Series) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) NoarkEntityEditWhenClosedException(nikita.util.exceptions.NoarkEntityEditWhenClosedException)

Example 25 with CaseFile

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

the class SeriesHateoasController method createDefaultCaseFile.

// Create a CaseFile object with default values
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/ny-saksmappe/
@ApiOperation(value = "Create a CaseFile with default values", response = CaseFile.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile returned", response = CaseFile.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_CASE_FILE, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> createDefaultCaseFile(HttpServletRequest request, final HttpServletResponse response) {
    CaseFile defaultCaseFile = new CaseFile();
    defaultCaseFile.setTitle(TEST_TITLE);
    defaultCaseFile.setOfficialTitle(TEST_TITLE);
    defaultCaseFile.setFileId("2017/01");
    defaultCaseFile.setDescription(TEST_DESCRIPTION);
    defaultCaseFile.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    defaultCaseFile.setTitle(TEST_TITLE);
    defaultCaseFile.setDescription(TEST_DESCRIPTION);
    defaultCaseFile.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    defaultCaseFile.setCaseResponsible(TEST_USER_CASE_HANDLER_1);
    defaultCaseFile.setAdministrativeUnit(TEST_ADMINISTRATIVE_UNIT);
    defaultCaseFile.setCaseDate(new Date());
    defaultCaseFile.setCaseStatus(STATUS_OPEN);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(defaultCaseFile);
    caseFileHateoasHandler.addLinksOnNew(caseFileHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Date(java.util.Date) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)18 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)17 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)15 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 Timed (com.codahale.metrics.annotation.Timed)9 Authorisation (nikita.webapp.security.Authorisation)9 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)9 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)7 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)7 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)6 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)4 Series (nikita.model.noark5.v4.Series)4 List (java.util.List)3 Series (nikita.common.model.noark5.v4.Series)3 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2