Search in sources :

Example 11 with RegistryEntry

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

the class CaseFileService method createRegistryEntryAssociatedWithCaseFile.

@Override
public RegistryEntry createRegistryEntryAssociatedWithCaseFile(@NotNull String fileSystemId, @NotNull RegistryEntry registryEntry) {
    CaseFile caseFile = getCaseFileOrThrow(fileSystemId);
    // bidirectional relationship @OneToMany and @ManyToOne, set both sides of relationship
    registryEntry.setReferenceFile(caseFile);
    caseFile.getReferenceRecord().add(registryEntry);
    return registryEntryService.save(registryEntry);
}
Also used : CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile)

Example 12 with RegistryEntry

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

the class RegistryEntryService method createPrecedenceAssociatedWithRecord.

@Override
public Precedence createPrecedenceAssociatedWithRecord(String registryEntrySystemID, Precedence precedence) {
    RegistryEntry registryEntry = getRegistryEntryOrThrow(registryEntrySystemID);
    NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(precedence);
    NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(precedence);
    // bidirectional relationship @ManyToMany, set both sides of relationship
    registryEntry.getReferencePrecedence().add(precedence);
    precedence.getReferenceRegistryEntry().add(registryEntry);
    return precedenceService.createNewPrecedence(precedence);
}
Also used : RegistryEntry(nikita.common.model.noark5.v4.casehandling.RegistryEntry)

Example 13 with RegistryEntry

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

the class RegistryEntryHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject registryEntryHateoas, JsonGenerator jgen) throws IOException {
    RegistryEntry registryEntry = (RegistryEntry) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, registryEntry);
    if (registryEntry.getArchivedDate() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(registryEntry.getArchivedDate()));
    }
    if (registryEntry.getArchivedBy() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_BY, registryEntry.getArchivedBy());
    }
    CommonUtils.Hateoas.Serialize.printDisposal(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printScreening(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printClassified(jgen, registryEntry);
    // handle general registryEntry properties
    if (registryEntry.getTitle() != null) {
        jgen.writeStringField(TITLE, registryEntry.getTitle());
    }
    if (registryEntry.getOfficialTitle() != null) {
        jgen.writeStringField(FILE_PUBLIC_TITLE, registryEntry.getOfficialTitle());
    }
    if (registryEntry.getDescription() != null) {
        jgen.writeStringField(DESCRIPTION, registryEntry.getDescription());
    }
    CommonUtils.Hateoas.Serialize.printKeyword(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printComment(jgen, registryEntry);
    // TODO: FIX THIS CommonCommonUtils.Hateoas.Serialize.printCrossReference(jgen, registryEntry);
    if (registryEntry.getRecordYear() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_YEAR, registryEntry.getRecordYear().intValue());
    }
    if (registryEntry.getRecordSequenceNumber() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_SEQUENCE_NUMBER, registryEntry.getRecordSequenceNumber().intValue());
    }
    if (registryEntry.getRegistryEntryNumber() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_NUMBER, registryEntry.getRegistryEntryNumber().intValue());
    }
    if (registryEntry.getRegistryEntryType() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_TYPE, registryEntry.getRegistryEntryType());
    }
    if (registryEntry.getRecordStatus() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_STATUS, registryEntry.getRecordStatus());
    }
    if (registryEntry.getRecordDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_DATE, Serialize.formatDate(registryEntry.getRecordDate()));
    }
    if (registryEntry.getDocumentDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_DOCUMENT_DATE, Serialize.formatDate(registryEntry.getDocumentDate()));
    }
    if (registryEntry.getReceivedDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_RECEIVED_DATE, Serialize.formatDate(registryEntry.getReceivedDate()));
    }
    if (registryEntry.getSentDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_SENT_DATE, Serialize.formatDate(registryEntry.getSentDate()));
    }
    if (registryEntry.getDueDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_DUE_DATE, Serialize.formatDate(registryEntry.getDueDate()));
    }
    if (registryEntry.getFreedomAssessmentDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_RECORD_FREEDOM_ASSESSMENT_DATE, Serialize.formatDate(registryEntry.getFreedomAssessmentDate()));
    }
    if (registryEntry.getNumberOfAttachments() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS, registryEntry.getNumberOfAttachments().intValue());
    }
    if (registryEntry.getLoanedDate() != null) {
        jgen.writeStringField(CASE_LOANED_DATE, Serialize.formatDate(registryEntry.getLoanedDate()));
    }
    if (registryEntry.getLoanedTo() != null) {
        jgen.writeStringField(CASE_LOANED_TO, registryEntry.getLoanedTo());
    }
    /*
        TODO: Temp disabled!
        CommonUtils.Hateoas.Serialize.printCorrespondencePartPersons(jgen, registryEntry);
        CommonUtils.Hateoas.Serialize.printCorrespondencePartUnits(jgen, registryEntry);
        CommonUtils.Hateoas.Serialize.printCorrespondencePartInternals(jgen, registryEntry);
        */
    CommonUtils.Hateoas.Serialize.printSignOff(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printDocumentFlow(jgen, registryEntry);
    // CommonUtils.Hateoas.Serialize.printPrecedence(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, registryEntryHateoas.getLinks(registryEntry));
    jgen.writeEndObject();
}
Also used : RegistryEntry(nikita.common.model.noark5.v4.casehandling.RegistryEntry)

Example 14 with RegistryEntry

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
@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 15 with RegistryEntry

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

the class RegistryEntryHateoasController method findAllRegistryEntry.

// Get all registryEntry
// GET [contextPath][api]/casehandling/journalpost/
// http://rel.kxml.no/noark5/v4/api/sakarkiv/journalpost/
@ApiOperation(value = "Retrieves multiple RegistryEntry entities limited by ownership rights", notes = "The field skip" + "tells how many RegistryEntry 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 = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry found", 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(method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findAllRegistryEntry(HttpServletRequest request, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas((List<INikitaEntity>) (List) registryEntryService.findRegistryEntryByOwnerPaginated(top, skip));
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
Also used : 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)

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