Search in sources :

Example 16 with CaseFile

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

the class CaseFileHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject caseFileHateoas, JsonGenerator jgen) throws IOException {
    CaseFile caseFile = (CaseFile) noarkSystemIdEntity;
    jgen.writeStartObject();
    if (caseFile.getSystemId() != null) {
        jgen.writeStringField(SYSTEM_ID, caseFile.getSystemId());
    }
    if (caseFile.getFileId() != null) {
        jgen.writeStringField(FILE_ID, caseFile.getFileId());
    }
    if (caseFile.getTitle() != null) {
        jgen.writeStringField(TITLE, caseFile.getTitle());
    }
    if (caseFile.getOfficialTitle() != null) {
        jgen.writeStringField(FILE_PUBLIC_TITLE, caseFile.getOfficialTitle());
    }
    if (caseFile.getDescription() != null) {
        jgen.writeStringField(DESCRIPTION, caseFile.getDescription());
    }
    CommonUtils.Hateoas.Serialize.printKeyword(jgen, caseFile);
    if (caseFile.getDocumentMedium() != null) {
        jgen.writeStringField(DOCUMENT_MEDIUM, caseFile.getDocumentMedium());
    }
    CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, caseFile);
    if (caseFile.getCreatedDate() != null) {
        jgen.writeStringField(CREATED_DATE, Serialize.formatDateTime(caseFile.getCreatedDate()));
    }
    if (caseFile.getCreatedBy() != null) {
        jgen.writeStringField(CREATED_BY, caseFile.getCreatedBy());
    }
    if (caseFile.getFinalisedDate() != null) {
        jgen.writeStringField(FINALISED_DATE, Serialize.formatDateTime(caseFile.getFinalisedDate()));
    }
    if (caseFile.getFinalisedBy() != null) {
        jgen.writeStringField(FINALISED_BY, caseFile.getFinalisedBy());
    }
    if (caseFile.getReferenceSeries() != null && caseFile.getReferenceSeries().getSystemId() != null) {
        jgen.writeStringField(REFERENCE_SERIES, caseFile.getReferenceSeries().getSystemId());
    }
    if (caseFile.getCaseYear() != null) {
        jgen.writeNumberField(CASE_YEAR, caseFile.getCaseYear().intValue());
    }
    if (caseFile.getCaseSequenceNumber() != null) {
        jgen.writeNumberField(CASE_SEQUENCE_NUMBER, caseFile.getCaseSequenceNumber().intValue());
    }
    if (caseFile.getCaseDate() != null) {
        jgen.writeStringField(CASE_DATE, Serialize.formatDate(caseFile.getCaseDate()));
    }
    if (caseFile.getAdministrativeUnit() != null) {
        jgen.writeStringField(ADMINISTRATIVE_UNIT, caseFile.getAdministrativeUnit());
    }
    if (caseFile.getCaseResponsible() != null) {
        jgen.writeStringField(CASE_RESPONSIBLE, caseFile.getCaseResponsible());
    }
    if (caseFile.getRecordsManagementUnit() != null) {
        jgen.writeStringField(CASE_RECORDS_MANAGEMENT_UNIT, caseFile.getRecordsManagementUnit());
    }
    if (caseFile.getCaseStatus() != null) {
        jgen.writeStringField(CASE_STATUS, caseFile.getCaseStatus());
    }
    if (caseFile.getLoanedDate() != null) {
        jgen.writeStringField(CASE_LOANED_DATE, Serialize.formatDate(caseFile.getLoanedDate()));
    }
    if (caseFile.getLoanedTo() != null) {
        jgen.writeStringField(CASE_LOANED_TO, caseFile.getLoanedTo());
    }
    // TODO: Implement M209 referanseSekundaerKlassifikasjon
    // CommonCommonUtils.Hateoas.Serialize.printSecondaryClassification(jgen, caseFile);
    CommonUtils.Hateoas.Serialize.printCaseParty(jgen, caseFile);
    // CommonUtils.Hateoas.Serialize.printPrecedence(jgen, caseFile);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, caseFileHateoas.getLinks(caseFile));
    jgen.writeEndObject();
}
Also used : CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile)

Example 17 with CaseFile

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

the class SeriesHateoasController method findAllCaseFileAssociatedWithCaseFile.

// Retrieve all CaseFiles associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/saksmappe/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/saksmappe/?top=5&skip=1
@ApiOperation(value = "Retrieves a list of CaseFiles associated with a Series", 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(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + CASE_FILE, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findAllCaseFileAssociatedWithCaseFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    seriesService.findAllCaseFileBySeries(systemID);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas((List<INikitaEntity>) (List) seriesService.findAllCaseFileBySeries(systemID));
    caseFileHateoasHandler.addLinksOnRead(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)

Example 18 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
@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 = setCaseFileDefaults(defaultCaseFile);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(defaultCaseFile);
    caseFileHateoasHandler.addLinksOnNew(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) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) Authorisation(nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted)

Example 19 with CaseFile

use of nikita.common.model.noark5.v4.casehandling.CaseFile 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
@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.findBySystemId(caseFileSystemId);
    if (caseFile == null) {
        throw new NoarkEntityNotFoundException(caseFileSystemId);
    }
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas((List<INikitaEntity>) (List) (caseFile.getReferenceRecord()));
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
Also used : RegistryEntryHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 20 with CaseFile

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

the class CaseFileHateoasController method findOneCaseFilebySystemId.

// Retrieve a single casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}
@ApiOperation(value = "Retrieves a single CaseFile entity given a systemId", 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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findOneCaseFilebySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
    CaseFile caseFile = caseFileService.findBySystemId(caseFileSystemId);
    if (caseFile == null) {
        throw new NoarkEntityNotFoundException(caseFileSystemId);
    }
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas(caseFile);
    caseFileHateoasHandler.addLinks(caseFileHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(caseFile.getVersion().toString()).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

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