Search in sources :

Example 1 with DataValue

use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.

the class DefaultCsvEventService method writeEvents.

@Override
public void writeEvents(OutputStream outputStream, Events events, boolean withHeader) throws IOException {
    ObjectWriter writer = CSV_MAPPER.writer(CSV_SCHEMA.withUseHeader(withHeader));
    List<CsvEventDataValue> dataValues = new ArrayList<>();
    for (Event event : events.getEvents()) {
        CsvEventDataValue templateDataValue = new CsvEventDataValue();
        templateDataValue.setEvent(event.getEvent());
        templateDataValue.setStatus(event.getStatus() != null ? event.getStatus().name() : null);
        templateDataValue.setProgram(event.getProgram());
        templateDataValue.setProgramStage(event.getProgramStage());
        templateDataValue.setEnrollment(event.getEnrollment());
        templateDataValue.setOrgUnit(event.getOrgUnit());
        templateDataValue.setEventDate(event.getEventDate());
        templateDataValue.setDueDate(event.getDueDate());
        templateDataValue.setStoredBy(event.getStoredBy());
        if (event.getCoordinate() != null) {
            templateDataValue.setLatitude(event.getCoordinate().getLatitude());
            templateDataValue.setLongitude(event.getCoordinate().getLongitude());
        }
        for (DataValue value : event.getDataValues()) {
            CsvEventDataValue dataValue = new CsvEventDataValue(templateDataValue);
            dataValue.setDataElement(value.getDataElement());
            dataValue.setValue(value.getValue());
            dataValue.setProvidedElsewhere(value.getProvidedElsewhere());
            if (value.getStoredBy() != null) {
                dataValue.setStoredBy(value.getStoredBy());
            }
            dataValues.add(dataValue);
        }
    }
    writer.writeValue(outputStream, dataValues);
}
Also used : DataValue(org.hisp.dhis.dxf2.events.event.DataValue) ArrayList(java.util.ArrayList) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) Event(org.hisp.dhis.dxf2.events.event.Event)

Example 2 with DataValue

use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.

the class DataValueController method saveDataValue.

