dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03437
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1153: Improved indicator integrity checks
------------------------------------------------------------
revno: 1153
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-12-02 16:08:11 +0100
message:
Improved indicator integrity checks
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java
dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties
dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2009-09-14 16:00:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataintegrity/DataIntegrityService.java 2009-12-02 15:08:11 +0000
@@ -83,11 +83,6 @@
// -------------------------------------------------------------------------
/**
- * Gets all indicators whith blank numerator or denominator.
- */
- Collection<Indicator> getIndicatorsWithBlankFormulas();
-
- /**
* Gets all indicators with identical numerator and denominator.
*/
Collection<Indicator> getIndicatorsWithIdenticalFormulas();
@@ -96,6 +91,16 @@
* Gets all indicators which are not assigned to any groups.
*/
Collection<Indicator> getIndicatorsWithoutGroups();
+
+ /**
+ * Gets all indicators with invalid indicator numerators.
+ */
+ Map<Indicator, String> getInvalidIndicatorNumerators();
+
+ /**
+ * Gets all indicators with invalid indicator denominators.
+ */
+ Map<Indicator, String> getInvalidIndicatorDenominators();
// -------------------------------------------------------------------------
// OrganisationUnit
@@ -141,5 +146,18 @@
// ValidationRule
// -------------------------------------------------------------------------
+ /**
+ * Gets all ValidationRules which are not members fo one or more groups.
+ */
Collection<ValidationRule> getValidationRulesWithoutGroups();
+
+ /**
+ * Gets all ValidationRules with invalid left side expressions.
+ */
+ Map<ValidationRule, String> getInvalidValidationRuleLeftSideExpressions();
+
+ /**
+ * Gets all ValidationRules with invalid right side expressions.
+ */
+ Map<ValidationRule, String> getInvalidValidationRuleRightSideExpressions();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2009-12-02 13:19:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2009-12-02 15:08:11 +0000
@@ -47,6 +47,7 @@
String ID = ExpressionService.class.getName();
final String VALID = "valid";
+ final String EXPRESSION_IS_EMPTY = "expression_is_empty";
final String DATAELEMENT_ID_NOT_NUMERIC = "dataelement_id_not_numeric";
final String CATEGORYOPTIONCOMBO_ID_NOT_NUMERIC = "category_option_combo_id_not_numeric";
final String DATAELEMENT_DOES_NOT_EXIST = "data_element_does_not_exist";
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2009-09-14 16:00:37 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2009-12-02 15:08:11 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.dataintegrity.DataIntegrityService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorService;
@@ -111,6 +112,13 @@
{
this.validationRuleService = validationRuleService;
}
+
+ private ExpressionService expressionService;
+
+ public void setExpressionService( ExpressionService expressionService )
+ {
+ this.expressionService = expressionService;
+ }
// -------------------------------------------------------------------------
// DataIntegrityService implementation
@@ -230,28 +238,6 @@
// Indicator
// -------------------------------------------------------------------------
- public Collection<Indicator> getIndicatorsWithBlankFormulas()
- {
- Collection<Indicator> indicators = indicatorService.getAllIndicators();
-
- Iterator<Indicator> iterator = indicators.iterator();
-
- while ( iterator.hasNext() )
- {
- final Indicator indicator = iterator.next();
-
- if ( indicator.getNumerator() != null &&
- indicator.getNumerator().trim().length() > 0 &&
- indicator.getDenominator() != null &&
- indicator.getDenominator().trim().length() > 0 )
- {
- iterator.remove();
- }
- }
-
- return indicators;
- }
-
public Collection<Indicator> getIndicatorsWithIdenticalFormulas()
{
List<String> formulas = new ArrayList<String>();
@@ -303,6 +289,40 @@
return indicators;
}
+ public Map<Indicator, String> getInvalidIndicatorNumerators()
+ {
+ Map<Indicator, String> invalids = new HashMap<Indicator, String>();
+
+ for ( Indicator indicator : indicatorService.getAllIndicators() )
+ {
+ String result = expressionService.expressionIsValid( indicator.getNumerator() );
+
+ if ( !result.equals( ExpressionService.VALID ) )
+ {
+ invalids.put( indicator, result );
+ }
+ }
+
+ return invalids;
+ }
+
+ public Map<Indicator, String> getInvalidIndicatorDenominators()
+ {
+ Map<Indicator, String> invalids = new HashMap<Indicator, String>();
+
+ for ( Indicator indicator : indicatorService.getAllIndicators() )
+ {
+ String result = expressionService.expressionIsValid( indicator.getDenominator() );
+
+ if ( !result.equals( ExpressionService.VALID ) )
+ {
+ invalids.put( indicator, result );
+ }
+ }
+
+ return invalids;
+ }
+
// -------------------------------------------------------------------------
// OrganisationUnit
// -------------------------------------------------------------------------
@@ -502,4 +522,38 @@
return validationRules;
}
+
+ public Map<ValidationRule, String> getInvalidValidationRuleLeftSideExpressions()
+ {
+ Map<ValidationRule, String> invalids = new HashMap<ValidationRule, String>();
+
+ for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
+ {
+ String result = expressionService.expressionIsValid( rule.getLeftSide().getExpression() );
+
+ if ( !result.equals( ExpressionService.VALID ) )
+ {
+ invalids.put( rule, result );
+ }
+ }
+
+ return invalids;
+ }
+
+ public Map<ValidationRule, String> getInvalidValidationRuleRightSideExpressions()
+ {
+ Map<ValidationRule, String> invalids = new HashMap<ValidationRule, String>();
+
+ for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
+ {
+ String result = expressionService.expressionIsValid( rule.getRightSide().getExpression() );
+
+ if ( !result.equals( ExpressionService.VALID ) )
+ {
+ invalids.put( rule, result );
+ }
+ }
+
+ return invalids;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2009-11-24 17:34:15 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2009-12-02 15:08:11 +0000
@@ -58,6 +58,8 @@
ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
<property name="validationRuleService"
ref="org.hisp.dhis.validation.ValidationRuleService"/>
+ <property name="expressionService"
+ ref="org.hisp.dhis.expression.ExpressionService"/>
</bean>
<!-- Maintenance -->
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java 2009-06-10 22:25:07 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataintegrity/DataIntegrityServiceTest.java 2009-12-02 15:08:11 +0000
@@ -254,14 +254,6 @@
}
@Test
- public void testGetIndicatorsWithBlankFormulas()
- {
- Collection<Indicator> expected = dataIntegrityService.getIndicatorsWithBlankFormulas();
-
- assertTrue( equals( expected, indicatorA ) );
- }
-
- @Test
public void testGetIndicatorsWithIdenticalFormulas()
{
Collection<Indicator> expected = dataIntegrityService.getIndicatorsWithIdenticalFormulas();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2009-12-02 13:19:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2009-12-02 15:08:11 +0000
@@ -243,6 +243,11 @@
public String expressionIsValid( String formula )
{
+ if ( formula == null )
+ {
+ return EXPRESSION_IS_EMPTY;
+ }
+
StringBuffer buffer = new StringBuffer();
final Matcher matcher = DESCRIPTION_PATTERN.matcher( formula );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2009-09-14 16:00:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataintegrity/GetDataIntegrityAction.java 2009-12-02 15:08:11 +0000
@@ -90,13 +90,6 @@
return dataElementsAssignedToDataSetsWithDifferentPeriodTypes;
}
- private Collection<Indicator> indicatorsWithBlankFormulas;
-
- public Collection<Indicator> getIndicatorsWithBlankFormulas()
- {
- return indicatorsWithBlankFormulas;
- }
-
private Collection<Indicator> indicatorsWithIdenticalFormulas;
public Collection<Indicator> getIndicatorsWithIdenticalFormulas()
@@ -110,6 +103,20 @@
{
return indicatorsWithoutGroups;
}
+
+ private Map<Indicator, String> invalidIndicatorNumerators;
+
+ public Map<Indicator, String> getInvalidIndicatorNumerators()
+ {
+ return invalidIndicatorNumerators;
+ }
+
+ private Map<Indicator, String> invalidIndicatorDenominators;
+
+ public Map<Indicator, String> getInvalidIndicatorDenominators()
+ {
+ return invalidIndicatorDenominators;
+ }
private Collection<OrganisationUnit> organisationUnitsWithCyclicReferences;
@@ -160,6 +167,20 @@
return validationRulesWithoutGroups;
}
+ private Map<ValidationRule, String> invalidValidationRuleLeftSideExpressions;
+
+ public Map<ValidationRule, String> getInvalidValidationRuleLeftSideExpressions()
+ {
+ return invalidValidationRuleLeftSideExpressions;
+ }
+
+ private Map<ValidationRule, String> invalidValidationRuleRightSideExpressions;
+
+ public Map<ValidationRule, String> getInvalidValidationRuleRightSideExpressions()
+ {
+ return invalidValidationRuleRightSideExpressions;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -172,9 +193,10 @@
dataSetsNotAssignedToOrganisationUnits = dataIntegrityService.getDataSetsNotAssignedToOrganisationUnits();
- indicatorsWithBlankFormulas = dataIntegrityService.getIndicatorsWithBlankFormulas();
indicatorsWithIdenticalFormulas = dataIntegrityService.getIndicatorsWithIdenticalFormulas();
indicatorsWithoutGroups = dataIntegrityService.getIndicatorsWithoutGroups();
+ invalidIndicatorNumerators = dataIntegrityService.getInvalidIndicatorNumerators();
+ invalidIndicatorDenominators = dataIntegrityService.getInvalidIndicatorDenominators();
organisationUnitsWithCyclicReferences = dataIntegrityService.getOrganisationUnitsWithCyclicReferences();
orphanedOrganisationUnits = dataIntegrityService.getOrphanedOrganisationUnits();
@@ -185,6 +207,8 @@
organisationUnitGroupsWithoutGroupSets = dataIntegrityService.getOrganisationUnitGroupsWithoutGroupSets();
validationRulesWithoutGroups = dataIntegrityService.getValidationRulesWithoutGroups();
+ invalidValidationRuleLeftSideExpressions = dataIntegrityService.getInvalidValidationRuleLeftSideExpressions();
+ invalidValidationRuleRightSideExpressions = dataIntegrityService.getInvalidValidationRuleRightSideExpressions();
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2009-11-25 10:01:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2009-12-02 15:08:11 +0000
@@ -122,4 +122,14 @@
intro_maintenance = Perform maintenance tasks such as pruning of data values and periods and clearing of database resource tables.
intro_resource_table = Generate resource database tables for the organisation unit hierarchy and group set structure among others.
intro_data_statistics = Browse the number of objects in the database.
-intro_cache_statistics = See the system database cache status and clear the cache.
\ No newline at end of file
+intro_cache_statistics = See the system database cache status and clear the cache.
+expression_is_empty = Expression is empty
+dataelement_id_not_numeric = Data element identifier must be a number
+category_option_combo_id_not_numeric = Category option combo identifier must be a number
+data_element_does_not_exist = Identifier does not reference a data element
+category_option_combo_does_not_exist = Identifier does not reference a category option combo
+expression_not_well_formed = Expression is not well formed
+invalid_indicator_denominators = Invalid indicator denominators
+invalid_indicator_numerators = Invalid indicator numerators
+invalid_validation_rule_left_side_expressions = Invalid validation rule left side expressions
+invalid_validation_rule_right_side_expressions = Invalid validation rule right side expressions
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 2009-09-14 16:00:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataIntegrityForm.vm 2009-12-02 15:08:11 +0000
@@ -54,15 +54,34 @@
#integrityHeader( $i18n.getString( "data_sets_not_assigned_to_organisation_units" ) $dataSetsNotAssignedToOrganisationUnits.size() "dataSetsNotAssignedToOrganisationUnits" )
#violationList( "dataSetsNotAssignedToOrganisationUnits" $dataSetsNotAssignedToOrganisationUnits )
-#integrityHeader( $i18n.getString( "indicators_with_blank_formulas" ) $indicatorsWithBlankFormulas.size() "indicatorsWithBlankFormulas" )
-#violationList( "indicatorsWithBlankFormulas" $indicatorsWithBlankFormulas )
-
#integrityHeader( $i18n.getString( "indicators_with_identical_formulas" ) $indicatorsWithIdenticalFormulas.size() "indicatorsWithIdenticalFormulas" )
#violationList( "indicatorsWithIdenticalFormulas" $indicatorsWithIdenticalFormulas )
#integrityHeader( $i18n.getString( "indicators_without_groups" ) $indicatorsWithoutGroups.size() "indicatorsWithoutGroups" )
#violationList( "indicatorsWithoutGroups" $indicatorsWithoutGroups )
+#integrityHeader( $i18n.getString( "invalid_indicator_numerators" ) $invalidIndicatorNumerators.size() "invalidIndicatorNumerators" )
+<div style="display:none" id="invalidIndicatorNumerators">
+ <table>
+ #foreach ( $indicator in $invalidIndicatorNumerators.keySet() )
+ <tr>
+ <td>${indicator.name}: $i18n.getString( $invalidIndicatorNumerators.get( $indicator ) )</td>
+ </tr>
+ #end
+ </table>
+</div>
+
+#integrityHeader( $i18n.getString( "invalid_indicator_denominators" ) $invalidIndicatorDenominators.size() "invalidIndicatorDenominators" )
+<div style="display:none" id="invalidIndicatorDenominators">
+ <table>
+ #foreach ( $indicator in $invalidIndicatorDenominators.keySet() )
+ <tr>
+ <td>${indicator.name}: $i18n.getString( $invalidIndicatorDenominators.get( $indicator ) )</td>
+ </tr>
+ #end
+ </table>
+</div>
+
#integrityHeader( $i18n.getString( "organisation_units_with_cyclic_references" ) $organisationUnitsWithCyclicReferences.size() "organisationUnitsWithCyclicReferences" )
#violationList( "organisationUnitsWithCyclicReferences" $organisationUnitsWithCyclicReferences )
@@ -83,3 +102,25 @@
#integrityHeader( $i18n.getString( "validation_rules_without_groups" ) $validationRulesWithoutGroups.size() "validationRulesWithoutGroups" )
#violationList( "validationRulesWithoutGroups" $validationRulesWithoutGroups )
+
+#integrityHeader( $i18n.getString( "invalid_validation_rule_left_side_expressions" ) $invalidValidationRuleLeftSideExpressions.size() "invalidValidationRuleLeftSideExpressions" )
+<div style="display:none" id="invalidValidationRuleLeftSideExpressions">
+ <table>
+ #foreach ( $rule in $invalidValidationRuleLeftSideExpressions.keySet() )
+ <tr>
+ <td>${rule.name}: $i18n.getString( $invalidValidationRuleLeftSideExpressions.get( $rule ) )</td>
+ </tr>
+ #end
+ </table>
+</div>
+
+#integrityHeader( $i18n.getString( "invalid_validation_rule_right_side_expressions" ) $invalidValidationRuleRightSideExpressions.size() "invalidValidationRuleRightSideExpressions" )
+<div style="display:none" id="invalidValidationRuleRightSideExpressions">
+ <table>
+ #foreach ( $rule in $invalidValidationRuleRightSideExpressions.keySet() )
+ <tr>
+ <td>${rule.name}: $i18n.getString( $invalidValidationRuleRightSideExpressions.get( $rule ) )</td>
+ </tr>
+ #end
+ </table>
+</div>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2009-12-02 13:19:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2009-12-02 15:08:11 +0000
@@ -303,11 +303,6 @@
select_period = Please select period
select_indicator = Please select indicator
annualized = Annualized
-dataelement_id_must_be_number = Data element identifier must be a number
-category_option_combo_id_must_be_number = Category option combo identifier must be a number
-id_does_not_reference_dataelement = Identifier does not reference a data element
-id_does_not_reference_category_option_combo = Identifier does not reference a category option combo
-expression_not_well_formed = Expression is not well formed
could_not_save = Could not save
object_not_deleted_associated_by_objects = Object not deleted becuause it is associated by objects of type
hide_warning = Hide warning
@@ -365,6 +360,7 @@
available_indicatorgroup = Available Indicator Groups
selected_indicatorgroup = Selected Indicator Groups
last_updated = Last updated
+expression_is_empty = Expression is empty
dataelement_id_not_numeric = Data element identifier must be a number
category_option_combo_id_not_numeric = Category option combo identifier must be a number
data_element_does_not_exist = Identifier does not reference a data element
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2009-12-02 13:19:53 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2009-12-02 15:08:11 +0000
@@ -100,6 +100,7 @@
data_quality_report = Data quality report
validation_result_details = Validation result details
validation_rule_ = Validation rule
+expression_is_empty = Expression is empty
dataelement_id_not_numeric = Data element identifier must be a number
category_option_combo_id_not_numeric = Category option combo identifier must be a number
data_element_does_not_exist = Identifier does not reference a data element