Search in sources :

Example 6 with RegistryEntry

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

the class CaseFileHateoasController method createRegistryEntryAssociatedWithFile.

// API - All POST Requests (CRUD - CREATE)
// Create a RegistryEntry entity
// POST [contextPath][api]/casehandling/{systemId}/ny-journalpost
@ApiOperation(value = "Persists a RegistryEntry object associated with the given Series systemId", notes = "Returns the newly created record object after it was associated with a File object and " + "persisted to the database", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type RegistryEntry"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_REGISTRY_ENTRY, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> createRegistryEntryAssociatedWithFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
    RegistryEntry createdRegistryEntry = caseFileService.createRegistryEntryAssociatedWithCaseFile(systemID, registryEntry);
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(createdRegistryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRegistryEntry));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
Also used : RegistryEntryHateoas(nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with RegistryEntry

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

the class RegistryEntryHateoasController method updateRegistryEntry.

// Update a RegistryEntry with given values
// PUT [contextPath][api]/casehandling/journalpost/{systemId}
@ApiOperation(value = "Updates a RegistryEntry identified by a given systemId", notes = "Returns the newly updated registryEntry", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type RegistryEntry"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> updateRegistryEntry(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of registryEntry to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
    validateForUpdate(registryEntry);
    RegistryEntry updatedRegistryEntry = registryEntryService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), registryEntry);
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(updatedRegistryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedRegistryEntry));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) AfterNoarkEntityUpdatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 8 with RegistryEntry

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

the class RegistryEntryHateoasController method findOneRegistryEntrybySystemId.

// Retrieve a single registryEntry identified by systemId
// GET [contextPath][api]/casehandling/journalpost/{systemID}
@ApiOperation(value = "Retrieves a single RegistryEntry entity given a systemId", 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, method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findOneRegistryEntrybySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the registryEntry to retrieve", required = true) @PathVariable("systemID") final String registryEntrySystemId) {
    RegistryEntry registryEntry = registryEntryService.findBySystemIdOrderBySystemId(registryEntrySystemId);
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(registryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(registryEntry.getVersion().toString()).body(registryEntryHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 9 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());
    }
    CommonUtils.Hateoas.Serialize.printCorrespondenceParts(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.model.noark5.v4.casehandling.RegistryEntry)

Example 10 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.model.noark5.v4.casehandling.CaseFile)

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