use of org.hisp.dhis.dxf2.importsummary.ImportSummaries in project dhis2-core by dhis2.
the class AbstractEventService method updateEvents.
// -------------------------------------------------------------------------
// UPDATE
// -------------------------------------------------------------------------
@Override
public ImportSummaries updateEvents(List<Event> events, boolean singleValue) {
ImportSummaries importSummaries = new ImportSummaries();
int counter = 0;
User user = currentUserService.getCurrentUser();
for (Event event : events) {
importSummaries.addImportSummary(updateEvent(event, user, singleValue, null));
if (counter % FLUSH_FREQUENCY == 0) {
clearSession();
}
counter++;
}
return importSummaries;
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummaries in project dhis2-core by dhis2.
the class AbstractEventService method addEvents.
// -------------------------------------------------------------------------
// CREATE
// -------------------------------------------------------------------------
@Override
public ImportSummaries addEvents(List<Event> events, ImportOptions importOptions) {
ImportSummaries importSummaries = new ImportSummaries();
int counter = 0;
User user = currentUserService.getCurrentUser();
for (Event event : events) {
importSummaries.addImportSummary(addEvent(event, user, importOptions));
if (counter % FLUSH_FREQUENCY == 0) {
clearSession();
}
counter++;
}
return importSummaries;
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummaries in project dhis2-core by dhis2.
the class AbstractTrackedEntityInstanceService method handleEnrollments.
// -------------------------------------------------------------------------
// HELPERS
// -------------------------------------------------------------------------
private ImportSummaries handleEnrollments(TrackedEntityInstance trackedEntityInstanceDTO, org.hisp.dhis.trackedentity.TrackedEntityInstance trackedEntityInstance, ImportOptions importOptions) {
List<Enrollment> create = new ArrayList<>();
List<Enrollment> update = new ArrayList<>();
for (Enrollment enrollment : trackedEntityInstanceDTO.getEnrollments()) {
enrollment.setTrackedEntity(trackedEntityInstanceDTO.getTrackedEntity());
enrollment.setTrackedEntityInstance(trackedEntityInstance.getUid());
if (!programInstanceService.programInstanceExists(enrollment.getEnrollment())) {
create.add(enrollment);
} else {
update.add(enrollment);
}
}
ImportSummaries importSummaries = new ImportSummaries();
importSummaries.addImportSummaries(enrollmentService.addEnrollments(create, importOptions));
importSummaries.addImportSummaries(enrollmentService.updateEnrollments(update, importOptions));
return importSummaries;
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummaries in project dhis2-core by dhis2.
the class AbstractEventService method deleteEvents.
@Override
public ImportSummaries deleteEvents(List<String> uids) {
ImportSummaries importSummaries = new ImportSummaries();
int counter = 0;
for (String uid : uids) {
importSummaries.addImportSummary(deleteEvent(uid));
if (counter % FLUSH_FREQUENCY == 0) {
clearSession();
}
counter++;
}
return importSummaries;
}
use of org.hisp.dhis.dxf2.importsummary.ImportSummaries in project dhis2-core by dhis2.
the class AbstractEnrollmentService method updateEnrollments.
// -------------------------------------------------------------------------
// UPDATE
// -------------------------------------------------------------------------
@Override
public ImportSummaries updateEnrollments(List<Enrollment> enrollments, ImportOptions importOptions) {
if (importOptions == null) {
importOptions = new ImportOptions();
}
ImportSummaries importSummaries = new ImportSummaries();
int counter = 0;
for (Enrollment enrollment : enrollments) {
importSummaries.addImportSummary(updateEnrollment(enrollment, importOptions));
if (counter % FLUSH_FREQUENCY == 0) {
clearSession();
}
counter++;
}
return importSummaries;
}
Aggregations