Search in sources :

Example 6 with ImportSummaries

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;
}
Also used : User(org.hisp.dhis.user.User) ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries)

Example 7 with 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;
}
Also used : User(org.hisp.dhis.user.User) ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries)

Example 8 with 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;
}
Also used : ArrayList(java.util.ArrayList) Enrollment(org.hisp.dhis.dxf2.events.enrollment.Enrollment) ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries)

Example 9 with 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;
}
Also used : ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries)

Example 10 with 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;
}
Also used : ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries) ImportOptions(org.hisp.dhis.dxf2.common.ImportOptions)

Aggregations

ImportSummaries (org.hisp.dhis.dxf2.importsummary.ImportSummaries)26 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)10 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)9 InputStream (java.io.InputStream)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 Date (java.util.Date)6 Lists (com.google.common.collect.Lists)5 IOException (java.io.IOException)5 List (java.util.List)5 Set (java.util.Set)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 DhisApiVersion (org.hisp.dhis.common.DhisApiVersion)5 OrganisationUnitSelectionMode (org.hisp.dhis.common.OrganisationUnitSelectionMode)5 StreamUtils (org.hisp.dhis.commons.util.StreamUtils)5 TextUtils (org.hisp.dhis.commons.util.TextUtils)5 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 StringUtils (org.apache.commons.lang3.StringUtils)4