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;
}
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();
}
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;
}
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;
}
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();
}
Aggregations