Search in sources :

Example 1 with ValueType

use of org.hisp.dhis.common.ValueType in project dhis2-core by dhis2.

the class SaveSectionFormAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    Validate.notNull(organisationUnitId);
    Validate.notNull(isoPeriod);
    Validate.notNull(dataSetId);
    OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
    Period period = periodService.getPeriod(isoPeriod);
    boolean needsValidation = false;
    dataSet = dataSetService.getDataSet(dataSetId);
    String storedBy = currentUserService.getCurrentUsername();
    if (StringUtils.isBlank(storedBy)) {
        storedBy = "[unknown]";
    }
    HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
    Map<String, String> parameterMap = ContextUtils.getParameterMap(request);
    for (String key : parameterMap.keySet()) {
        if (key.startsWith("DE") && key.contains("OC")) {
            String[] splitKey = key.split("OC");
            Integer dataElementId = Integer.parseInt(splitKey[0].substring(2));
            Integer optionComboId = Integer.parseInt(splitKey[1]);
            String value = parameterMap.get(key);
            DataElement dataElement = dataElementService.getDataElement(dataElementId);
            DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(optionComboId);
            DataValue dataValue = dataValueService.getDataValue(dataElement, period, organisationUnit, categoryOptionCombo);
            value = value.trim();
            Boolean valueIsEmpty = value.length() == 0;
            // validate types
            Boolean correctType = true;
            ValueType valueType = dataElement.getValueType();
            if (!valueIsEmpty) {
                if (valueType.isText()) {
                } else if (ValueType.BOOLEAN == valueType) {
                    if (!ValueUtils.isBoolean(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_boolean"));
                    }
                } else if (ValueType.DATE == valueType) {
                    if (!ValueUtils.isDate(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_date"));
                    }
                } else if (ValueType.NUMBER == valueType) {
                    if (!MathUtils.isNumeric(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_number"));
                    }
                } else if (ValueType.INTEGER == valueType) {
                    if (!MathUtils.isInteger(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_integer"));
                    }
                } else if (ValueType.INTEGER_POSITIVE == valueType) {
                    if (!MathUtils.isPositiveInteger(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_positive_integer"));
                    }
                } else if (ValueType.INTEGER_NEGATIVE == valueType) {
                    if (!MathUtils.isNegativeInteger(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_negative_integer"));
                    }
                } else if (ValueType.INTEGER_ZERO_OR_POSITIVE == valueType) {
                    if (!MathUtils.isZeroOrPositiveInteger(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_zero_or_positive_integer"));
                    }
                } else if (ValueType.COORDINATE == valueType) {
                    if (!MathUtils.isCoordinate(value)) {
                        correctType = false;
                        typeViolations.put(key, "\"" + value + "\"" + " " + i18n.getString("is_invalid_coordinate"));
                    }
                }
            }
            // nothing entered
            if (valueIsEmpty || !correctType) {
                if (dataValue != null) {
                    dataValueService.deleteDataValue(dataValue);
                }
            }
            if (correctType && !valueIsEmpty) {
                if (dataValue == null) {
                    needsValidation = true;
                    dataValue = new DataValue(dataElement, period, organisationUnit, categoryOptionCombo, null, value, storedBy, new Date(), null);
                    dataValueService.addDataValue(dataValue);
                } else {
                    if (!dataValue.getValue().equals(value)) {
                        needsValidation = true;
                        dataValue.setValue(value);
                        dataValue.setLastUpdated(new Date());
                        dataValue.setStoredBy(storedBy);
                        dataValueService.updateDataValue(dataValue);
                    }
                }
            }
        }
    }
    //TODO
    DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
    CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(dataSet, period, organisationUnit, optionCombo);
    if (registration == null && complete) {
        registration = new CompleteDataSetRegistration();
        registration.setDataSet(dataSet);
        registration.setPeriod(period);
        registration.setSource(organisationUnit);
        registration.setDate(new Date());
        registration.setStoredBy(storedBy);
        registrationService.saveCompleteDataSetRegistration(registration);
    } else if (registration != null && !complete) {
        registrationService.deleteCompleteDataSetRegistration(registration);
    }
    if (typeViolations.size() > 0) {
        needsValidation = true;
    }
    if (sectionId != null) {
        for (Section section : dataSet.getSections()) {
            if (section.getId() == sectionId) {
                name = section.getName();
                dataElements = section.getDataElements();
                break;
            }
        }
    } else {
        name = "Default";
        dataElements = new ArrayList<>(dataSet.getDataElements());
        Collections.sort(dataElements);
    }
    dataValues = formUtils.getDataValueMap(organisationUnit, dataSet, period);
    validationViolations = formUtils.getValidationViolations(organisationUnit, dataElements, period);
    if (needsValidation && (!validationViolations.isEmpty() || !typeViolations.isEmpty())) {
        return ERROR;
    }
    validated = true;
    return SUCCESS;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DeflatedDataValue(org.hisp.dhis.datavalue.DeflatedDataValue) DataValue(org.hisp.dhis.datavalue.DataValue) ValueType(org.hisp.dhis.common.ValueType) Period(org.hisp.dhis.period.Period) Section(org.hisp.dhis.dataset.Section) Date(java.util.Date) HttpServletRequest(javax.servlet.http.HttpServletRequest) DataElement(org.hisp.dhis.dataelement.DataElement) CompleteDataSetRegistration(org.hisp.dhis.dataset.CompleteDataSetRegistration) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 2 with ValueType

use of org.hisp.dhis.common.ValueType in project dhis2-core by dhis2.

the class DefaultProgramDataEntryService method prepareDataEntryFormForAdd.

@Override
public String prepareDataEntryFormForAdd(String htmlCode, I18n i18n, ProgramStage programStage) {
    // ---------------------------------------------------------------------
    // Inline Javascript to add to HTML before outputting
    // ---------------------------------------------------------------------
    final String jQueryCalendar = "<script>$DATAPICKER-METHOD(\"$PROGRAMSTAGEID-$DATAELEMENTID-val\", false);</script>";
    StringBuffer sb = new StringBuffer();
    // ---------------------------------------------------------------------
    // Pattern to match data elements in the HTML code
    // ---------------------------------------------------------------------
    Matcher dataElementMatcher = INPUT_PATTERN.matcher(htmlCode);
    int tabindex = 0;
    // ---------------------------------------------------------------------
    // Iterate through all matching data element fields
    // ---------------------------------------------------------------------
    Map<String, ProgramStageDataElement> programStageDataElementMap = getProgramStageDataElementMap(programStage);
    while (dataElementMatcher.find()) {
        // -----------------------------------------------------------------
        // Get HTML input field code
        // -----------------------------------------------------------------
        String compulsory = "null";
        boolean allowProvidedElsewhere = false;
        String dateMethod = "datePickerValid";
        String inputHTML = dataElementMatcher.group(1);
        Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher(inputHTML);
        if (identifierMatcher.find() && identifierMatcher.groupCount() > 0) {
            // -------------------------------------------------------------
            // Get ID of data element
            // -------------------------------------------------------------
            String programStageUid = identifierMatcher.group(1);
            String dataElementUid = identifierMatcher.group(2);
            DataElement dataElement = null;
            String programStageName = programStage.getDisplayName();
            if (!programStageUid.equals(programStage.getUid())) {
                dataElement = dataElementService.getDataElement(dataElementUid);
                ProgramStage otherProgramStage = programStageService.getProgramStage(programStageUid);
                programStageName = otherProgramStage != null ? otherProgramStage.getDisplayName() : "N/A";
            } else {
                ProgramStageDataElement psde = programStageDataElementMap.get(dataElementUid);
                if (psde == null) {
                    return i18n.getString("some_data_element_not_exist");
                }
                dataElement = psde.getDataElement();
                compulsory = BooleanUtils.toStringTrueFalse(psde.isCompulsory());
                allowProvidedElsewhere = psde.getAllowProvidedElsewhere();
                if (psde.getAllowFutureDate()) {
                    dateMethod = "datePicker";
                }
            }
            if (dataElement == null) {
                continue;
            }
            // -------------------------------------------------------------
            // Find existing value of data element in data set
            // -------------------------------------------------------------
            TrackedEntityDataValue entityInstanceDataValue = null;
            String dataElementValue = EMPTY;
            if (inputHTML.contains("title=\"\"")) {
                inputHTML = inputHTML.replace("title=\"\"", "title=\"[ " + dataElement.getUid() + " - " + dataElement.getName() + " - " + dataElement.getValueType() + " ]\" ");
            } else {
                inputHTML += "title=\"[ " + dataElement.getUid() + " - " + dataElement.getName() + " - " + dataElement.getValueType() + " ]\" ";
            }
            // -------------------------------------------------------------
            // Set field for dataElement
            // -------------------------------------------------------------
            tabindex++;
            ValueType valueType = dataElement.getValueType();
            if (valueType.isText() || valueType.isNumeric() || ValueType.USERNAME == valueType) {
                inputHTML = populateCustomDataEntryForTextBox(dataElement, inputHTML, dataElementValue);
            } else if (ValueType.DATE == valueType || ValueType.DATETIME == valueType) {
                inputHTML = populateCustomDataEntryForDate(inputHTML, dataElementValue);
            } else if (ValueType.TRUE_ONLY == valueType) {
                inputHTML = populateCustomDataEntryForTrueOnly(dataElement, inputHTML, dataElementValue);
            } else if (ValueType.BOOLEAN == valueType) {
                inputHTML = populateCustomDataEntryForBoolean(dataElement, inputHTML, dataElementValue, i18n);
            }
            // -----------------------------------------------------------
            // Check if this dataElement is from another programStage then
            // disable
            // If programStagsInstance is completed then disabled it
            // -----------------------------------------------------------
            String disabled = "";
            if (!programStageUid.equals(programStage.getUid())) {
                disabled = "disabled=\"\"";
            } else {
                if (ValueType.DATE == valueType || ValueType.DATETIME == valueType) {
                    inputHTML += jQueryCalendar;
                }
                if (allowProvidedElsewhere) {
                    // Add ProvidedByOtherFacility checkbox
                    inputHTML = addProvidedElsewherCheckbox(inputHTML, entityInstanceDataValue, programStage);
                }
            }
            inputHTML = inputHTML.replace("$DATAELEMENTID", String.valueOf(dataElementUid));
            inputHTML = inputHTML.replace("$VALUE", dataElementValue);
            inputHTML = inputHTML.replace("$PROGRAMSTAGEID", String.valueOf(programStageUid));
            inputHTML = inputHTML.replace("$PROGRAMSTAGENAME", programStageName);
            inputHTML = inputHTML.replace("$DATAELEMENTNAME", dataElement.getName());
            inputHTML = inputHTML.replace("$DATAELEMENTTYPE", dataElement.getValueType().toString());
            inputHTML = inputHTML.replace("$DISABLED", disabled);
            inputHTML = inputHTML.replace("$COMPULSORY", compulsory);
            inputHTML = inputHTML.replace("$SAVEMODE", "false");
            inputHTML = inputHTML.replace("$TABINDEX", tabindex + "");
            inputHTML = inputHTML.replace("$DATAPICKER-METHOD", dateMethod);
            inputHTML = inputHTML.replaceAll("\\$", "\\\\\\$");
            dataElementMatcher.appendReplacement(sb, inputHTML);
        }
    }
    dataElementMatcher.appendTail(sb);
    return populateI18nStrings(sb.toString(), i18n);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) Matcher(java.util.regex.Matcher) ValueType(org.hisp.dhis.common.ValueType) TrackedEntityDataValue(org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue)

Example 3 with ValueType

use of org.hisp.dhis.common.ValueType in project dhis2-core by dhis2.

the class MinMaxOutlierAnalysisService method generateMinMaxValues.

@Override
public void generateMinMaxValues(Collection<OrganisationUnit> parents, Collection<DataElement> dataElements, Double stdDevFactor) {
    log.info("Starting min-max value generation, no of data elements: " + dataElements.size() + ", no of org units: " + parents.size());
    //Set<Integer> orgUnitIds = new HashSet<>( IdentifiableObjectUtils.getIdentifiers( organisationUnits ) );
    Date from = new DateTime(1, 1, 1, 1, 1).toDate();
    minMaxDataElementService.removeMinMaxDataElements(dataElements, parents);
    log.debug("Deleted existing min-max values");
    BatchHandler<MinMaxDataElement> batchHandler = batchHandlerFactory.createBatchHandler(MinMaxDataElementBatchHandler.class).init();
    for (DataElement dataElement : dataElements) {
        ValueType valueType = dataElement.getValueType();
        if (valueType.isNumeric()) {
            Collection<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryOptionCombos();
            for (DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos) {
                Map<Integer, Double> standardDeviations = dataAnalysisStore.getStandardDeviation(dataElement, categoryOptionCombo, parents, from);
                Map<Integer, Double> averages = dataAnalysisStore.getAverage(dataElement, categoryOptionCombo, parents, from);
                for (Integer unit : averages.keySet()) {
                    Double stdDev = standardDeviations.get(unit);
                    Double avg = averages.get(unit);
                    if (stdDev != null && avg != null) {
                        int min = (int) MathUtils.getLowBound(stdDev, stdDevFactor, avg);
                        int max = (int) MathUtils.getHighBound(stdDev, stdDevFactor, avg);
                        if (ValueType.INTEGER_POSITIVE == valueType || ValueType.INTEGER_ZERO_OR_POSITIVE == valueType) {
                            // Cannot be < 0
                            min = Math.max(0, min);
                        }
                        if (ValueType.INTEGER_NEGATIVE == valueType) {
                            // Cannot be > 0
                            max = Math.min(0, max);
                        }
                        OrganisationUnit source = new OrganisationUnit();
                        source.setId(unit);
                        batchHandler.addObject(new MinMaxDataElement(source, dataElement, categoryOptionCombo, min, max, true));
                    }
                }
            }
        }
    }
    log.info("Min-max value generation done");
    batchHandler.flush();
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ValueType(org.hisp.dhis.common.ValueType) Date(java.util.Date) DateTime(org.joda.time.DateTime) MinMaxDataElementBatchHandler(org.hisp.dhis.jdbc.batchhandler.MinMaxDataElementBatchHandler) DataElement(org.hisp.dhis.dataelement.DataElement) MinMaxDataElement(org.hisp.dhis.minmax.MinMaxDataElement) MinMaxDataElement(org.hisp.dhis.minmax.MinMaxDataElement) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 4 with ValueType

use of org.hisp.dhis.common.ValueType in project dhis2-core by dhis2.

the class JdbcEventAnalyticsTableManager method getDimensionColumns.

@Override
public List<AnalyticsTableColumn> getDimensionColumns(AnalyticsTable table) {
    final String dbl = statementBuilder.getDoubleColumnType();
    final String numericClause = " and value " + statementBuilder.getRegexpMatch() + " '" + NUMERIC_LENIENT_REGEXP + "'";
    final String dateClause = " and value " + statementBuilder.getRegexpMatch() + " '" + DATE_REGEXP + "'";
    //TODO dateClause regular expression
    List<AnalyticsTableColumn> columns = new ArrayList<>();
    if (table.getProgram().hasCategoryCombo()) {
        List<DataElementCategory> categories = table.getProgram().getCategoryCombo().getCategories();
        for (DataElementCategory category : categories) {
            if (category.isDataDimension()) {
                columns.add(new AnalyticsTableColumn(quote(category.getUid()), "character(11)", "acs." + quote(category.getUid()), category.getCreated()));
            }
        }
    }
    List<OrganisationUnitLevel> levels = organisationUnitService.getFilledOrganisationUnitLevels();
    List<OrganisationUnitGroupSet> orgUnitGroupSets = idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class);
    List<CategoryOptionGroupSet> attributeCategoryOptionGroupSets = categoryService.getAttributeCategoryOptionGroupSetsNoAcl();
    for (OrganisationUnitLevel level : levels) {
        String column = quote(PREFIX_ORGUNITLEVEL + level.getLevel());
        columns.add(new AnalyticsTableColumn(column, "character(11)", "ous." + column, level.getCreated()));
    }
    for (OrganisationUnitGroupSet groupSet : orgUnitGroupSets) {
        columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), "character(11)", "ougs." + quote(groupSet.getUid()), groupSet.getCreated()));
    }
    for (CategoryOptionGroupSet groupSet : attributeCategoryOptionGroupSets) {
        columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), "character(11)", "acs." + quote(groupSet.getUid()), groupSet.getCreated()));
    }
    for (PeriodType periodType : PeriodType.getAvailablePeriodTypes()) {
        String column = quote(periodType.getName().toLowerCase());
        columns.add(new AnalyticsTableColumn(column, "character varying(15)", "dps." + column));
    }
    for (DataElement dataElement : table.getProgram().getDataElements()) {
        ValueType valueType = dataElement.getValueType();
        String dataType = getColumnType(valueType);
        String dataClause = dataElement.isNumericType() ? numericClause : dataElement.getValueType().isDate() ? dateClause : "";
        String select = getSelectClause(valueType);
        boolean skipIndex = NO_INDEX_VAL_TYPES.contains(dataElement.getValueType()) && !dataElement.hasOptionSet();
        String sql = "(select " + select + " from trackedentitydatavalue where programstageinstanceid=psi.programstageinstanceid " + "and dataelementid=" + dataElement.getId() + dataClause + ") as " + quote(dataElement.getUid());
        columns.add(new AnalyticsTableColumn(quote(dataElement.getUid()), dataType, sql, skipIndex));
    }
    for (DataElement dataElement : table.getProgram().getDataElementsWithLegendSet()) {
        for (LegendSet legendSet : dataElement.getLegendSets()) {
            String column = quote(dataElement.getUid() + PartitionUtils.SEP + legendSet.getUid());
            String select = getSelectClause(dataElement.getValueType());
            String sql = "(select l.uid from maplegend l " + "inner join trackedentitydatavalue dv on l.startvalue <= " + select + " " + "and l.endvalue > " + select + " " + "and l.maplegendsetid=" + legendSet.getId() + " " + "and dv.programstageinstanceid=psi.programstageinstanceid " + "and dv.dataelementid=" + dataElement.getId() + numericClause + ") as " + column;
            columns.add(new AnalyticsTableColumn(column, "character(11)", sql));
        }
    }
    for (TrackedEntityAttribute attribute : table.getProgram().getNonConfidentialTrackedEntityAttributes()) {
        String dataType = getColumnType(attribute.getValueType());
        String dataClause = attribute.isNumericType() ? numericClause : attribute.isDateType() ? dateClause : "";
        String select = getSelectClause(attribute.getValueType());
        boolean skipIndex = NO_INDEX_VAL_TYPES.contains(attribute.getValueType()) && !attribute.hasOptionSet();
        String sql = "(select " + select + " from trackedentityattributevalue where trackedentityinstanceid=pi.trackedentityinstanceid " + "and trackedentityattributeid=" + attribute.getId() + dataClause + ") as " + quote(attribute.getUid());
        columns.add(new AnalyticsTableColumn(quote(attribute.getUid()), dataType, sql, skipIndex));
    }
    for (TrackedEntityAttribute attribute : table.getProgram().getNonConfidentialTrackedEntityAttributesWithLegendSet()) {
        for (LegendSet legendSet : attribute.getLegendSets()) {
            String column = quote(attribute.getUid() + PartitionUtils.SEP + legendSet.getUid());
            String select = getSelectClause(attribute.getValueType());
            String sql = "(select l.uid from maplegend l " + "inner join trackedentityattributevalue av on l.startvalue <= " + select + " " + "and l.endvalue > " + select + " " + "and l.maplegendsetid=" + legendSet.getId() + " " + "and av.trackedentityinstanceid=pi.trackedentityinstanceid " + "and av.trackedentityattributeid=" + attribute.getId() + numericClause + ") as " + column;
            columns.add(new AnalyticsTableColumn(column, "character(11)", sql));
        }
    }
    AnalyticsTableColumn psi = new AnalyticsTableColumn(quote("psi"), "character(11) not null", "psi.uid");
    AnalyticsTableColumn pi = new AnalyticsTableColumn(quote("pi"), "character(11) not null", "pi.uid");
    AnalyticsTableColumn ps = new AnalyticsTableColumn(quote("ps"), "character(11) not null", "ps.uid");
    AnalyticsTableColumn ao = new AnalyticsTableColumn(quote("ao"), "character(11) not null", "ao.uid");
    AnalyticsTableColumn erd = new AnalyticsTableColumn(quote("enrollmentdate"), "timestamp", "pi.enrollmentdate");
    AnalyticsTableColumn id = new AnalyticsTableColumn(quote("incidentdate"), "timestamp", "pi.incidentdate");
    AnalyticsTableColumn ed = new AnalyticsTableColumn(quote("executiondate"), "timestamp", "psi.executiondate");
    AnalyticsTableColumn dd = new AnalyticsTableColumn(quote("duedate"), "timestamp", "psi.duedate");
    AnalyticsTableColumn cd = new AnalyticsTableColumn(quote("completeddate"), "timestamp", "psi.completeddate");
    AnalyticsTableColumn pes = new AnalyticsTableColumn(quote("pistatus"), "character(25)", "pi.status");
    AnalyticsTableColumn es = new AnalyticsTableColumn(quote("psistatus"), "character(25)", "psi.status");
    AnalyticsTableColumn longitude = new AnalyticsTableColumn(quote("longitude"), dbl, "psi.longitude");
    AnalyticsTableColumn latitude = new AnalyticsTableColumn(quote("latitude"), dbl, "psi.latitude");
    AnalyticsTableColumn ou = new AnalyticsTableColumn(quote("ou"), "character(11) not null", "ou.uid");
    AnalyticsTableColumn oun = new AnalyticsTableColumn(quote("ouname"), "character varying(230) not null", "ou.name");
    AnalyticsTableColumn ouc = new AnalyticsTableColumn(quote("oucode"), "character varying(50)", "ou.code");
    columns.addAll(Lists.newArrayList(psi, pi, ps, ao, erd, id, ed, dd, cd, pes, es, longitude, latitude, ou, oun, ouc));
    if (databaseInfo.isSpatialSupport()) {
        String alias = "(select ST_SetSRID(ST_MakePoint(psi.longitude, psi.latitude), 4326)) as geom";
        columns.add(new AnalyticsTableColumn(quote("geom"), "geometry(Point, 4326)", alias, false, "gist"));
    }
    if (table.hasProgram() && table.getProgram().isRegistration()) {
        columns.add(new AnalyticsTableColumn(quote("tei"), "character(11)", "tei.uid"));
    }
    return filterDimensionColumns(columns);
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) ValueType(org.hisp.dhis.common.ValueType) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) UniqueArrayList(org.hisp.dhis.commons.collection.UniqueArrayList) DataElementCategory(org.hisp.dhis.dataelement.DataElementCategory) CategoryOptionGroupSet(org.hisp.dhis.dataelement.CategoryOptionGroupSet) LegendSet(org.hisp.dhis.legend.LegendSet) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) DataElement(org.hisp.dhis.dataelement.DataElement) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)

