Search in sources :

Example 1 with FondsCreator

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

the class FondsCreatorDeserializer method deserialize.

@Override
public FondsCreator deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    FondsCreator fondsCreator = new FondsCreator();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseFondsCreator(fondsCreator, objectNode);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The arkivskaper you tried to create is malformed. The " + "following fields are not recognised as arkivskaper fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return fondsCreator;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FondsCreator(nikita.model.noark5.v4.FondsCreator) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Example 2 with FondsCreator

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

the class FondsCreatorService method deleteEntity.

// All DELETE operations
@Override
public void deleteEntity(@NotNull String fondsCreatorSystemId) {
    FondsCreator fondsCreator = getFondsCreatorOrThrow(fondsCreatorSystemId);
    // See issue for a description of why this code was written this way
    // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
    Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE f_pk_fonds_creator_id = :id ;");
    q.setParameter("id", fondsCreator.getId());
    q.executeUpdate();
    entityManager.remove(fondsCreator);
    entityManager.flush();
    entityManager.clear();
}
Also used : CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) FondsCreator(nikita.model.noark5.v4.FondsCreator)

Example 3 with FondsCreator

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

Example 4 with FondsCreator

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

Example 5 with FondsCreator

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

the class FondsCreatorService method findFondsCreatorByOwnerPaginated.

// All READ operations
@Override
public List<FondsCreator> findFondsCreatorByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<FondsCreator> criteriaQuery = criteriaBuilder.createQuery(FondsCreator.class);
    Root<FondsCreator> from = criteriaQuery.from(FondsCreator.class);
    CriteriaQuery<FondsCreator> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<FondsCreator> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(maxPageSize);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FondsCreator(nikita.model.noark5.v4.FondsCreator)

Aggregations

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