use of nikita.common.model.noark5.v4.BasicRecord in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordService method findBasicRecordByOwnerPaginated.
// All READ operations
@Override
public List<BasicRecord> findBasicRecordByOwnerPaginated(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<BasicRecord> criteriaQuery = criteriaBuilder.createQuery(BasicRecord.class);
Root<BasicRecord> from = criteriaQuery.from(BasicRecord.class);
CriteriaQuery<BasicRecord> select = criteriaQuery.select(from);
criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
TypedQuery<BasicRecord> typedQuery = entityManager.createQuery(select);
typedQuery.setFirstResult(skip);
typedQuery.setMaxResults(maxPageSize);
return typedQuery.getResultList();
}
use of nikita.common.model.noark5.v4.BasicRecord in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String basicRecordSystemId) {
BasicRecord basicRecord = getBasicRecordOrThrow(basicRecordSystemId);
basicRecordRepository.delete(basicRecord);
}
use of nikita.common.model.noark5.v4.BasicRecord in project nikita-noark5-core by HiOA-ABI.
the class FileService method createBasicRecordAssociatedWithFile.
@Override
public BasicRecord createBasicRecordAssociatedWithFile(String fileSystemId, BasicRecord basicRecord) {
BasicRecord persistedBasicRecord = null;
File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
basicRecord.setReferenceFile(file);
persistedBasicRecord = (BasicRecord) recordService.save(basicRecord);
}
return persistedBasicRecord;
}
use of nikita.common.model.noark5.v4.BasicRecord in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String basicRecordSystemId) {
BasicRecord basicRecord = getBasicRecordOrThrow(basicRecordSystemId);
basicRecordRepository.delete(basicRecord);
}
use of nikita.common.model.noark5.v4.BasicRecord in project nikita-noark5-core by HiOA-ABI.
the class FileService method createBasicRecordAssociatedWithFile.
@Override
public BasicRecord createBasicRecordAssociatedWithFile(String fileSystemId, BasicRecord basicRecord) {
BasicRecord persistedBasicRecord;
File file = fileRepository.findBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
basicRecord.setReferenceFile(file);
persistedBasicRecord = (BasicRecord) recordService.save(basicRecord);
}
return persistedBasicRecord;
}
Aggregations