Search in sources :

Example 1 with ProgramTempOwner

use of org.hisp.dhis.program.ProgramTempOwner 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)

Aggregations

ProgramTempOwner (org.hisp.dhis.program.ProgramTempOwner)1 ProgramTempOwnershipAudit (org.hisp.dhis.program.ProgramTempOwnershipAudit)1 Transactional (org.springframework.transaction.annotation.Transactional)1