use of org.hisp.dhis.program.ProgramTempOwnershipAudit in project dhis2-core by dhis2.
the class DefaultTrackerOwnershipManager method grantTemporaryOwnership.
@Override
@Transactional
public void grantTemporaryOwnership(TrackedEntityInstance entityInstance, Program program, User user, String reason) {
if (canSkipOwnershipCheck(user, program) || entityInstance == null) {
return;
}
if (program.isProtected()) {
if (config.isEnabled(CHANGELOG_TRACKER)) {
programTempOwnershipAuditService.addProgramTempOwnershipAudit(new ProgramTempOwnershipAudit(program, entityInstance, reason, user.getUsername()));
}
ProgramTempOwner programTempOwner = new ProgramTempOwner(program, entityInstance, reason, user, TEMPORARY_OWNERSHIP_VALIDITY_IN_HOURS);
programTempOwnerService.addProgramTempOwner(programTempOwner);
tempOwnerCache.invalidate(getTempOwnershipCacheKey(entityInstance.getUid(), program.getUid(), user.getUid()));
}
}
use of org.hisp.dhis.program.ProgramTempOwnershipAudit in project dhis2-core by dhis2.
the class HibernateProgramTempOwnershipAuditStore method getProgramTempOwnershipAudits.
@Override
public List<ProgramTempOwnershipAudit> getProgramTempOwnershipAudits(ProgramTempOwnershipAuditQueryParams params) {
CriteriaBuilder builder = getCriteriaBuilder();
JpaQueryParameters<ProgramTempOwnershipAudit> jpaParameters = newJpaParameters().addPredicates(getProgramTempOwnershipAuditPredicates(params, builder)).addOrder(root -> builder.desc(root.get("created")));
if (!params.isSkipPaging()) {
jpaParameters.setFirstResult(params.getFirst()).setMaxResults(params.getMax());
}
return getList(builder, jpaParameters);
}
Aggregations