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;
}
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;
}
use of nikita.common.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();
}
use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String fondsSystemId) {
Fonds fonds = getFondsOrThrow(fondsSystemId);
// 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();
//fondsRepository.delete(fonds);
}
use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsService method createFondsCreatorAssociatedWithFonds.
public FondsCreator createFondsCreatorAssociatedWithFonds(String fondsSystemId, FondsCreator fondsCreator) {
Fonds fonds = fondsRepository.findBySystemIdOrderBySystemId(fondsSystemId);
if (fonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + fondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
fondsCreatorService.createNewFondsCreator(fondsCreator);
fondsCreator.addFonds(fonds);
fonds.getReferenceFondsCreator().add(fondsCreator);
return fondsCreator;
}
Aggregations