// ---------------------------------------------------------------------
// POST
// ---------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void saveDataValue(@RequestParam String de, @RequestParam(required = false) String co, @RequestParam(required = false) String cc, @RequestParam(required = false) String cp, @RequestParam String pe, @RequestParam String ou, @RequestParam(required = false) String value, @RequestParam(required = false) String comment, @RequestParam(required = false) boolean followUp, HttpServletResponse response) throws WebMessageException {
    boolean strictPeriods = (Boolean) systemSettingManager.getSystemSetting(SettingKey.DATA_IMPORT_STRICT_PERIODS);
    boolean strictCategoryOptionCombos = (Boolean) systemSettingManager.getSystemSetting(SettingKey.DATA_IMPORT_STRICT_CATEGORY_OPTION_COMBOS);
    boolean strictOrgUnits = (Boolean) systemSettingManager.getSystemSetting(SettingKey.DATA_IMPORT_STRICT_ORGANISATION_UNITS);
    boolean requireCategoryOptionCombo = (Boolean) systemSettingManager.getSystemSetting(SettingKey.DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO);
    // ---------------------------------------------------------------------
    // Input validation
    // ---------------------------------------------------------------------
    DataElement dataElement = getAndValidateDataElement(de);
    DataElementCategoryOptionCombo categoryOptionCombo = getAndValidateCategoryOptionCombo(co, requireCategoryOptionCombo);
    DataElementCategoryOptionCombo attributeOptionCombo = getAndValidateAttributeOptionCombo(cc, cp);
    Period period = getAndValidatePeriod(pe);
    OrganisationUnit organisationUnit = getAndValidateOrganisationUnit(ou);
    validateInvalidFuturePeriod(period, dataElement);
    validateAttributeOptionComboWithOrgUnitAndPeriod(attributeOptionCombo, organisationUnit, period);
    String valueValid = ValidationUtils.dataValueIsValid(value, dataElement);
    if (valueValid != null) {
        throw new WebMessageException(WebMessageUtils.conflict("Invalid value: " + value + ", must match data element type: " + dataElement.getValueType()));
    }
    String commentValid = ValidationUtils.commentIsValid(comment);
    if (commentValid != null) {
        throw new WebMessageException(WebMessageUtils.conflict("Invalid comment: " + comment));
    }
    OptionSet optionSet = dataElement.getOptionSet();
    if (!Strings.isNullOrEmpty(value) && optionSet != null && !optionSet.getOptionCodesAsSet().contains(value)) {
        throw new WebMessageException(WebMessageUtils.conflict("Data value is not a valid option of the data element option set: " + dataElement.getUid()));
    }
    if (strictPeriods && !dataElement.getPeriodTypes().contains(period.getPeriodType())) {
        throw new WebMessageException(WebMessageUtils.conflict("Period type of period: " + period.getIsoDate() + " not valid for data element: " + dataElement.getUid()));
    }
    if (strictCategoryOptionCombos && !dataElement.getCategoryOptionCombos().contains(categoryOptionCombo)) {
        throw new WebMessageException(WebMessageUtils.conflict("Category option combo: " + categoryOptionCombo.getUid() + " must be part of category combo of data element: " + dataElement.getUid()));
    }
    if (strictOrgUnits && !organisationUnit.hasDataElement(dataElement)) {
        throw new WebMessageException(WebMessageUtils.conflict("Data element: " + dataElement.getUid() + " must be assigned through data sets to organisation unit: " + organisationUnit.getUid()));
    }
    // ---------------------------------------------------------------------
    // Locking validation
    // ---------------------------------------------------------------------
    validateDataSetNotLocked(dataElement, period, organisationUnit, attributeOptionCombo);
    // ---------------------------------------------------------------------
    // Period validation
    // ---------------------------------------------------------------------
    validateDataInputPeriodForDataElementAndPeriod(dataElement, period);
    // ---------------------------------------------------------------------
    // Assemble and save data value
    // ---------------------------------------------------------------------
    String storedBy = currentUserService.getCurrentUsername();
    Date now = new Date();
    DataValue dataValue = dataValueService.getDataValue(dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo);
    FileResource fileResource = null;
    if (dataValue == null) {
        if (dataElement.getValueType() == ValueType.FILE_RESOURCE) {
            if (value != null) {
                fileResource = fileResourceService.getFileResource(value);
                if (fileResource == null || fileResource.getDomain() != FileResourceDomain.DATA_VALUE) {
                    throw new WebMessageException(WebMessageUtils.notFound(FileResource.class, value));
                }
                if (fileResource.isAssigned()) {
                    throw new WebMessageException(WebMessageUtils.conflict("File resource already assigned or linked to another data value"));
                }
                fileResource.setAssigned(true);
            } else {
                throw new WebMessageException(WebMessageUtils.conflict("Missing parameter 'value'"));
            }
        }
        dataValue = new DataValue(dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo, StringUtils.trimToNull(value), storedBy, now, StringUtils.trimToNull(comment));
        dataValueService.addDataValue(dataValue);
    } else {
        if (value == null && ValueType.TRUE_ONLY.equals(dataElement.getValueType())) {
            if (comment == null) {
                dataValueService.deleteDataValue(dataValue);
                return;
            } else {
                value = "false";
            }
        }
        if (dataElement.isFileType()) {
            fileResourceService.deleteFileResource(dataValue.getValue());
        }
        if (value != null) {
            dataValue.setValue(StringUtils.trimToNull(value));
        }
        if (comment != null) {
            dataValue.setComment(StringUtils.trimToNull(comment));
        }
        if (followUp) {
            dataValue.toggleFollowUp();
        }
        dataValue.setLastUpdated(now);
        dataValue.setStoredBy(storedBy);
        dataValueService.updateDataValue(dataValue);
    }
    if (fileResource != null) {
        fileResourceService.updateFileResource(fileResource);
    }
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) DataValue(org.hisp.dhis.datavalue.DataValue) FileResource(org.hisp.dhis.fileresource.FileResource) Period(org.hisp.dhis.period.Period) OptionSet(org.hisp.dhis.option.OptionSet) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DataValue

