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);
}
}
}
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());
}
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);
}
}
}
Aggregations