=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java 2011-05-05 21:28:46 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java 2011-05-31 05:38:55 +0000 @@ -101,12 +101,6 @@ return rightSideTextualExpression; } - private String validationOperator; - - public String getValidationOperator() - { - return validationOperator; - } private PeriodType periodType; public PeriodType getPeriodType() @@ -130,8 +124,6 @@ leftSideTextualExpression = VALID.equals( leftSideResult ) ? expressionService.getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult ); rightSideTextualExpression = VALID.equals( rightSideResult ) ? expressionService.getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult ); - validationOperator = validationRule.getOperator().toString(); - periodType = validationRule.getPeriodType(); return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/SetupTreeAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/SetupTreeAction.java 2011-05-05 21:15:45 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/SetupTreeAction.java 2011-05-31 05:38:55 +0000 @@ -27,12 +27,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.List; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.validation.ValidationRuleGroup; +import org.hisp.dhis.validation.ValidationRuleService; +import org.hisp.dhis.validation.comparator.ValidationRuleGroupNameComparator; import com.opensymphony.xwork2.Action; @@ -53,14 +59,14 @@ { this.selectionTreeManager = selectionTreeManager; } - + private OrganisationUnitSelectionManager selectionManager; public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) { this.selectionManager = selectionManager; } - + private CurrentUserService currentUserService; public void setCurrentUserService( CurrentUserService currentUserService ) @@ -68,13 +74,31 @@ this.currentUserService = currentUserService; } + private ValidationRuleService validationRuleService; + + public void setValidationRuleService( ValidationRuleService validationRuleService ) + { + this.validationRuleService = validationRuleService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List validationRuleGroups; + + public List getValidationRuleGroups() + { + return validationRuleGroups; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - + public String execute() throws Exception - { + { if ( currentUserService.getCurrentUser() != null ) { Collection orgUnits = currentUserService.getCurrentUser().getOrganisationUnits(); @@ -91,7 +115,11 @@ { selectionTreeManager.setSelectedOrganisationUnits( selectionManager.getSelectedOrganisationUnits() ); } - + + validationRuleGroups = new ArrayList( validationRuleService.getAllValidationRuleGroups() ); + + Collections.sort( validationRuleGroups, new ValidationRuleGroupNameComparator() ); + return SUCCESS; } } === added file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowRunValidationFormAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowRunValidationFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowRunValidationFormAction.java 2011-05-31 05:38:55 +0000 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.validationrule.action; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.validation.ValidationRuleGroup; +import org.hisp.dhis.validation.ValidationRuleService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ ShowRunValidationFormAction.java May 31, 2011 11:30:17 AM $ + * + */ +public class ShowRunValidationFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + private ValidationRuleService validationRuleService; + + public void setValidationRuleService( ValidationRuleService validationRuleService ) + { + this.validationRuleService = validationRuleService; + } private List validationRuleGroups; + + public List getValidationRuleGroups() + { + return validationRuleGroups; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + if ( currentUserService.getCurrentUser() != null ) + { + Collection orgUnits = currentUserService.getCurrentUser().getOrganisationUnits(); + + if ( orgUnits.size() > 0 ) + { + selectionTreeManager.setRootOrganisationUnits( orgUnits ); + } + } + + selectionTreeManager.clearSelectedOrganisationUnits(); + + if ( selectionManager.getSelectedOrganisationUnits() != null ) + { + selectionTreeManager.setSelectedOrganisationUnits( selectionManager.getSelectedOrganisationUnits() ); + } + + validationRuleGroups = new ArrayList( validationRuleService.getAllValidationRuleGroups() ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java 2011-05-31 05:38:55 +0000 @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.validationrule.action; + +import static org.hisp.dhis.expression.ExpressionService.VALID; + +import java.util.Collection; + +import org.hisp.dhis.expression.ExpressionService; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.validation.ValidationRule; +import org.hisp.dhis.validation.ValidationRuleService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ ShowUpdateValidationRuleFormAction.java May 31, 2011 10:48:14 AM $ + * + */ +public class ShowUpdateValidationRuleFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ValidationRuleService validationRuleService; + + public void setValidationRuleService( ValidationRuleService validationRuleService ) + { + this.validationRuleService = validationRuleService; + } + + private ExpressionService expressionService; + + public void setExpressionService( ExpressionService expressionService ) + { + this.expressionService = expressionService; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Input/output + // ------------------------------------------------------------------------- + + private int id; + + public void setId( int id ) + { + this.id = id; + } + + private ValidationRule validationRule; + + public ValidationRule getValidationRule() + { + return validationRule; + } + + private String leftSideTextualExpression; + + public String getLeftSideTextualExpression() + { + return leftSideTextualExpression; + } + + private String rightSideTextualExpression; + + public String getRightSideTextualExpression() + { + return rightSideTextualExpression; + } + + private Collection periodTypes; + + public Collection getPeriodTypes() + { + return periodTypes; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + // --------------------------------------------------------------------- + // Get periodTypes + // --------------------------------------------------------------------- + + periodTypes = periodService.getAllPeriodTypes(); + + // --------------------------------------------------------------------- + // Get validationRule + // --------------------------------------------------------------------- + + validationRule = validationRuleService.getValidationRule( id ); + + String leftSideFormula = validationRule.getLeftSide().getExpression(); + String rightSideFormula = validationRule.getRightSide().getExpression(); + + String leftSideResult = expressionService.expressionIsValid( leftSideFormula ); + String rightSideResult = expressionService.expressionIsValid( rightSideFormula ); + + leftSideTextualExpression = VALID.equals( leftSideResult ) ? expressionService + .getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult ); + rightSideTextualExpression = VALID.equals( rightSideResult ) ? expressionService + .getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/ShowUpdateValidationRuleGroupFormAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/ShowUpdateValidationRuleGroupFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/ShowUpdateValidationRuleGroupFormAction.java 2011-05-31 05:38:55 +0000 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.validationrule.action.validationrulegroup; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.validation.ValidationRule; +import org.hisp.dhis.validation.ValidationRuleGroup; +import org.hisp.dhis.validation.ValidationRuleService; +import org.hisp.dhis.validation.comparator.ValidationRuleNameComparator; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ ShowUpdateValidationRuleGroupFormAction.java May 31, 2011 11:23:59 + * AM $ + * + */ +public class ShowUpdateValidationRuleGroupFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ValidationRuleService validationRuleService; + + public void setValidationRuleService( ValidationRuleService validationRuleService ) + { + this.validationRuleService = validationRuleService; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private ValidationRuleGroup validationRuleGroup; + + public ValidationRuleGroup getValidationRuleGroup() + { + return validationRuleGroup; + } + + private List groupMembers = new ArrayList(); + + public List getGroupMembers() + { + return groupMembers; + } + + private List availableValidationRules = new ArrayList(); + + public List getAvailableValidationRules() + { + return availableValidationRules; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + // --------------------------------------------------------------------- + // Get selected group + // --------------------------------------------------------------------- + + validationRuleGroup = validationRuleService.getValidationRuleGroup( id ); + + groupMembers = new ArrayList( validationRuleGroup.getMembers() ); + + Collections.sort( groupMembers, new ValidationRuleNameComparator() ); + + // --------------------------------------------------------------------- + // Get available ValidationRules + // --------------------------------------------------------------------- + + availableValidationRules = new ArrayList( validationRuleService.getAllValidationRules() ); + + availableValidationRules.removeAll( groupMembers ); + + Collections.sort( availableValidationRules, new ValidationRuleNameComparator() ); + + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2011-03-01 04:17:29 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2011-05-31 05:38:55 +0000 @@ -24,6 +24,20 @@ + + + + + + + + + + + + @@ -84,7 +98,10 @@ - + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2011-03-29 08:15:49 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2011-05-31 05:38:55 +0000 @@ -59,11 +59,7 @@ plainTextError - - showUpdateValidationRuleFormChain - - - + /main.vm /dhis-web-validationrule/updateValidationRuleForm.vm javascript/general.js,javascript/validationForm.js,javascript/expression.js, javascript/updateValidationRuleForm.js @@ -112,15 +108,12 @@ F_VALIDATIONRULEGROUP_ADD - - getGroupMembersAndAvailableValidationRules - F_VALIDATIONRULEGROUP_UPDATE - - - + /main.vm /dhis-web-validationrule/updateValidationRuleGroupForm.vm javascript/validationRuleGroup.js, javascript/updateValidationRuleGroupForm.js + F_VALIDATIONRULEGROUP_UPDATE @@ -136,11 +129,7 @@ - - showRunValidationFormChain - - - + /main.vm /dhis-web-validationrule/runValidationForm.vm /dhis-web-validationrule/menu.vm === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/responseValidationRule.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/responseValidationRule.vm 2011-02-10 23:09:13 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/responseValidationRule.vm 2011-05-31 05:38:55 +0000 @@ -3,7 +3,7 @@ $!encoder.xmlEncode( $validationRule.name ) $!encoder.xmlEncode( $validationRule.description ) $!encoder.xmlEncode( $validationRule.type ) - $!encoder.xmlEncode( $validationRule.operator.mathematicalOperator ) + $validationRule.operator $!encoder.xmlEncode( $validationRule.leftSide.description ) $!encoder.xmlEncode( $validationRule.rightSide.description ) \ No newline at end of file