Search in sources :

Example 6 with TrackerType

use of org.hisp.dhis.tracker.TrackerType in project dhis2-core by dhis2.

the class TrackerImportReport method processBundleReport.

/**
 * Calculates the 'ignored' value for each type of entity in the
 * {@link TrackerBundleReport}.
 *
 * The 'ignored' value is calculated by subtracting the sum of all processed
 * entities from the TrackerBundleReport (by type) from the bundle size
 * specified in the 'bundleSize' map.
 */
private static TrackerBundleReport processBundleReport(TrackerBundleReport bundleReport, Map<TrackerType, Integer> bundleSize) {
    for (final TrackerType value : TrackerType.values()) {
        final TrackerTypeReport trackerTypeReport = bundleReport.getTypeReportMap().get(value);
        if (trackerTypeReport != null) {
            final TrackerStats stats = trackerTypeReport.getStats();
            if (stats != null) {
                int statsSize = stats.getDeleted() + stats.getCreated() + stats.getUpdated();
                stats.setIgnored(bundleSize.getOrDefault(value, statsSize) - statsSize);
            }
        }
    }
    return bundleReport;
}
Also used : TrackerType(org.hisp.dhis.tracker.TrackerType)

Example 7 with TrackerType

use of org.hisp.dhis.tracker.TrackerType in project dhis2-core by dhis2.

the class ValidationErrorReporterTest method hasErrorReportNotFound.

@Test
void hasErrorReportNotFound() {
    ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
    TrackerBundle bundle = mock(TrackerBundle.class);
    TrackerErrorReport error = TrackerErrorReport.builder().errorCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
    reporter.getReportList().add(error);
    assertFalse(reporter.hasErrorReport(r -> TrackerType.TRACKED_ENTITY.equals(r.getTrackerType())));
}
Also used : Test(org.junit.jupiter.api.Test) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TrackerType(org.hisp.dhis.tracker.TrackerType) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Mockito.mock(org.mockito.Mockito.mock) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Example 8 with TrackerType

use of org.hisp.dhis.tracker.TrackerType in project dhis2-core by dhis2.

the class ValidationErrorReporterTest method hasErrorReportFound.

@Test
void hasErrorReportFound() {
    ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
    TrackerBundle bundle = mock(TrackerBundle.class);
    TrackerErrorReport error = TrackerErrorReport.builder().errorCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
    reporter.getReportList().add(error);
    assertTrue(reporter.hasErrorReport(r -> TrackerType.EVENT.equals(r.getTrackerType())));
}
Also used : Test(org.junit.jupiter.api.Test) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TrackerType(org.hisp.dhis.tracker.TrackerType) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Mockito.mock(org.mockito.Mockito.mock) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Example 9 with TrackerType

use of org.hisp.dhis.tracker.TrackerType in project dhis2-core by dhis2.

the class ValidationErrorReporterTest method hasWarningReportNotFound.

@Test
void hasWarningReportNotFound() {
    ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
    TrackerBundle bundle = mock(TrackerBundle.class);
    TrackerWarningReport warning = TrackerWarningReport.builder().warningCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
    reporter.getWarningsReportList().add(warning);
    assertFalse(reporter.hasWarningReport(r -> TrackerType.TRACKED_ENTITY.equals(r.getTrackerType())));
}
Also used : Test(org.junit.jupiter.api.Test) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TrackerType(org.hisp.dhis.tracker.TrackerType) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Mockito.mock(org.mockito.Mockito.mock) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Example 10 with TrackerType

use of org.hisp.dhis.tracker.TrackerType in project dhis2-core by dhis2.

the class ValidationErrorReporterTest method hasWarningReportFound.

@Test
void hasWarningReportFound() {
    ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
    TrackerBundle bundle = mock(TrackerBundle.class);
    TrackerWarningReport warning = TrackerWarningReport.builder().warningCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
    reporter.getWarningsReportList().add(warning);
    assertTrue(reporter.hasWarningReport(r -> TrackerType.EVENT.equals(r.getTrackerType())));
}
Also used : Test(org.junit.jupiter.api.Test) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TrackerType(org.hisp.dhis.tracker.TrackerType) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Mockito.mock(org.mockito.Mockito.mock) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) Test(org.junit.jupiter.api.Test)

Aggregations

TrackerType (org.hisp.dhis.tracker.TrackerType)10 TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)5 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 Test (org.junit.jupiter.api.Test)4 Mockito.mock (org.mockito.Mockito.mock)4 TrackerBundleReport (org.hisp.dhis.tracker.report.TrackerBundleReport)2 TrackerTypeReport (org.hisp.dhis.tracker.report.TrackerTypeReport)2 TrackerImportValidationContext (org.hisp.dhis.tracker.validation.TrackerImportValidationContext)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 NonNull (lombok.NonNull)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Session (org.hibernate.Session)1 CategoryOption (org.hisp.dhis.category.CategoryOption)1 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)1 EventStatus (org.hisp.dhis.event.EventStatus)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 OrganisationUnitService (org.hisp.dhis.organisationunit.OrganisationUnitService)1 Program (org.hisp.dhis.program.Program)1