← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5780: I18n db, validation module

 

------------------------------------------------------------
revno: 5780
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-01-22 09:38:11 +0100
message:
  I18n db, validation module
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.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/validation/DefaultValidationRuleService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java	2012-01-22 08:38:11 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
 import static org.hisp.dhis.system.util.MathUtils.expressionIsTrue;
 import static org.hisp.dhis.system.util.MathUtils.getRounded;
 
@@ -36,6 +37,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.dataelement.DataElement;
@@ -43,6 +45,7 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -76,8 +79,7 @@
 
     private GenericIdentifiableObjectStore<ValidationRuleGroup> validationRuleGroupStore;
 
-    public void setValidationRuleGroupStore(
-        GenericIdentifiableObjectStore<ValidationRuleGroup> validationRuleGroupStore )
+    public void setValidationRuleGroupStore( GenericIdentifiableObjectStore<ValidationRuleGroup> validationRuleGroupStore )
     {
         this.validationRuleGroupStore = validationRuleGroupStore;
     }
@@ -110,6 +112,13 @@
         this.dataElementService = dataElementService;
     }
 
+    private I18nService i18nService;
+
+    public void setI18nService( I18nService service )
+    {
+        i18nService = service;
+    }
+
     // -------------------------------------------------------------------------
     // ValidationRule business logic
     // -------------------------------------------------------------------------
@@ -129,7 +138,7 @@
         }
 
         grid.addRow();
