Search in sources :

Example 1 with SeriesStatus

use of nikita.common.model.noark5.v4.metadata.SeriesStatus in project nikita-noark5-core by HiOA-ABI.

the class FondsDeserializer method deserialize.

@Override
public Fonds deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    Fonds fonds = new Fonds();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // TODO : Are we deserialising parent? No, it's not done here or is it????
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(fonds, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(fonds, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(fonds, objectNode);
    // Deserialize seriesStatus
    JsonNode currentNode = objectNode.get(FONDS_STATUS);
    if (currentNode != null) {
        fonds.setFondsStatus(currentNode.textValue());
        objectNode.remove(FONDS_STATUS);
    }
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return fonds;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Fonds(nikita.model.noark5.v4.Fonds) JsonNode(com.fasterxml.jackson.databind.JsonNode) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Example 2 with SeriesStatus

use of nikita.common.model.noark5.v4.metadata.SeriesStatus in project nikita-noark5-core by HiOA-ABI.

the class UserDeserializer method deserialize.

@Override
public Fonds deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    Fonds fonds = new Fonds();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // TODO : Are we deserialising parent? No, it's not done here or is it????
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(fonds, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(fonds, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(fonds, objectNode);
    // Deserialize seriesStatus
    JsonNode currentNode = objectNode.get(FONDS_STATUS);
    if (currentNode != null) {
        fonds.setFondsStatus(currentNode.textValue());
        objectNode.remove(FONDS_STATUS);
    }
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return fonds;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Fonds(nikita.model.noark5.v4.Fonds) JsonNode(com.fasterxml.jackson.databind.JsonNode) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Example 3 with SeriesStatus

use of nikita.common.model.noark5.v4.metadata.SeriesStatus in project nikita-noark5-core by HiOA-ABI.

the class SeriesDeserializer method deserialize.

@Override
public Series deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    StringBuilder errors = new StringBuilder();
    Series series = new Series();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(series, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(series, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(series, objectNode, errors);
    // Deserialize seriesStatus
    JsonNode currentNode = objectNode.get(N5ResourceMappings.SERIES_STATUS);
    if (null != currentNode) {
        series.setSeriesStatus(currentNode.textValue());
        objectNode.remove(N5ResourceMappings.SERIES_STATUS);
    }
    // Deserialize seriesStartDate
    series.setSeriesStartDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.SERIES_START_DATE, objectNode, errors));
    // Deserialize seriesEndDate
    series.setSeriesEndDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.SERIES_END_DATE, objectNode, errors));
    // Deserialize referencePrecursor
    currentNode = objectNode.get(N5ResourceMappings.SERIES_PRECURSOR);
    if (null != currentNode) {
        Series seriesPrecursor = new Series();
        seriesPrecursor.setSystemId(currentNode.textValue());
        series.setReferencePrecursor(seriesPrecursor);
        // TODO: Does this imply that the current arkivdel is the successor?
        // I would not set it here, as the service class has to check that
        // the seriesPrecursor object actually exists
        objectNode.remove(N5ResourceMappings.SERIES_PRECURSOR);
    }
    // Deserialize referenceSuccessor
    currentNode = objectNode.get(N5ResourceMappings.SERIES_SUCCESSOR);
    if (null != currentNode) {
        Series seriesSuccessor = new Series();
        seriesSuccessor.setSystemId(currentNode.textValue());
        series.setReferenceSuccessor(seriesSuccessor);
        // TODO: Does this imply that the current arkivdel is the precursor?
        // I would not set it here, as the service class should do this
        objectNode.remove(N5ResourceMappings.SERIES_SUCCESSOR);
    }
    series.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode, errors));
    series.setReferenceDisposalUndertaken(CommonUtils.Hateoas.Deserialize.deserialiseDisposalUndertaken(objectNode, errors));
    series.setReferenceDeletion(CommonUtils.Hateoas.Deserialize.deserialiseDeletion(objectNode, errors));
    series.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode, errors));
    series.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode, errors));
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The arkivdel you tried to create is malformed. The " + "following fields are not recognised as arkivdel fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    if (0 < errors.length())
        throw new NikitaMalformedInputDataException(errors.toString());
    return series;
}
Also used : Series(nikita.common.model.noark5.v4.Series) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) NikitaMalformedInputDataException(nikita.common.util.exceptions.NikitaMalformedInputDataException)

Example 4 with SeriesStatus

