Search in sources :

Example 11 with Series

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

the class SeriesHateoasController method createFileAssociatedWithSeries.

// API - All POST Requests (CRUD - CREATE)
// Create a new file
// POST [contextPath][api]/arkivstruktur/arkivdel/ny-mappe/
@ApiOperation(value = "Persists a File object associated with the given Series systemId", notes = "Returns the " + "newly created file object after it was associated with a Series object and persisted to the database", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FileHateoas.class), @ApiResponse(code = 201, message = "File " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FileHateoas.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 File"), @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_FILE, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FileHateoas> createFileAssociatedWithSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of series to associate the caseFile with", required = true) @PathVariable String systemID, @ApiParam(name = "File", value = "Incoming file object", required = true) @RequestBody File file) throws NikitaException {
    validateForCreate(file);
    File createdFile = seriesService.createFileAssociatedWithSeries(systemID, file);
    FileHateoas fileHateoas = new FileHateoas(createdFile);
    fileHateoasHandler.addLinks(fileHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdFile));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdFile.getVersion().toString()).body(fileHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) CaseFileHateoas(nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed)

Example 12 with Series

use of nikita.model.noark5.v4.Series 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 13 with Series

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

the class CaseFileDeserializer method deserialize.

@Override
public CaseFile deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    CaseFile caseFile = new CaseFile();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise properties for File
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(caseFile, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(caseFile, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(caseFile, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseKeyword(caseFile, objectNode);
    // Deserialize fileId
    JsonNode currentNode = objectNode.get(FILE_ID);
    if (null != currentNode) {
        caseFile.setFileId(currentNode.textValue());
        objectNode.remove(FILE_ID);
    }
    // Deserialize officialTitle
    currentNode = objectNode.get(FILE_PUBLIC_TITLE);
    if (null != currentNode) {
        caseFile.setOfficialTitle(currentNode.textValue());
        objectNode.remove(FILE_PUBLIC_TITLE);
    }
    caseFile.setReferenceCrossReference(CommonUtils.Hateoas.Deserialize.deserialiseCrossReferences(objectNode));
    CommonUtils.Hateoas.Deserialize.deserialiseComments(caseFile, objectNode);
    caseFile.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode));
    caseFile.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode));
    caseFile.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode));
    // Deserialise general properties for CaseFile
    // Deserialize caseYear
    currentNode = objectNode.get(CASE_YEAR);
    if (null != currentNode) {
        caseFile.setCaseYear(Integer.valueOf(currentNode.intValue()));
        objectNode.remove(CASE_YEAR);
    }
    // Deserialize caseSequenceNumber
    currentNode = objectNode.get(CASE_SEQUENCE_NUMBER);
    if (null != currentNode) {
        caseFile.setCaseSequenceNumber(Integer.valueOf(currentNode.intValue()));
        objectNode.remove(CASE_SEQUENCE_NUMBER);
    }
    // Deserialize caseDate
    currentNode = objectNode.get(CASE_DATE);
    if (null != currentNode) {
        try {
            Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
            caseFile.setCaseDate(parsedDate);
            objectNode.remove(CASE_DATE);
        } catch (ParseException e) {
            throw new NikitaMalformedInputDataException("The saksmappe you tried to create " + "has a malformed saksDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
        }
    }
    // Deserialize administrativeUnit
    currentNode = objectNode.get(ADMINISTRATIVE_UNIT);
    if (null != currentNode) {
        caseFile.setAdministrativeUnit(currentNode.textValue());
        objectNode.remove(ADMINISTRATIVE_UNIT);
    }
    // Deserialize caseResponsible
    currentNode = objectNode.get(CASE_RESPONSIBLE);
    if (null != currentNode) {
        caseFile.setCaseResponsible(currentNode.textValue());
        objectNode.remove(CASE_RESPONSIBLE);
    }
    // Deserialize recordsManagementUnit
    currentNode = objectNode.get(CASE_RECORDS_MANAGEMENT_UNIT);
    if (null != currentNode) {
        caseFile.setRecordsManagementUnit(currentNode.textValue());
        objectNode.remove(CASE_RECORDS_MANAGEMENT_UNIT);
    }
    // Deserialize caseStatus
    currentNode = objectNode.get(CASE_STATUS);
    if (null != currentNode) {
        caseFile.setCaseStatus(currentNode.textValue());
        objectNode.remove(CASE_STATUS);
    }
    // Deserialize loanedDate
    currentNode = objectNode.get(CASE_LOANED_DATE);
    if (null != currentNode) {
        try {
            Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
            caseFile.setLoanedDate(parsedDate);
            objectNode.remove(CASE_LOANED_DATE);
        } catch (ParseException e) {
            throw new NikitaMalformedInputDataException("The saksmappe you tried to create " + "has a malformed utlaantDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
        }
    }
    // Deserialize loanedTo
    currentNode = objectNode.get(CASE_LOANED_TO);
    if (null != currentNode) {
        caseFile.setLoanedTo(currentNode.textValue());
        objectNode.remove(CASE_LOANED_TO);
    }
    // Deserialize referenceSeries
    currentNode = objectNode.get(REFERENCE_SERIES);
    if (null != currentNode) {
        Series series = new Series();
        String systemID = currentNode.textValue();
        if (systemID != null) {
            series.setSystemId(systemID);
        }
        caseFile.setReferenceSeries(series);
        objectNode.remove(REFERENCE_SERIES);
    }
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The saksmappe object you tried to create is malformed. The " + "following fields are not recognised as saksmappe fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    caseFile.setReferenceCaseParty(CommonUtils.Hateoas.Deserialize.deserialiseCaseParties(objectNode));
    caseFile.setReferencePrecedence(CommonUtils.Hateoas.Deserialize.deserialisePrecedences(objectNode));
    return caseFile;
}
Also used : Series(nikita.model.noark5.v4.Series) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParseException(java.text.ParseException) Date(java.util.Date) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Example 14 with Series

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

the class SeriesHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject seriesHateoas, JsonGenerator jgen) throws IOException {
    Series series = (Series) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, series);
    CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, series);
    if (series.getSeriesStatus() != null) {
        jgen.writeStringField(SERIES_STATUS, series.getSeriesStatus());
    }
    CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, series);
    CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, series);
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, series);
    CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, series);
    if (series.getSeriesStartDate() != null) {
        jgen.writeStringField(SERIES_START_DATE, Serialize.formatDate(series.getSeriesStartDate()));
    }
    if (series.getSeriesEndDate() != null) {
        jgen.writeStringField(SERIES_END_DATE, Serialize.formatDate(series.getSeriesEndDate()));
    }
    if (series.getReferencePrecursor() != null && series.getReferencePrecursor().getSystemId() != null) {
        jgen.writeStringField(SERIES_PRECURSOR, series.getReferencePrecursor().getSystemId());
    }
    if (series.getReferenceSuccessor() != null && series.getReferenceSuccessor().getSystemId() != null) {
        jgen.writeStringField(SERIES_SUCCESSOR, series.getReferenceSuccessor().getSystemId());
    }
    CommonUtils.Hateoas.Serialize.printDisposal(jgen, series);
    CommonUtils.Hateoas.Serialize.printDisposalUndertaken(jgen, series);
    CommonUtils.Hateoas.Serialize.printDeletion(jgen, series);
    CommonUtils.Hateoas.Serialize.printScreening(jgen, series);
    CommonUtils.Hateoas.Serialize.printClassified(jgen, series);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, seriesHateoas.getLinks(series));
    jgen.writeEndObject();
}
Also used : Series(nikita.model.noark5.v4.Series)

