Search in sources :

Example 11 with FondsCreator

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

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

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

the class FondsCreatorService method handleUpdate.

// All UPDATE operations
@Override
public FondsCreator handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull FondsCreator incomingFondsCreator) {
    FondsCreator existingFondsCreator = getFondsCreatorOrThrow(systemId);
    // Here copy all the values you are allowed to copy ....
    if (null != incomingFondsCreator.getDescription()) {
        existingFondsCreator.setDescription(incomingFondsCreator.getDescription());
    }
    if (null != incomingFondsCreator.getFondsCreatorId()) {
        existingFondsCreator.setFondsCreatorId(incomingFondsCreator.getFondsCreatorId());
    }
    if (null != incomingFondsCreator.getFondsCreatorName()) {
        existingFondsCreator.setFondsCreatorName(incomingFondsCreator.getFondsCreatorName());
    }
    existingFondsCreator.setVersion(version);
    fondsCreatorRepository.save(existingFondsCreator);
    return existingFondsCreator;
}
Also used : FondsCreator(nikita.common.model.noark5.v4.FondsCreator)

Example 14 with FondsCreator

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

the class FondsCreatorService method getFondsCreatorOrThrow.

// All HELPER operations
/**
 * Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
 * If you call this, be aware that you will only ever get a valid FondsCreator back. If there is no valid
 * FondsCreator, an exception is thrown
 *
 * @param fondsCreatorSystemId
 * @return
 */
protected FondsCreator getFondsCreatorOrThrow(@NotNull String fondsCreatorSystemId) {
    FondsCreator fondsCreator = fondsCreatorRepository.findBySystemId(fondsCreatorSystemId);
    if (fondsCreator == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " FondsCreator, using systemId " + fondsCreatorSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return fondsCreator;
}
Also used : NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) FondsCreator(nikita.common.model.noark5.v4.FondsCreator)

Example 15 with FondsCreator

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

Aggregations

Counted (com.codahale.metrics.annotation.Counted)16 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 FondsCreator (nikita.model.noark5.v4.FondsCreator)11 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)10 Authorisation (nikita.webapp.security.Authorisation)9 Timed (com.codahale.metrics.annotation.Timed)8 FondsCreatorHateoas (nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas)8 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)7 FondsCreatorHateoas (nikita.model.noark5.v4.hateoas.FondsCreatorHateoas)6 Query (javax.persistence.Query)4 Fonds (nikita.common.model.noark5.v4.Fonds)4 TypedQuery (javax.persistence.TypedQuery)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)3 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 List (java.util.List)2 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)2 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)2