Search in sources :

Example 1 with ProgramStageInstanceMapper

use of org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper in project dhis2-core by dhis2.

the class DefaultEventPersistenceService method update.

/**
 * Updates the list of given events using a single transaction.
 *
 * @param context a {@see WorkContext}
 * @param events a List of {@see Event}
 */
@Override
@Transactional
public void update(final WorkContext context, final List<Event> events) {
    if (isNotEmpty(events)) {
        ProgramStageInstanceMapper mapper = new ProgramStageInstanceMapper(context);
        List<ProgramStageInstance> programStageInstances = jdbcEventStore.updateEvents(events.stream().map(mapper::map).collect(Collectors.toList()));
        jdbcEventCommentStore.saveAllComments(programStageInstances);
        if (!context.getImportOptions().isSkipLastUpdated()) {
            updateTeis(context, events);
        }
    }
}
Also used : ProgramStageInstanceMapper(org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ProgramStageInstanceMapper

use of org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper 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 3 with ProgramStageInstanceMapper

use of org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper in project dhis2-core by dhis2.

the class DefaultEventPersistenceService method save.

@Override
@Transactional
public void save(WorkContext context, List<Event> events) {
    if (isNotEmpty(events)) {
        ProgramStageInstanceMapper mapper = new ProgramStageInstanceMapper(context);
        List<ProgramStageInstance> programStageInstances = jdbcEventStore.saveEvents(events.stream().map(mapper::map).collect(Collectors.toList()));
        jdbcEventCommentStore.saveAllComments(programStageInstances);
        if (!context.getImportOptions().isSkipLastUpdated()) {
            updateTeis(context, events);
        }
    }
}
Also used : ProgramStageInstanceMapper(org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ProgramStageInstanceMapper (org.hisp.dhis.dxf2.events.importer.mapper.ProgramStageInstanceMapper)3 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)3 Transactional (org.springframework.transaction.annotation.Transactional)2 AuditManager (org.hisp.dhis.artemis.audit.AuditManager)1 AuditableEntity (org.hisp.dhis.artemis.audit.AuditableEntity)1 EventImporterUserService (org.hisp.dhis.dxf2.events.importer.EventImporterUserService)1