Example 15 with Series

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

the class FondsService method generateDefaultSeries.

/**
 * Generate a Default Fonds object that can be associated with the
 * identified Fonds.
 * <br>
 * Note. Ideally this method would be configurable based on the logged in
 * user and the business area they are working with. A generic Noark core
 * like this does not have scope for that kind of functionality.
 *
 * @param fondsSystemId The systemId of the Fonds object you wish to
 *                      generate a default Series for
 * @return the Series object wrapped as a SeriesHateoas object
 */
@Override
public SeriesHateoas generateDefaultSeries(@NotNull String fondsSystemId) {
    Series defaultSeries = new Series();
    defaultSeries.setSeriesStatus(STATUS_OPEN);
    defaultSeries.setDocumentMedium(DOCUMENT_MEDIUM_ELECTRONIC);
    defaultSeries.setTitle("Default Series object generated by nikita " + "that can be associated with Fonds with systemID " + fondsSystemId);
    SeriesHateoas seriesHateoas = new SeriesHateoas(defaultSeries);
    seriesHateoasHandler.addLinksOnNew(seriesHateoas, new Authorisation());
    return seriesHateoas;
}
Also used : Series(nikita.common.model.noark5.v4.Series) Authorisation(nikita.webapp.security.Authorisation) SeriesHateoas(nikita.common.model.noark5.v4.hateoas.SeriesHateoas)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)29 Series (nikita.model.noark5.v4.Series)20 ApiOperation (io.swagger.annotations.ApiOperation)18 ApiResponses (io.swagger.annotations.ApiResponses)18 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (nikita.webapp.security.Authorisation)13 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)13 Series (nikita.common.model.noark5.v4.Series)11 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)11 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)6 Fonds (nikita.model.noark5.v4.Fonds)6 NoarkEntityEditWhenClosedException (nikita.util.exceptions.NoarkEntityEditWhenClosedException)6 List (java.util.List)5 SeriesHateoas (nikita.common.model.noark5.v4.hateoas.SeriesHateoas)5 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 SeriesHateoas (nikita.model.noark5.v4.hateoas.SeriesHateoas)5