Search in sources :

Example 1 with ProgramTempOwnershipAudit

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()));
    }
}
Also used : ProgramTempOwnershipAudit(org.hisp.dhis.program.ProgramTempOwnershipAudit) ProgramTempOwner(org.hisp.dhis.program.ProgramTempOwner) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ProgramTempOwnershipAudit

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) ProgramTempOwnershipAudit(org.hisp.dhis.program.ProgramTempOwnershipAudit)

Aggregations

ProgramTempOwnershipAudit (org.hisp.dhis.program.ProgramTempOwnershipAudit)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 ProgramTempOwner (org.hisp.dhis.program.ProgramTempOwner)1 Transactional (org.springframework.transaction.annotation.Transactional)1