Search in sources :

Example 1 with Fonds

use of nikita.model.noark5.v4.Fonds 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 Fonds

use of nikita.model.noark5.v4.Fonds 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 Fonds

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

the class UserHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsHateoas, JsonGenerator jgen) throws IOException {
    Fonds fonds = (Fonds) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, fonds);
    CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, fonds);
    if (fonds.getFondsStatus() != null) {
        jgen.writeStringField(FONDS_STATUS, fonds.getFondsStatus());
    }
    CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, fonds);
    CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, fonds);
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, fonds);
    CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, fonds);
    CommonUtils.Hateoas.Serialize.printFondsCreators(jgen, fonds);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsHateoas.getLinks(fonds));
    jgen.writeEndObject();
}
Also used : Fonds(nikita.model.noark5.v4.Fonds)

Example 4 with Fonds

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

the class FondsCreatorService method createFondsAssociatedWithFondsCreator.

@Override
public Fonds createFondsAssociatedWithFondsCreator(String fondsCreatorSystemId, Fonds fonds) {
    FondsCreator fondsCreator = getFondsCreatorOrThrow(fondsCreatorSystemId);
    NoarkUtils.NoarkEntity.Create.checkDocumentMediumValid(fonds);
    NoarkUtils.NoarkEntity.Create.setNoarkEntityValues(fonds);
    fonds.setFondsStatus(STATUS_OPEN);
    NoarkUtils.NoarkEntity.Create.setFinaliseEntityValues(fonds);
    fonds.getReferenceFondsCreator().add(fondsCreator);
    fondsCreator.getReferenceFonds().add(fonds);
    fondsRepository.save(fonds);
    return fonds;
}
Also used : FondsCreator(nikita.model.noark5.v4.FondsCreator)

Example 5 with Fonds

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

the class FondsService method createFondsAssociatedWithFonds.

/**
     *
     ** Persists a new fonds object to the database, that is associated with a parent fonds object. Some values are set
     * in the incoming payload (e.g. title) and some are set by the core. owner, createdBy, createdDate are
     * automatically set by the core.
     *
     * First we try to locate the parent. If the parent does not exist a NoarkEntityNotFoundException exception is
     * thrown
     *
     * @param childFonds incoming fonds object with some values set
     * @param parentFondsSystemId The systemId of the parent fonds
     * @return the newly persisted fonds object
     */
@Override
public Fonds createFondsAssociatedWithFonds(String parentFondsSystemId, Fonds childFonds) {
    Fonds persistedChildFonds = null;
    Fonds parentFonds = fondsRepository.findBySystemIdOrderBySystemId(parentFondsSystemId);
    if (parentFonds == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + parentFondsSystemId + " when " + "trying to associate a child fonds with a parent fonds";
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else if (parentFonds.getReferenceSeries() != null) {
        String info = INFO_INVALID_STRUCTURE + " Cannot associate a new child fonds with a fonds that has " + "one or more series " + parentFondsSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        childFonds.setReferenceParentFonds(parentFonds);
        persistedChildFonds = this.createNewFonds(childFonds);
    }
    return persistedChildFonds;
}
Also used : Fonds(nikita.model.noark5.v4.Fonds) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Aggregations

Fonds (nikita.model.noark5.v4.Fonds)28 Counted (com.codahale.metrics.annotation.Counted)18 Timed (com.codahale.metrics.annotation.Timed)18 ApiOperation (io.swagger.annotations.ApiOperation)18 ApiResponses (io.swagger.annotations.ApiResponses)18 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)14 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)10 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)8 Series (nikita.model.noark5.v4.Series)5 SeriesHateoas (nikita.model.noark5.v4.hateoas.SeriesHateoas)4 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)4 ArrayList (java.util.ArrayList)3 FondsCreator (nikita.model.noark5.v4.FondsCreator)3 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)3 ResponseEntity (org.springframework.http.ResponseEntity)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Date (java.util.Date)2 FondsCreatorHateoas (nikita.model.noark5.v4.hateoas.FondsCreatorHateoas)2 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)2