Search in sources :

Example 21 with Fonds

use of nikita.common.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 22 with Fonds

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

the class CorrespondencePartService method deleteCorrespondencePartInternal.

@Override
public void deleteCorrespondencePartInternal(@NotNull String code) {
    CorrespondencePartInternal correspondencePartInternal = (CorrespondencePartInternal) getCorrespondencePartOrThrow(code);
    /*
        // Disassociate the link between Fonds and FondsCreator
        // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
        Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE f_pk_fonds_id  = :id ;");
        q.setParameter("id", fonds.getId());
        q.executeUpdate();
        entityManager.remove(fonds);
        entityManager.flush();
        entityManager.clear();*/
    correspondencePartRepository.delete(correspondencePartInternal);
}
Also used : CorrespondencePartInternal(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)

Example 23 with Fonds

use of nikita.common.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.common.model.noark5.v4.FondsCreator)

Example 24 with Fonds

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

the class FondsService method findFondsCreatorAssociatedWithFonds.

// All READ operations
/**
 * Retrieve a list of FondsCreator objects associated with a given Fonds
 * from the database. First we try to locate the Fonds object. If the
 * Fonds object does not exist a NoarkEntityNotFoundException exception
 * is thrown that the caller has to deal with.
 * <p>
 * If any FondsCreator objects exist, they are wrapped in a
 * FondsCreatorHateoas object and returned to the caller.
 *
 * @param fondsSystemId The systemId of the Fonds object that you want to
 *                      retrieve associated FondsCreator objects
 * @return the fondsCreator objects wrapped as a FondsCreatorHateoas object
 */
@Override
public FondsCreatorHateoas findFondsCreatorAssociatedWithFonds(@NotNull String fondsSystemId) {
    Fonds fonds = getFondsOrThrow(fondsSystemId);
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas((List<INikitaEntity>) (List) fonds.getReferenceFondsCreator());
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
    return fondsCreatorHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) Fonds(nikita.common.model.noark5.v4.Fonds) FondsCreatorHateoas(nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas) List(java.util.List)

Example 25 with Fonds

use of nikita.common.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 first 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.
 * <p>
 * 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 FondsHateoas createFondsAssociatedWithFonds(@NotNull String parentFondsSystemId, @NotNull Fonds childFonds) {
    Fonds parentFonds = getFondsOrThrow(parentFondsSystemId);
    checkFondsDoesNotContainSeries(parentFonds);
    childFonds.setReferenceParentFonds(parentFonds);
    return createNewFonds(childFonds);
}
Also used : Fonds(nikita.common.model.noark5.v4.Fonds)

Aggregations

Fonds (nikita.model.noark5.v4.Fonds)28 Counted (com.codahale.metrics.annotation.Counted)27 ApiOperation (io.swagger.annotations.ApiOperation)27 ApiResponses (io.swagger.annotations.ApiResponses)27 Timed (com.codahale.metrics.annotation.Timed)18 Fonds (nikita.common.model.noark5.v4.Fonds)15 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)14 Authorisation (nikita.webapp.security.Authorisation)13 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)10 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)9 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)8 ArrayList (java.util.ArrayList)5 Series (nikita.model.noark5.v4.Series)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 List (java.util.List)4 FondsCreatorHateoas (nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas)4 SeriesHateoas (nikita.common.model.noark5.v4.hateoas.SeriesHateoas)4 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)4 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)3