-        grid.addValue( "" );
+        grid.addValue( StringUtils.EMPTY );
 
         for ( Period period : periods )
         {
@@ -392,22 +401,22 @@
 
     public ValidationRule getValidationRule( int id )
     {
-        return validationRuleStore.get( id );
+        return i18n( i18nService, validationRuleStore.get( id ) );
     }
 
     public ValidationRule getValidationRule( String uid )
     {
-        return validationRuleStore.getByUid( uid );
+        return i18n( i18nService, validationRuleStore.getByUid( uid ) );
     }
 
     public ValidationRule getValidationRuleByName( String name )
     {
-        return validationRuleStore.getByName( name );
+        return i18n( i18nService, validationRuleStore.getByName( name ) );
     }
 
     public Collection<ValidationRule> getAllValidationRules()
     {
-        return validationRuleStore.getAll();
+        return i18n( i18nService, validationRuleStore.getAll() );
     }
 
     public Collection<ValidationRule> getValidationRules( final Collection<Integer> identifiers )
@@ -425,12 +434,32 @@
 
     public Collection<ValidationRule> getValidationRulesByName( String name )
     {        
-        return validationRuleStore.getLikeName( name );
+        return i18n( i18nService, validationRuleStore.getLikeName( name ) );
     }
     
     public Collection<ValidationRule> getValidationRulesByDataElements( Collection<DataElement> dataElements )
     {
-        return validationRuleStore.getValidationRulesByDataElements( dataElements );
+        return i18n( i18nService, validationRuleStore.getValidationRulesByDataElements( dataElements ) );
+    }
+
+    public int getValidationRuleCount()
+    {
+        return validationRuleStore.getCount();
+    }
+
+    public int getValidationRuleCountByName( String name )
+    {
+        return validationRuleStore.getCountByName( name );
+    }
+
+    public Collection<ValidationRule> getValidationRulesBetween( int first, int max )
+    {
+        return i18n( i18nService, validationRuleStore.getBetween( first, max ) );
+    }
+
+    public Collection<ValidationRule> getValidationRulesBetweenByName( String name, int first, int max )
+    {
+        return i18n( i18nService, validationRuleStore.getBetweenByName( name, first, max ) );
     }
 
     // -------------------------------------------------------------------------
@@ -454,42 +483,22 @@
 
     public ValidationRuleGroup getValidationRuleGroup( int id )
     {
-        return validationRuleGroupStore.get( id );
+        return i18n( i18nService, validationRuleGroupStore.get( id ) );
     }
 
     public ValidationRuleGroup getValidationRuleGroup( String uid )
     {
-        return validationRuleGroupStore.getByUid( uid );
+        return i18n( i18nService, validationRuleGroupStore.getByUid( uid ) );
     }
 
     public Collection<ValidationRuleGroup> getAllValidationRuleGroups()
     {
-        return validationRuleGroupStore.getAll();
+        return i18n( i18nService, validationRuleGroupStore.getAll() );
     }
 
     public ValidationRuleGroup getValidationRuleGroupByName( String name )
     {
-        return validationRuleGroupStore.getByName( name );
-    }
-
-    public int getValidationRuleCount()
-    {
-        return validationRuleStore.getCount();
-    }
-
-    public int getValidationRuleCountByName( String name )
-    {
-        return validationRuleStore.getCountByName( name );
-    }
-
-    public Collection<ValidationRule> getValidationRulesBetween( int first, int max )
-    {
-        return validationRuleStore.getBetween( first, max );
-    }
-
-    public Collection<ValidationRule> getValidationRulesBetweenByName( String name, int first, int max )
-    {
-        return validationRuleStore.getBetweenByName( name, first, max );
+        return i18n( i18nService, validationRuleGroupStore.getByName( name ) );
     }
 
     public int getValidationRuleGroupCount()
@@ -504,12 +513,11 @@
 
     public Collection<ValidationRuleGroup> getValidationRuleGroupsBetween( int first, int max )
     {
-        return validationRuleGroupStore.getBetween( first, max );
+        return i18n( i18nService, validationRuleGroupStore.getBetween( first, max ) );
     }
 
     public Collection<ValidationRuleGroup> getValidationRuleGroupsBetweenByName( String name, int first, int max )
     {
-        return validationRuleGroupStore.getBetweenByName( name, first, max );
+        return i18n( i18nService, validationRuleGroupStore.getBetweenByName( name, first, max ) );
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-01-22 08:21:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-01-22 08:38:11 +0000
@@ -343,7 +343,8 @@
     <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />	
+    <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
   </bean>
 
   <bean id="org.hisp.dhis.dataelement.DataElementCategoryService" class="org.hisp.dhis.dataelement.DefaultDataElementCategoryService">

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm	2011-09-26 09:31:56 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm	2012-01-22 08:38:11 +0000
@@ -37,7 +37,7 @@
 			<table class="listTable" id="listTable"> 
 				<col/>
 				<col/>
-				<col width="96px">				
+				<col width="120px">				
 				<thead>							
 				<tr>
 					<th>$i18n.getString( "name" )</th>
@@ -48,12 +48,13 @@
 				<tbody id="list">
 				#foreach( $validationRule in $validationRulesList )
 				<tr id="tr${validationRule.id}">
-					<td onclick="showValidationRuleDetails( $validationRule.id )">$!encoder.htmlEncode( $validationRule.name )</td>
+					<td onclick="showValidationRuleDetails( $validationRule.id )">$!encoder.htmlEncode( $validationRule.displayName )</td>
 					<td onclick="showValidationRuleDetails( $validationRule.id )">$i18n.getString($!validationRule.periodType.name) </td>
 					<td style="text-align:right">
 						<a href="showUpdateValidationRuleForm.action?id=$validationRule.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+						<a href="javascript:translate( 'ValidationRule', '$validationRule.id' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a>
 						#if( $auth.hasAccess( "dhis-web-validationrule", "removeValidationRule" ) )
-						<a href="javascript:removeValidationRule( $validationRule.id, '$encoder.jsEncode( $validationRule.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+						<a href="javascript:removeValidationRule( $validationRule.id, '$encoder.jsEncode( $validationRule.displayName )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
 						#else <img src="../images/delete-denied.png"> #end
 						<a href="javascript:showValidationRuleDetails( $validationRule.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
 					</td>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.vm	2011-03-18 14:58:26 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.vm	2012-01-22 08:38:11 +0000
@@ -20,7 +20,7 @@
 
             <table class="listTable" id="listTable">
                 <col>
-                <col width="96px">                
+                <col width="120px">                
                 <thead>  
                 <tr>
                     <th>$i18n.getString( "name" )</th>
@@ -30,11 +30,12 @@
                 <tbody id="list">
                 #foreach( $group in $validationRuleGroups )
                 <tr id="tr${group.id}">
-                    <td onclick="showValidationRuleGroupDetails( $group.id )">$!encoder.htmlEncode( $group.name )</td>
+                    <td onclick="showValidationRuleGroupDetails( $group.id )">$!encoder.htmlEncode( $group.displayName )</td>
                     <td style="text-align:right">
 						<a href="showUpdateValidationRuleGroupForm.action?id=$group.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
+						<a href="javascript:translate( 'ValidationRuleGroup', '$group.id' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a>
 						#if( $auth.hasAccess( "dhis-web-validationrule", "removeValidationRuleGroup" ) )
-						<a href="javascript:removeValidationRuleGroup( $group.id, '$encoder.jsEncode( $group.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
+						<a href="javascript:removeValidationRuleGroup( $group.id, '$encoder.jsEncode( $group.displayName )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
 						#else <img src="../images/delete-denied.png"> #end
 						<a href="javascript:showValidationRuleGroupDetails( $group.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
 					</td>