use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.

the class AnalyticsUtils method getDataValueSetFromGrid.

/**
     * Generates a data value set based on the given grid with aggregated data.
     * Sets the created and last updated fields to the current date.
     * 
     * @param params the data query parameters.
     * @param grid the grid.
     * @return a data value set.
     */
public static DataValueSet getDataValueSetFromGrid(DataQueryParams params, Grid grid) {
    int dxInx = grid.getIndexOfHeader(DATA_X_DIM_ID);
    int peInx = grid.getIndexOfHeader(PERIOD_DIM_ID);
    int ouInx = grid.getIndexOfHeader(ORGUNIT_DIM_ID);
    int coInx = grid.getIndexOfHeader(CATEGORYOPTIONCOMBO_DIM_ID);
    int aoInx = grid.getIndexOfHeader(ATTRIBUTEOPTIONCOMBO_DIM_ID);
    int vlInx = grid.getWidth() - 1;
    Assert.isTrue(dxInx >= 0, "Data dimension index must be greater than or equal to zero");
    Assert.isTrue(peInx >= 0, "Period dimension index must be greater than or equal to zero");
    Assert.isTrue(ouInx >= 0, "Org unit dimension index must be greater than or equal to zero");
    Assert.isTrue(coInx >= 0, "Category option combo dimension index must be greater than or equal to zero");
    Assert.isTrue(aoInx >= 0, "Attribute option combo dimension index must be greater than or equal to zero");
    Assert.isTrue(vlInx >= 0, "Value index must be greater than or equal to zero");
    String created = DateUtils.getMediumDateString();
    DataValueSet dvs = new DataValueSet();
    Set<String> primaryKeys = Sets.newHashSet();
    for (List<Object> row : grid.getRows()) {
        DataValue dv = new DataValue();
        Object coc = row.get(coInx);
        Object aoc = row.get(aoInx);
        dv.setDataElement(String.valueOf(row.get(dxInx)));
        dv.setPeriod(String.valueOf(row.get(peInx)));
        dv.setOrgUnit(String.valueOf(row.get(ouInx)));
        dv.setCategoryOptionCombo(coc != null ? String.valueOf(coc) : null);
        dv.setAttributeOptionCombo(aoc != null ? String.valueOf(aoc) : null);
        dv.setValue(String.valueOf(row.get(vlInx)));
        dv.setComment(KEY_AGG_VALUE);
        dv.setStoredBy(KEY_AGG_VALUE);
        dv.setCreated(created);
        dv.setLastUpdated(created);
        if (!params.isDuplicatesOnly() || !primaryKeys.add(dv.getPrimaryKey())) {
            dvs.getDataValues().add(dv);
        }
    }
    return dvs;
}
Also used : DataValueSet(org.hisp.dhis.dxf2.datavalueset.DataValueSet) DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DimensionalObject(org.hisp.dhis.common.DimensionalObject) DateUtils.getMediumDateString(org.hisp.dhis.system.util.DateUtils.getMediumDateString)

Example 4 with DataValue

use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.

the class AnalyticsUtils method getDataValueSetFromGrid.

/**
 * Generates a data value set based on the given grid with aggregated data.
 * Sets the created and last updated fields to the current date.
 *
 * @param params the data query parameters.
 * @param grid the grid.
 * @return a data value set.
 */
