← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12606: Validation. Fixed issue with saving of organisation unit level of validation rule. Problem was si...

 

------------------------------------------------------------
revno: 12606
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-10-13 19:40:38 +0200
message:
  Validation. Fixed issue with saving of organisation unit level of validation rule. Problem was simply a typo in the setter methods.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/OperatorUserType.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/AddValidationRuleAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/UpdateValidationRuleAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/OperatorUserType.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/OperatorUserType.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/OperatorUserType.java	2013-10-13 17:40:38 +0000
@@ -1,7 +1,5 @@
 package org.hisp.dhis.expression;
 
-import org.hisp.dhis.hibernate.EnumUserType;
-
 /*
  * Copyright (c) 2004-2013, University of Oslo
  * All rights reserved.
@@ -30,9 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-public class OperatorUserType extends EnumUserType<Operator> { 
+import org.hisp.dhis.hibernate.EnumUserType;
 
-    public OperatorUserType() { 
-        super(Operator.class); 
-    } 
+public class OperatorUserType
+    extends EnumUserType<Operator>
+{
+    public OperatorUserType()
+    {
+        super( Operator.class );
+    }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml	2013-10-08 17:20:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml	2013-10-13 17:40:38 +0000
@@ -25,9 +25,7 @@
 
     <property name="type" />
 
-    <property name="operator" type="org.hisp.dhis.expression.OperatorUserType">
-      <column name="operator" not-null="true" unique="false" />
-    </property>
+    <property name="operator" column="operator" type="org.hisp.dhis.expression.OperatorUserType" not-null="true" />
 
     <many-to-one name="leftSide" column="leftexpressionid" class="org.hisp.dhis.expression.Expression"
       cascade="all" foreign-key="fk_validationrule_leftexpressionid" />

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/AddValidationRuleAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/AddValidationRuleAction.java	2013-10-08 17:20:57 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/AddValidationRuleAction.java	2013-10-13 17:40:38 +0000
@@ -156,7 +156,7 @@
 
     private Integer organisationUnitLevel;
     
-    public void setOrganizationUnitLevel(Integer organisationUnitLevel) 
+    public void setOrganisationUnitLevel( Integer organisationUnitLevel )
     {
         this.organisationUnitLevel = organisationUnitLevel;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/UpdateValidationRuleAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/UpdateValidationRuleAction.java	2013-10-08 17:20:57 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/UpdateValidationRuleAction.java	2013-10-13 17:40:38 +0000
@@ -159,9 +159,9 @@
         this.rightSideNullIfBlank = rightSideNullIfBlank;
     }
 
-    private String organisationUnitLevel;
-
-    public void setOrganisationUnitLevel( String organisationUnitLevel )
+    private Integer organisationUnitLevel;
+    
+    public void setOrganisationUnitLevel( Integer organisationUnitLevel )
     {
         this.organisationUnitLevel = organisationUnitLevel;
     }
@@ -226,7 +226,7 @@
         validationRule.getRightSide().setNullIfBlank( rightSideNullIfBlank );
         validationRule.getRightSide().setDataElementsInExpression( expressionService.getDataElementsInExpression( rightSideExpression ) );
         validationRule.getRightSide().setOptionCombosInExpression( expressionService.getOptionCombosInExpression( rightSideExpression ) );
-        validationRule.setOrganisationUnitLevel( organisationUnitLevel != null && !organisationUnitLevel.isEmpty() ? Integer.parseInt( organisationUnitLevel ) : null );
+        validationRule.setOrganisationUnitLevel( organisationUnitLevel );
         
         PeriodType periodType = periodService.getPeriodTypeByName( periodTypeName );
         validationRule.setPeriodType( periodType == null ? null : periodService.getPeriodTypeByClass( periodType.getClass() ) );

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm	2013-10-08 19:10:40 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm	2013-10-13 17:40:38 +0000
@@ -47,7 +47,7 @@
 		<td>
 			<select type="text" id="organisationUnitLevel" name="organisationUnitLevel">
 				#foreach( $level in $organisationUnitLevels )
-				<option value="${level.level}"#if( $validationRule.organisationUnitLevel == '${level.level}' ) selected #end>${level.level} $encoder.htmlEncode( $!level.name )</option>
+				<option value="${level.level}"#if( $validationRule.organisationUnitLevel == "${level.level}" ) selected="selected"#end>${level.level} $!encoder.htmlEncode( $level.name )</option>
 			    #end
 			</select>
 		</td>
@@ -56,7 +56,7 @@
 		<td><label for="periodType">$i18n.getString( "period_type" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 		<td><select type="text" id="periodTypeName" name="periodTypeName" disabled>
 					#foreach ( $periodType in $periodTypes )
-             		 <option value="$periodType.name" #if( $validationRule.periodType.name.equals($periodType.name ) ) selected #end>$encoder.htmlEncode( $i18n.getString($periodType.name) )</option>
+             		 <option value="$periodType.name" #if( $validationRule.periodType.name.equals($periodType.name ) ) selected #end>$encoder.htmlEncode( $i18n.getString( $periodType.name ) )</option>
             		#end						
 			</select>
 			<img title="$i18n.getString('clear_expression')" onclick='setNullExpression();' src='../images/edit-clear.png' style='width: 20px;cursor:pointer' />