@Override public Set<DataElement> getDataElements( ValidationRule validationRule ) { Set<DataElement> elements = new HashSet<>(); elements.addAll( expressionService.getDataElementsInExpression( validationRule.getLeftSide().getExpression() ) ); elements.addAll( expressionService.getDataElementsInExpression( validationRule.getRightSide().getExpression() ) ); return elements; }
private void upgradeExpressions() { Collection<Expression> expressions = expressionService.getAllExpressions(); for ( Expression expression : expressions ) { String expr = upgradeExpression( expression.getExpression() ); if ( expr != null ) { expression.setExpression( expr ); expressionService.updateExpression( expression ); } } }
/** * Gets all DimensionalItemObjects from the expressions and skip test. * * @param expressions set of expressions. * @param skipTest the skip test expression (if any). * @return set of all dimensional item objects found in all expressions. */ private Set<DimensionalItemObject> getDimensionItems( Set<String> expressions, Expression skipTest ) { Set<DimensionalItemObject> operands = new HashSet<>(); for ( String expression : expressions ) { operands.addAll( expressionService.getDimensionalItemObjectsInExpression( expression ) ); } if ( skipTest != null ) { operands.addAll( expressionService.getDimensionalItemObjectsInExpression( skipTest.getExpression() ) ); } return operands; }
expressionService.getAggregatesAndNonAggregatesInExpression( generator.getExpression(), aggregates, nonAggregates ); Map<String, Double> constantMap = constantService.getConstantMap(); Set<Period> outputPeriods = getPeriodsBetweenDates( predictor.getPeriodType(), startDate, endDate ); Double value = expressionService.getExpressionValue( generator, nonAggregateValueMap, constantMap, null, period.getDaysInPeriod(), aggregateValueMap );
@Override public SortedMap<Indicator, String> getInvalidIndicatorNumerators() { SortedMap<Indicator, String> invalids = new TreeMap<>(); I18n i18n = i18nManager.getI18n(); for ( Indicator indicator : indicatorService.getAllIndicators() ) { ExpressionValidationOutcome result = expressionService.expressionIsValid( indicator.getNumerator() ); if ( !result.isValid() ) { invalids.put( indicator, i18n.getString(result.getKey()) ); } } return invalids; }
Double value = expressionService.getExpressionValue( expression, values, context.getConstantMap(), null, period.getDaysInPeriod() );
@Override public String allowDeleteCategoryCombo( CategoryCombo categoryCombo ) { for ( Indicator indicator : indicatorService.getAllIndicators() ) { Set<CategoryOptionCombo> optionCombos = expressionService.getOptionCombosInExpression( indicator .getNumerator() ); optionCombos.retainAll( categoryCombo.getOptionCombos() ); if ( !optionCombos.isEmpty() ) { return indicator.getName(); } optionCombos = expressionService.getOptionCombosInExpression( indicator.getDenominator() ); optionCombos.retainAll( categoryCombo.getOptionCombos() ); if ( !optionCombos.isEmpty() ) { return indicator.getName(); } } return null; } }
@Override public Collection<ValidationRule> getValidationRulesForDataSet( DataSet dataSet ) { Set<String> elementsAndOptionCombos = new HashSet<>(); for ( DataSetElement dataSetElement : dataSet.getDataSetElements() ) { DataElement dataElement = dataSetElement.getDataElement(); elementsAndOptionCombos.add( dataElement.getUid() ); CategoryCombo catCombo = dataSetElement.hasCategoryCombo() ? dataSetElement.getCategoryCombo() : dataElement.getCategoryCombo(); for ( CategoryOptionCombo optionCombo : catCombo.getOptionCombos() ) { elementsAndOptionCombos.add( dataElement.getUid() + Expression.SEPARATOR + optionCombo.getUid() ); } } Set<ValidationRule> rulesForDataSet = new HashSet<>(); for ( ValidationRule rule : getAllFormValidationRules() ) { if ( !Sets.intersection( expressionService.getElementsAndOptionCombosInExpression( rule.getLeftSide().getExpression() ), elementsAndOptionCombos ).isEmpty() || !Sets.intersection( expressionService.getElementsAndOptionCombosInExpression( rule.getRightSide().getExpression() ), elementsAndOptionCombos ).isEmpty() ) { rulesForDataSet.add( rule ); } } return rulesForDataSet; }
.getDimensionalItemIdsInExpression( rule.getLeftSide().getExpression() ); dimensionItemIdentifiers.putValues( expressionService.getDimensionalItemIdsInExpression( rule.getRightSide().getExpression() ) );
@Override public SortedMap<Indicator, String> getInvalidIndicatorDenominators() { SortedMap<Indicator, String> invalids = new TreeMap<>(); I18n i18n = i18nManager.getI18n(); for ( Indicator indicator : indicatorService.getAllIndicators() ) { ExpressionValidationOutcome result = expressionService.expressionIsValid( indicator.getDenominator() ); if ( !result.isValid() ) { invalids.put( indicator, i18n.getString(result.getKey()) ); } } return invalids; }
/** * Evaluates the skip test expression for any sample periods in which * skip test data occurs. For any combination of period and attribute * option combo where the skip test is true, removes all sample data with * that combination of period and attribute option combo. * * @param dataMap all data values (both skip and aggregate). * @param skipTest the skip test expression. * @param constantMap constants to use in skip expression if needed. */ private void applySkipTest( MapMapMap<Period, String, DimensionalItemObject, Double> dataMap, Expression skipTest, Map<String, Double> constantMap ) { if ( skipTest != null && dataMap != null ) { for ( Period period : dataMap.keySet() ) { MapMap<String, DimensionalItemObject, Double> periodData = dataMap.get( period ); for ( String aoc : periodData.keySet() ) { Double testValue = expressionService.getExpressionValue( skipTest, periodData.get( aoc ), constantMap, null, period.getDaysInPeriod() ); if ( testValue != null && !MathUtils.isZero( testValue ) ) { periodData.remove( aoc ); } } } } }
@Override public String allowDeleteDataElement( DataElement dataElement ) { for ( Indicator indicator : indicatorService.getAllIndicators() ) { Set<DataElement> daels = expressionService.getDataElementsInExpression( indicator.getNumerator() ); if ( daels != null && daels.contains( dataElement ) ) { return indicator.getName(); } daels = expressionService.getDataElementsInExpression( indicator.getDenominator() ); if ( daels != null && daels.contains( dataElement ) ) { return indicator.getName(); } } return null; }
@Override public SortedMap<ValidationRule, String> getInvalidValidationRuleLeftSideExpressions() { SortedMap<ValidationRule, String> invalids = new TreeMap<>(); I18n i18n = i18nManager.getI18n(); for ( ValidationRule rule : validationRuleService.getAllValidationRules() ) { ExpressionValidationOutcome result = expressionService.expressionIsValid( rule.getLeftSide().getExpression() ); if ( !result.isValid() ) { invalids.put( rule, i18n.getString(result.getKey()) ); } } return invalids; }
Double value = expressionService.getExpressionValue( expression, periodValues.get( aoc ), constantMap, null, period.getDaysInPeriod() );
@Override public SortedMap<ValidationRule, String> getInvalidValidationRuleRightSideExpressions() { SortedMap<ValidationRule, String> invalids = new TreeMap<>(); I18n i18n = i18nManager.getI18n(); for ( ValidationRule rule : validationRuleService.getAllValidationRules() ) { ExpressionValidationOutcome result = expressionService.expressionIsValid( rule.getRightSide().getExpression() ); if ( !result.isValid() ) { invalids.put( rule, i18n.getString(result.getKey()) ); } } return invalids; }