public static DataValueSet getDataValueSetFromGrid(DataQueryParams params, Grid grid) {
    int dxInx = grid.getIndexOfHeader(DATA_X_DIM_ID);
    int peInx = grid.getIndexOfHeader(PERIOD_DIM_ID);
    int ouInx = grid.getIndexOfHeader(ORGUNIT_DIM_ID);
    int coInx = grid.getIndexOfHeader(CATEGORYOPTIONCOMBO_DIM_ID);
    int aoInx = grid.getIndexOfHeader(ATTRIBUTEOPTIONCOMBO_DIM_ID);
    int vlInx = grid.getHeaderWidth() - 1;
    Assert.isTrue(dxInx >= 0, "Data dimension index must be greater than or equal to zero");
    Assert.isTrue(peInx >= 0, "Period dimension index must be greater than or equal to zero");
    Assert.isTrue(ouInx >= 0, "Org unit dimension index must be greater than or equal to zero");
    Assert.isTrue(coInx >= 0, "Category option combo dimension index must be greater than or equal to zero");
    Assert.isTrue(aoInx >= 0, "Attribute option combo dimension index must be greater than or equal to zero");
    Assert.isTrue(vlInx >= 0, "Value index must be greater than or equal to zero");
    String created = DateUtils.getMediumDateString();
    DataValueSet dvs = new DataValueSet();
    Set<String> primaryKeys = Sets.newHashSet();
    for (List<Object> row : grid.getRows()) {
        DataValue dv = new DataValue();
        Object coc = row.get(coInx);
        Object aoc = row.get(aoInx);
        dv.setDataElement(String.valueOf(row.get(dxInx)));
        dv.setPeriod(String.valueOf(row.get(peInx)));
        dv.setOrgUnit(String.valueOf(row.get(ouInx)));
        dv.setCategoryOptionCombo(coc != null ? String.valueOf(coc) : null);
        dv.setAttributeOptionCombo(aoc != null ? String.valueOf(aoc) : null);
        dv.setValue(String.valueOf(row.get(vlInx)));
        dv.setComment(KEY_AGG_VALUE);
        dv.setStoredBy(KEY_AGG_VALUE);
        dv.setCreated(created);
        dv.setLastUpdated(created);
        if (!params.isDuplicatesOnly() || !primaryKeys.add(dv.getPrimaryKey())) {
            dvs.getDataValues().add(dv);
        }
    }
    return dvs;
}
Also used : DataValueSet(org.hisp.dhis.dxf2.datavalueset.DataValueSet) DataValue(org.hisp.dhis.dxf2.datavalue.DataValue) DimensionalObject(org.hisp.dhis.common.DimensionalObject) DataDimensionalItemObject(org.hisp.dhis.common.DataDimensionalItemObject) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) DateUtils.getMediumDateString(org.hisp.dhis.util.DateUtils.getMediumDateString)

Example 5 with DataValue

use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.

the class AbstractEventService method getEvent.

