use of nikita.common.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassService method createClassAssociatedWithClass.
public Class createClassAssociatedWithClass(String classSystemId, Class klass) {
Class persistedClass = null;
Class parentKlass = classRepository.findBySystemId(classSystemId);
if (parentKlass == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Class, using classSystemId " + classSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (parentKlass.getFinalisedDate() != null) {
String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Class with classSystemId " + classSystemId + "has been finalised. Cannot associate a new class object with a finalised class object";
logger.info(info);
throw new NoarkEntityEditWhenClosedException(info);
} else {
klass.setReferenceParentClass(parentKlass);
persistedClass = this.save(klass);
}
return persistedClass;
}
use of nikita.common.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassService method findClassByOwnerPaginated.
// All READ operations
@Override
public List<Class> findClassByOwnerPaginated(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<Class> criteriaQuery = criteriaBuilder.createQuery(Class.class);
Root<Class> from = criteriaQuery.from(Class.class);
CriteriaQuery<Class> select = criteriaQuery.select(from);
criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
TypedQuery<Class> typedQuery = entityManager.createQuery(select);
typedQuery.setFirstResult(skip);
typedQuery.setMaxResults(top);
return typedQuery.getResultList();
}
use of nikita.common.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class ClassService method getClassOrThrow.
// 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 Class back. If there is no valid
* Class, an exception is thrown
*
* @param classSystemId systemId of the class object you are looking for
* @return the newly found class object or null if it does not exist
*/
protected Class getClassOrThrow(@NotNull String classSystemId) {
Class klass = classRepository.findBySystemId(classSystemId);
if (null == klass) {
String info = INFO_CANNOT_FIND_OBJECT + " Class, using systemId " + classSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return klass;
}
use of nikita.common.model.noark5.v4.Class 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.findBySystemId(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;
}
use of nikita.common.model.noark5.v4.Class in project nikita-noark5-core by HiOA-ABI.
the class RecordService method handleUpdate.
// All UPDATE operations
@Override
public Record handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull Record incomingRecord) {
Record existingRecord = getRecordOrThrow(systemId);
// Here copy all the values you are allowed to copy ....
// TODO: FIND ALL VALUES
// This might be a class that can only have values set via parameter values rather than request bodies
existingRecord.setVersion(version);
recordRepository.save(existingRecord);
return existingRecord;
}
Aggregations