use of nikita.common.model.noark5.v4.metadata.SeriesStatus in project nikita-noark5-core by HiOA-ABI.

the class UserDeserializer method deserialize.

@Override
public Fonds deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    StringBuilder errors = new StringBuilder();
    Fonds fonds = new Fonds();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // TODO : Are we deserialising parent? No, it's not done here or is it????
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(fonds, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(fonds, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(fonds, objectNode, errors);
    // Deserialize seriesStatus
    JsonNode currentNode = objectNode.get(N5ResourceMappings.FONDS_STATUS);
    if (currentNode != null) {
        fonds.setFondsStatus(currentNode.textValue());
        objectNode.remove(N5ResourceMappings.FONDS_STATUS);
    }
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    if (0 < errors.length())
        throw new NikitaMalformedInputDataException(errors.toString());
    return fonds;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Fonds(nikita.common.model.noark5.v4.Fonds) JsonNode(com.fasterxml.jackson.databind.JsonNode) NikitaMalformedInputDataException(nikita.common.util.exceptions.NikitaMalformedInputDataException)

Example 5 with SeriesStatus

use of nikita.common.model.noark5.v4.metadata.SeriesStatus in project nikita-noark5-core by HiOA-ABI.

the class SeriesDeserializer method deserialize.

@Override
public Series deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    Series series = new Series();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(series, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(series, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(series, objectNode);
    // Deserialize seriesStatus
    JsonNode currentNode = objectNode.get(SERIES_STATUS);
    if (null != currentNode) {
        series.setSeriesStatus(currentNode.textValue());
        objectNode.remove(SERIES_STATUS);
    }
    // Deserialize seriesStartDate
    currentNode = objectNode.get(SERIES_START_DATE);
    if (null != currentNode) {
        try {
            Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
            series.setSeriesStartDate(parsedDate);
            objectNode.remove(SERIES_START_DATE);
        } catch (ParseException e) {
            throw new NikitaMalformedInputDataException("The arkivdel you tried to create " + "has a malformed arkivperiodeStartDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
        }
    }
    // Deserialize seriesEndDate
    currentNode = objectNode.get(SERIES_END_DATE);
    if (null != currentNode) {
        try {
            Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
            series.setSeriesEndDate(parsedDate);
            objectNode.remove(SERIES_END_DATE);
        } catch (ParseException e) {
            throw new NikitaMalformedInputDataException("The arkivdel you tried to create " + "has a malformed arkivperiodeSluttDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
        }
    }
    // Deserialize referencePrecursor
    currentNode = objectNode.get(SERIES_PRECURSOR);
    if (null != currentNode) {
        Series seriesPrecursor = new Series();
        seriesPrecursor.setSystemId(currentNode.textValue());
        series.setReferencePrecursor(seriesPrecursor);
        // TODO: Does this imply that the current arkivdel is the successor?
        // I would not set it here, as the service class has to check that
        // the seriesPrecursor object actually exists
        objectNode.remove(SERIES_PRECURSOR);
    }
    // Deserialize referenceSuccessor
    currentNode = objectNode.get(SERIES_SUCCESSOR);
    if (null != currentNode) {
        Series seriesSuccessor = new Series();
        seriesSuccessor.setSystemId(currentNode.textValue());
        series.setReferenceSuccessor(seriesSuccessor);
        // TODO: Does this imply that the current arkivdel is the precursor?
        // I would not set it here, as the service class should do this
        objectNode.remove(SERIES_SUCCESSOR);
    }
    series.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode));
    series.setReferenceDisposalUndertaken(CommonUtils.Hateoas.Deserialize.deserialiseDisposalUndertaken(objectNode));
    series.setReferenceDeletion(CommonUtils.Hateoas.Deserialize.deserialiseDeletion(objectNode));
    series.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode));
    series.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode));
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The arkivdel you tried to create is malformed. The " + "following fields are not recognised as arkivdel fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return series;
}
Also used : Series(nikita.model.noark5.v4.Series) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParseException(java.text.ParseException) Date(java.util.Date) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 Counted (com.codahale.metrics.annotation.Counted)4 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)4 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)3 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)3 Authorisation (nikita.webapp.security.Authorisation)3 Fonds (nikita.common.model.noark5.v4.Fonds)2 SeriesStatus (nikita.common.model.noark5.v4.metadata.SeriesStatus)2 Fonds (nikita.model.noark5.v4.Fonds)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 Series (nikita.common.model.noark5.v4.Series)1 Series (nikita.model.noark5.v4.Series)1