dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03546
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1185: fixed validation rule didn't run when click Complete Data Set and Run Validation button in data e...
------------------------------------------------------------
revno: 1185
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Wed 2009-12-09 12:08:26 +0700
message:
fixed validation rule didn't run when click Complete Data Set and Run Validation button in data entry module
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
--
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-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2009-12-09 05:08:26 +0000
@@ -40,6 +40,7 @@
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.validation.ValidationResult;
import org.hisp.dhis.validation.ValidationRule;
import org.hisp.dhis.validation.ValidationRuleService;
@@ -50,120 +51,118 @@
* @author Margrethe Store
* @version $Id: ValidationAction.java 5426 2008-06-16 04:33:05Z larshelg $
*/
-public class ValidationAction
- implements Action
-{
- private static final Log log = LogFactory.getLog( ValidationAction.class );
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ValidationRuleService validationRuleService;
-
- public void setValidationRuleService( ValidationRuleService validationRuleService )
- {
- this.validationRuleService = validationRuleService;
- }
-
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
- private ExpressionService expressionService;
-
- public void setExpressionService (ExpressionService expressionService )
- {
- this.expressionService = expressionService;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private List<ValidationResult> results;
-
- public List<ValidationResult> getResults()
- {
- return results;
- }
-
- private Map<Integer, Expression> leftsideMap;
-
- public Map<Integer, Expression> getLeftsideMap()
- {
- return leftsideMap;
- }
-
- private Map<Integer, Expression> rightsideMap;
-
- public Map<Integer, Expression> getRightsideMap()
- {
- return rightsideMap;
- }
-
- private Map<Integer, String> leftsideFormulaMap;
-
- public Map<Integer, String> getLeftsideFormulaMap()
- {
- return leftsideFormulaMap;
- }
-
- private Map<Integer, String> rightsideFormulaMap;
-
- public Map<Integer, String> getRightsideFormulaMap()
- {
- return rightsideFormulaMap;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- OrganisationUnit orgUnit = selectedStateManager.getSelectedOrganisationUnit();
-
- Period period = selectedStateManager.getSelectedPeriod();
-
- DataSet dataSet = selectedStateManager.getSelectedDataSet();
-
- results = new ArrayList<ValidationResult>( validationRuleService.validate( dataSet, period, orgUnit ) );
-
- log.info( "Numer of validation violations: " + results.size() );
-
- if ( results.size() == 0 )
- {
- return NONE;
- }
- else
- {
- leftsideMap = new HashMap<Integer, Expression>( results.size() );
- rightsideMap = new HashMap<Integer, Expression>( results.size() );
-
- leftsideFormulaMap = new HashMap<Integer, String>( results.size() );
- rightsideFormulaMap = new HashMap<Integer, String>( results.size() );
-
- for ( ValidationResult result : results )
- {
- ValidationRule rule = result.getValidationRule();
- int id = rule.getId();
-
- Expression leftside = rule.getLeftSide();
- Expression rightside = rule.getRightSide();
-
- leftsideMap.put( id, leftside );
- rightsideMap.put( id, rightside );
-
- leftsideFormulaMap.put( id, expressionService.getExpressionDescription( leftside.getExpression() ) );
- rightsideFormulaMap.put( id, expressionService.getExpressionDescription( rightside.getExpression() ) );
- }
- }
-
- return SUCCESS;
- }
+public class ValidationAction implements Action {
+ private static final Log log = LogFactory.getLog(ValidationAction.class);
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ValidationRuleService validationRuleService;
+
+ public void setValidationRuleService(
+ ValidationRuleService validationRuleService) {
+ this.validationRuleService = validationRuleService;
+ }
+
+ private SelectedStateManager selectedStateManager;
+
+ public void setSelectedStateManager(
+ SelectedStateManager selectedStateManager) {
+ this.selectedStateManager = selectedStateManager;
+ }
+
+ private ExpressionService expressionService;
+
+ public void setExpressionService(ExpressionService expressionService) {
+ this.expressionService = expressionService;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService(PeriodService periodService) {
+ this.periodService = periodService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private List<ValidationResult> results;
+
+ public List<ValidationResult> getResults() {
+ return results;
+ }
+
+ private Map<Integer, Expression> leftsideMap;
+
+ public Map<Integer, Expression> getLeftsideMap() {
+ return leftsideMap;
+ }
+
+ private Map<Integer, Expression> rightsideMap;
+
+ public Map<Integer, Expression> getRightsideMap() {
+ return rightsideMap;
+ }
+
+ private Map<Integer, String> leftsideFormulaMap;
+
+ public Map<Integer, String> getLeftsideFormulaMap() {
+ return leftsideFormulaMap;
+ }
+
+ private Map<Integer, String> rightsideFormulaMap;
+
+ public Map<Integer, String> getRightsideFormulaMap() {
+ return rightsideFormulaMap;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute() throws Exception {
+ OrganisationUnit orgUnit = selectedStateManager
+ .getSelectedOrganisationUnit();
+
+ Period selectedPeriod = selectedStateManager.getSelectedPeriod();
+
+ Period period = periodService.getPeriod(selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedPeriod.getPeriodType());
+
+ DataSet dataSet = selectedStateManager.getSelectedDataSet();
+
+ results = new ArrayList<ValidationResult>(validationRuleService
+ .validate(dataSet, period, orgUnit));
+
+ log.info("Numer of validation violations: " + results.size());
+
+ if (results.size() == 0) {
+ return NONE;
+ } else {
+ leftsideMap = new HashMap<Integer, Expression>(results.size());
+ rightsideMap = new HashMap<Integer, Expression>(results.size());
+
+ leftsideFormulaMap = new HashMap<Integer, String>(results.size());
+ rightsideFormulaMap = new HashMap<Integer, String>(results.size());
+
+ for (ValidationResult result : results) {
+ ValidationRule rule = result.getValidationRule();
+ int id = rule.getId();
+
+ Expression leftside = rule.getLeftSide();
+ Expression rightside = rule.getRightSide();
+
+ leftsideMap.put(id, leftside);
+ rightsideMap.put(id, rightside);
+
+ leftsideFormulaMap.put(id, expressionService
+ .getExpressionDescription(leftside.getExpression()));
+ rightsideFormulaMap.put(id, expressionService
+ .getExpressionDescription(rightside.getExpression()));
+ }
+ }
+
+ return SUCCESS;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2009-11-25 08:19:22 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2009-12-09 05:08:26 +0000
@@ -295,5 +295,6 @@
<ref bean="org.hisp.dhis.expression.ExpressionService" />
</property>
<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
</beans>