Search in sources :

Example 1 with AuditableEntity

use of org.hisp.dhis.artemis.audit.AuditableEntity in project dhis2-core by dhis2.

the class AbstractEventAuditPostProcessor method process.

@Override
public void process(final Event event, final WorkContext ctx) {
    final AuditManager auditManager = ctx.getServiceDelegator().getAuditManager();
    final EventImporterUserService eventImporterUserService = ctx.getServiceDelegator().getEventImporterUserService();
    final ProgramStageInstanceMapper programStageInstanceMapper = new ProgramStageInstanceMapper(ctx);
    final ProgramStageInstance programStageInstance = programStageInstanceMapper.map(event);
    auditManager.send(Audit.builder().auditType(getAuditType()).auditScope(AuditScope.TRACKER).createdAt(LocalDateTime.now()).createdBy(eventImporterUserService.getAuditUsername()).object(programStageInstance).auditableEntity(new AuditableEntity(ProgramStageInstance.class, programStageInstance)).build());
}
Also used : EventImporterUserService(org.hisp.dhis.dxf2.events.importer.EventImporterUserService) AuditableEntity(org.hisp.dhis.artemis.audit.AuditableEntity) AuditManager(org.hisp.dhis.artemis.audit.AuditManager) ProgramStageInstanceMapper(org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance)

Example 2 with AuditableEntity

use of org.hisp.dhis.artemis.audit.AuditableEntity in project dhis2-core by dhis2.

the class HibernatePotentialDuplicateStore method auditMerge.

@Override
public void auditMerge(DeduplicationMergeParams params) {
    TrackedEntityInstance duplicate = params.getDuplicate();
    MergeObject mergeObject = params.getMergeObject();
    mergeObject.getRelationships().forEach(rel -> {
        duplicate.getRelationshipItems().stream().map(RelationshipItem::getRelationship).filter(r -> r.getUid().equals(rel)).findAny().ifPresent(relationship -> auditManager.send(Audit.builder().auditScope(AuditScope.TRACKER).auditType(AuditType.UPDATE).createdAt(LocalDateTime.now()).object(relationship).klass(HibernateProxyUtils.getRealClass(relationship).getCanonicalName()).uid(rel).auditableEntity(new AuditableEntity(Relationship.class, relationship)).build()));
    });
}
Also used : AuditableEntity(org.hisp.dhis.artemis.audit.AuditableEntity) MergeObject(org.hisp.dhis.deduplication.MergeObject) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance)

Example 3 with AuditableEntity

use of org.hisp.dhis.artemis.audit.AuditableEntity in project dhis2-core by dhis2.

the class JdbcMaintenanceStore method auditHardDeletedEntity.

private void auditHardDeletedEntity(List<String> deletedEnrollments, Class<? extends SoftDeletableObject> entity) {
    deletedEnrollments.forEach(enrolment -> {
        SoftDeletableObject object = ENTITY_MAPPER.getOrDefault(entity, new SoftDeletableObject());
        object.setUid(enrolment);
        object.setDeleted(true);
        auditManager.send(Audit.builder().auditType(AuditType.DELETE).auditScope(AuditScope.TRACKER).createdAt(LocalDateTime.now()).object(object).uid(enrolment).auditableEntity(new AuditableEntity(entity, object)).build());
    });
}
Also used : AuditableEntity(org.hisp.dhis.artemis.audit.AuditableEntity) SoftDeletableObject(org.hisp.dhis.common.SoftDeletableObject)

Aggregations

AuditableEntity (org.hisp.dhis.artemis.audit.AuditableEntity)3 AuditManager (org.hisp.dhis.artemis.audit.AuditManager)1 SoftDeletableObject (org.hisp.dhis.common.SoftDeletableObject)1 MergeObject (org.hisp.dhis.deduplication.MergeObject)1 EventImporterUserService (org.hisp.dhis.dxf2.events.importer.EventImporterUserService)1 ProgramStageInstanceMapper (org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper)1 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)1 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)1