@Transactional(readOnly = true)
@Override
public Event getEvent(ProgramStageInstance programStageInstance, boolean isSynchronizationQuery, boolean skipOwnershipCheck) {
    if (programStageInstance == null) {
        return null;
    }
    Event event = new Event();
    event.setEvent(programStageInstance.getUid());
    if (programStageInstance.getProgramInstance().getEntityInstance() != null) {
        event.setTrackedEntityInstance(programStageInstance.getProgramInstance().getEntityInstance().getUid());
    }
    event.setFollowup(programStageInstance.getProgramInstance().getFollowup());
    event.setEnrollmentStatus(EnrollmentStatus.fromProgramStatus(programStageInstance.getProgramInstance().getStatus()));
    event.setStatus(programStageInstance.getStatus());
    event.setEventDate(DateUtils.getIso8601NoTz(programStageInstance.getExecutionDate()));
    event.setDueDate(DateUtils.getIso8601NoTz(programStageInstance.getDueDate()));
    event.setStoredBy(programStageInstance.getStoredBy());
    event.setCompletedBy(programStageInstance.getCompletedBy());
    event.setCompletedDate(DateUtils.getIso8601NoTz(programStageInstance.getCompletedDate()));
    event.setCreated(DateUtils.getIso8601NoTz(programStageInstance.getCreated()));
    event.setCreatedByUserInfo(programStageInstance.getCreatedByUserInfo());
    event.setLastUpdatedByUserInfo(programStageInstance.getLastUpdatedByUserInfo());
    event.setCreatedAtClient(DateUtils.getIso8601NoTz(programStageInstance.getCreatedAtClient()));
    event.setLastUpdated(DateUtils.getIso8601NoTz(programStageInstance.getLastUpdated()));
    event.setLastUpdatedAtClient(DateUtils.getIso8601NoTz(programStageInstance.getLastUpdatedAtClient()));
    event.setGeometry(programStageInstance.getGeometry());
    event.setDeleted(programStageInstance.isDeleted());
    if (programStageInstance.getAssignedUser() != null) {
        event.setAssignedUser(programStageInstance.getAssignedUser().getUid());
        event.setAssignedUserUsername(programStageInstance.getAssignedUser().getUsername());
        event.setAssignedUserDisplayName(programStageInstance.getAssignedUser().getName());
    }
    User user = currentUserService.getCurrentUser();
    OrganisationUnit ou = programStageInstance.getOrganisationUnit();
    List<String> errors = trackerAccessManager.canRead(user, programStageInstance, skipOwnershipCheck);
    if (!errors.isEmpty()) {
        throw new IllegalQueryException(errors.toString());
    }
    if (ou != null) {
        event.setOrgUnit(ou.getUid());
        event.setOrgUnitName(ou.getName());
    }
    Program program = programStageInstance.getProgramInstance().getProgram();
    event.setProgram(program.getUid());
    event.setEnrollment(programStageInstance.getProgramInstance().getUid());
    event.setProgramStage(programStageInstance.getProgramStage().getUid());
    CategoryOptionCombo attributeOptionCombo = programStageInstance.getAttributeOptionCombo();
    if (attributeOptionCombo != null) {
        event.setAttributeOptionCombo(attributeOptionCombo.getUid());
        event.setAttributeCategoryOptions(String.join(";", attributeOptionCombo.getCategoryOptions().stream().map(CategoryOption::getUid).collect(Collectors.toList())));
    }
    if (programStageInstance.getProgramInstance().getEntityInstance() != null) {
        event.setTrackedEntityInstance(programStageInstance.getProgramInstance().getEntityInstance().getUid());
    }
    Collection<EventDataValue> dataValues;
    if (!isSynchronizationQuery) {
        dataValues = programStageInstance.getEventDataValues();
    } else {
        Set<String> dataElementsToSync = programStageInstance.getProgramStage().getProgramStageDataElements().stream().filter(psde -> !psde.getSkipSynchronization()).map(psde -> psde.getDataElement().getUid()).collect(Collectors.toSet());
        dataValues = programStageInstance.getEventDataValues().stream().filter(dv -> dataElementsToSync.contains(dv.getDataElement())).collect(Collectors.toSet());
    }
    for (EventDataValue dataValue : dataValues) {
        if (getDataElement(user.getUid(), dataValue.getDataElement())) {
            DataValue value = new DataValue();
            value.setCreated(DateUtils.getIso8601NoTz(dataValue.getCreated()));
            value.setCreatedByUserInfo(dataValue.getCreatedByUserInfo());
            value.setLastUpdated(DateUtils.getIso8601NoTz(dataValue.getLastUpdated()));
            value.setLastUpdatedByUserInfo(dataValue.getLastUpdatedByUserInfo());
            value.setDataElement(dataValue.getDataElement());
            value.setValue(dataValue.getValue());
            value.setProvidedElsewhere(dataValue.getProvidedElsewhere());
            value.setStoredBy(dataValue.getStoredBy());
            event.getDataValues().add(value);
        } else {
            log.info("Can not find a Data Element having UID [" + dataValue.getDataElement() + "]");
        }
    }
    event.getNotes().addAll(NoteHelper.convertNotes(programStageInstance.getComments()));
    event.setRelationships(programStageInstance.getRelationshipItems().stream().filter(Objects::nonNull).map((r) -> relationshipService.getRelationship(r.getRelationship(), RelationshipParams.FALSE, user)).collect(Collectors.toSet()));
    return event;
}
Also used : ListGrid(org.hisp.dhis.system.grid.ListGrid) Arrays(java.util.Arrays) CategoryService(org.hisp.dhis.category.CategoryService) FIRST_PAGE(org.hisp.dhis.common.SlimPager.FIRST_PAGE) CategoryOption(org.hisp.dhis.category.CategoryOption) ValidationUtils(org.hisp.dhis.system.util.ValidationUtils) EventRow(org.hisp.dhis.dxf2.events.report.EventRow) ProgramStageDataElement(org.hisp.dhis.program.ProgramStageDataElement) StringUtils(org.apache.commons.lang3.StringUtils) EVENT_CREATED_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_CREATED_ID) EVENT_EXECUTION_DATE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_EXECUTION_DATE_ID) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) EnrollmentStatus(org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus) EventSyncService(org.hisp.dhis.program.EventSyncService) FileResourceService(org.hisp.dhis.fileresource.FileResourceService) Map(java.util.Map) EventDataValue(org.hisp.dhis.eventdatavalue.EventDataValue) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) EVENT_STATUS_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_STATUS_ID) OrganisationUnitSelectionMode(org.hisp.dhis.common.OrganisationUnitSelectionMode) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) DateUtils.getMediumDateString(org.hisp.dhis.util.DateUtils.getMediumDateString) Set(java.util.Set) SchemaService(org.hisp.dhis.schema.SchemaService) TrackerOwnershipManager(org.hisp.dhis.trackedentity.TrackerOwnershipManager) Slf4j(lombok.extern.slf4j.Slf4j) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) TrackedEntityComment(org.hisp.dhis.trackedentitycomment.TrackedEntityComment) ProgramType(org.hisp.dhis.program.ProgramType) ProgramInstanceService(org.hisp.dhis.program.ProgramInstanceService) TrackedEntityCommentService(org.hisp.dhis.trackedentitycomment.TrackedEntityCommentService) EVENT_STORED_BY_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_STORED_BY_ID) QueryItem(org.hisp.dhis.common.QueryItem) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) EVENT_GEOMETRY(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_GEOMETRY) ArrayList(java.util.ArrayList) RelationshipParams(org.hisp.dhis.dxf2.events.RelationshipParams) Lists(com.google.common.collect.Lists) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) SlimPager(org.hisp.dhis.common.SlimPager) ImportConflicts(org.hisp.dhis.dxf2.importsummary.ImportConflicts) EventManager(org.hisp.dhis.dxf2.events.importer.EventManager) EVENT_ENROLLMENT_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ENROLLMENT_ID) IdSchemes(org.hisp.dhis.common.IdSchemes) RelationshipService(org.hisp.dhis.dxf2.events.relationship.RelationshipService) DEFAULT_PAGE_SIZE(org.hisp.dhis.common.Pager.DEFAULT_PAGE_SIZE) ImportOptions(org.hisp.dhis.dxf2.common.ImportOptions) ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries) TrackedEntityInstanceService(org.hisp.dhis.trackedentity.TrackedEntityInstanceService) DebugUtils(org.hisp.dhis.commons.util.DebugUtils) ERROR(org.hisp.dhis.system.notification.NotificationLevel.ERROR) CodeGenerator(org.hisp.dhis.common.CodeGenerator) ProgramService(org.hisp.dhis.program.ProgramService) DateUtils(org.hisp.dhis.util.DateUtils) EVENT_PROGRAM_STAGE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_PROGRAM_STAGE_ID) PAGER_META_KEY(org.hisp.dhis.dxf2.events.event.EventSearchParams.PAGER_META_KEY) Authorities(org.hisp.dhis.security.Authorities) Date(java.util.Date) WorkContextLoader(org.hisp.dhis.dxf2.events.importer.context.WorkContextLoader) OrganisationUnitService(org.hisp.dhis.organisationunit.OrganisationUnitService) EVENT_LAST_UPDATED_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_LAST_UPDATED_ID) ProgramStageInstanceService(org.hisp.dhis.program.ProgramStageInstanceService) NoteHelper(org.hisp.dhis.dxf2.events.NoteHelper) EVENT_PROGRAM_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_PROGRAM_ID) EVENT_DUE_DATE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_DUE_DATE_ID) UserService(org.hisp.dhis.user.UserService) Collection(java.util.Collection) EventStatus(org.hisp.dhis.event.EventStatus) Collectors(java.util.stream.Collectors) QueryService(org.hisp.dhis.query.QueryService) EventRows(org.hisp.dhis.dxf2.events.report.EventRows) Objects(java.util.Objects) List(java.util.List) CollectionUtils.isNotEmpty(org.apache.commons.collections4.CollectionUtils.isNotEmpty) EventImporter(org.hisp.dhis.dxf2.events.importer.EventImporter) TrackerAccessManager(org.hisp.dhis.trackedentity.TrackerAccessManager) Cache(org.hisp.dhis.cache.Cache) EVENT_ORG_UNIT_NAME(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ORG_UNIT_NAME) EVENT_CREATED_BY_USER_INFO_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_CREATED_BY_USER_INFO_ID) EVENT_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ID) HashMap(java.util.HashMap) ObjectUtils.defaultIfNull(org.apache.commons.lang3.ObjectUtils.defaultIfNull) Program(org.hisp.dhis.program.Program) HashSet(java.util.HashSet) DataElement(org.hisp.dhis.dataelement.DataElement) WorkContext(org.hisp.dhis.dxf2.events.importer.context.WorkContext) Notifier(org.hisp.dhis.system.notification.Notifier) DbmsManager(org.hisp.dhis.dbms.DbmsManager) GridHeader(org.hisp.dhis.common.GridHeader) User(org.hisp.dhis.user.User) ImportStatus(org.hisp.dhis.dxf2.importsummary.ImportStatus) EVENT_ORG_UNIT_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ORG_UNIT_ID) EVENT_LAST_UPDATED_BY_USER_INFO_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_LAST_UPDATED_BY_USER_INFO_ID) Collections.emptyMap(java.util.Collections.emptyMap) EVENT_DELETED(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_DELETED) Pager(org.hisp.dhis.common.Pager) Grid(org.hisp.dhis.common.Grid) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) NotificationLevel(org.hisp.dhis.system.notification.NotificationLevel) EVENT_ATTRIBUTE_OPTION_COMBO_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ATTRIBUTE_OPTION_COMBO_ID) CurrentUserService(org.hisp.dhis.user.CurrentUserService) CachingMap(org.hisp.dhis.commons.collection.CachingMap) Collections(java.util.Collections) EVENT_COMPLETED_BY_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_COMPLETED_BY_ID) EVENT_COMPLETED_DATE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_COMPLETED_DATE_ID) Transactional(org.springframework.transaction.annotation.Transactional) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) User(org.hisp.dhis.user.User) Program(org.hisp.dhis.program.Program) EventDataValue(org.hisp.dhis.eventdatavalue.EventDataValue) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) DateUtils.getMediumDateString(org.hisp.dhis.util.DateUtils.getMediumDateString) EventDataValue(org.hisp.dhis.eventdatavalue.EventDataValue) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Test (org.junit.jupiter.api.Test)58 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)33 DataValue (org.hisp.dhis.dxf2.datavalue.DataValue)32 DataValue (org.hisp.dhis.datavalue.DataValue)31 DataSetContext (org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext)29 DataValueContext (org.hisp.dhis.dxf2.datavalueset.ImportContext.DataValueContext)28 DataElement (org.hisp.dhis.dataelement.DataElement)26 DataValue (org.hisp.dhis.dxf2.events.event.DataValue)26 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)21 Event (org.hisp.dhis.dxf2.events.event.Event)20 ClassPathResource (org.springframework.core.io.ClassPathResource)20 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)16 Period (org.hisp.dhis.period.Period)16 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)11 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)11 ArrayList (java.util.ArrayList)10 Date (java.util.Date)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)8 User (org.hisp.dhis.user.User)8