use of nikita.common.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassifiactionSystemDeserializer method deserialize.
@Override
public ClassificationSystem deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
ClassificationSystem classificationSystem = new ClassificationSystem();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(classificationSystem, objectNode);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The klassifikasjonssystem you tried to create is " + "malformed. The following fields are not recognised as klassifikasjonssystem fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return classificationSystem;
}
use of nikita.common.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String classificationSystemSystemId) {
ClassificationSystem classificationSystem = getClassificationSystemOrThrow(classificationSystemSystemId);
classificationSystemRepository.delete(classificationSystem);
}
use of nikita.common.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method findClassificationSystemByOwnerPaginated.
// All READ operations
@Override
public List<ClassificationSystem> findClassificationSystemByOwnerPaginated(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<ClassificationSystem> criteriaQuery = criteriaBuilder.createQuery(ClassificationSystem.class);
Root<ClassificationSystem> from = criteriaQuery.from(ClassificationSystem.class);
CriteriaQuery<ClassificationSystem> select = criteriaQuery.select(from);
criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
TypedQuery<ClassificationSystem> typedQuery = entityManager.createQuery(select);
typedQuery.setFirstResult(skip);
typedQuery.setMaxResults(maxPageSize);
return typedQuery.getResultList();
}
use of nikita.common.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method getClassificationSystemOrThrow.
// 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 ClassificationSystem back. If there is no valid
* ClassificationSystem, an exception is thrown
*
* @param classificationSystemSystemId
* @return
*/
protected ClassificationSystem getClassificationSystemOrThrow(@NotNull String classificationSystemSystemId) {
ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemIdOrderBySystemId(classificationSystemSystemId);
if (classificationSystem == null) {
String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using systemId " + classificationSystemSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return classificationSystem;
}
use of nikita.common.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemService method createClassAssociatedWithClassificationSystem.
@Override
public Class createClassAssociatedWithClassificationSystem(String classificationSystemSystemId, Class klass) {
Class persistedClass = null;
ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemIdOrderBySystemId(classificationSystemSystemId);
if (classificationSystem == null) {
String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using classificationSystemSystemId " + classificationSystemSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
klass.setReferenceClassificationSystem(classificationSystem);
persistedClass = classService.save(klass);
}
return persistedClass;
}
Aggregations