Example 5 with ValueType

use of org.hisp.dhis.common.ValueType in project dhis2-core by dhis2.

the class TestTextPatternValidationUtils method testValidateValueType.

@Test
void testValidateValueType() {
    TextPattern textTP = new TextPattern(Lists.newArrayList(textSegment));
    TextPattern numberTP = new TextPattern(Lists.newArrayList(sequentialSegment));
    for (ValueType valueType : ValueType.values()) {
        if (valueType.equals(ValueType.TEXT)) {
            assertTrue(TextPatternValidationUtils.validateValueType(textTP, valueType));
        } else if (valueType.equals(ValueType.NUMBER)) {
            assertTrue(TextPatternValidationUtils.validateValueType(numberTP, valueType));
        } else {
            assertFalse(TextPatternValidationUtils.validateValueType(textTP, valueType));
            assertFalse(TextPatternValidationUtils.validateValueType(numberTP, valueType));
        }
    }
}
Also used : ValueType(org.hisp.dhis.common.ValueType) Test(org.junit.jupiter.api.Test)

Aggregations

ValueType (org.hisp.dhis.common.ValueType)20 DataElement (org.hisp.dhis.dataelement.DataElement)10 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)5 Date (java.util.Date)4 QueryItem (org.hisp.dhis.common.QueryItem)4 Matcher (java.util.regex.Matcher)3 Collectors (java.util.stream.Collectors)3 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)3 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)3 PeriodType (org.hisp.dhis.period.PeriodType)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 Lists (com.google.common.collect.Lists)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 StringUtils (org.apache.commons.lang3.StringUtils)2 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)2