← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3380: Changes for content localization of Facility Reporting Module.

 

------------------------------------------------------------
revno: 3380
committer: Tran Ng Minh Luan <Luan@MinhLuan-PC>
branch nick: dhis2
timestamp: Thu 2011-04-14 10:30:48 +0700
message:
  Changes for content localization of Facility Reporting Module.
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api/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-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java	2011-03-16 07:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileModel.java	2011-04-14 03:30:48 +0000
@@ -30,8 +30,10 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Collection;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -46,6 +48,8 @@
     private Date serverCurrentDate;
 
     private List<DataSet> datasets;
+    
+    private Collection<Locale> locales;
 
     public ActivityPlan getActivityPlan()
     {
@@ -84,6 +88,16 @@
     public void setDatasets( List<DataSet> datasets )
     {
         this.datasets = datasets;
+    }    
+
+    public Collection<Locale> getLocales()
+    {
+        return locales;
+    }
+
+    public void setLocales( Collection<Locale> locales )
+    {
+        this.locales = locales;
     }
 
     @Override
@@ -115,6 +129,7 @@
             this.activityPlan.serialize( dout );
         }
         
+        // Write current server's date
         dout.writeLong(serverCurrentDate.getTime());
 
         // Write DataSets
@@ -130,6 +145,18 @@
                 ds.serialize( dout );
             }
         }
+        
+        // Write Locales
+        if ( locales == null ){
+            dout.writeInt( 0 );
+        }else{
+            dout.writeInt(locales.size());
+            for(Locale each : locales){
+                dout.writeUTF( each.getLanguage()+"-"+each.getCountry() ); 
+            }
+        }
+        
+        
     }
 
     @Override

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java	2011-02-25 04:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/MobileOrgUnitLinks.java	2011-04-14 03:30:48 +0000
@@ -51,6 +51,8 @@
     private String uploadActivityReportUrl;
 
     private String updateDataSetUrl;
+    
+    private String changeUpdateDataSetLangUrl;
 
     @XmlAttribute
     public int getId()
@@ -112,6 +114,16 @@
     public void setUpdateDataSetUrl( String updateDataSetUrl )
     {
         this.updateDataSetUrl = updateDataSetUrl;
+    }    
+
+    public String getChangeUpdateDataSetLangUrl()
+    {
+        return changeUpdateDataSetLangUrl;
+    }
+
+    public void setChangeUpdateDataSetLangUrl( String changeUpdateDataSetLangUrl )
+    {
+        this.changeUpdateDataSetLangUrl = changeUpdateDataSetLangUrl;
     }
 
     public String getUpdateActivityPlanUrl() {
@@ -132,6 +144,7 @@
         dataOutputStream.writeUTF( this.uploadFacilityReportUrl );
         dataOutputStream.writeUTF( this.uploadActivityReportUrl );
         dataOutputStream.writeUTF( this.updateDataSetUrl );
+        dataOutputStream.writeUTF( this.changeUpdateDataSetLangUrl );
     }
 
     public void deSerialize( DataInputStream dataInputStream )
@@ -144,6 +157,7 @@
         this.uploadFacilityReportUrl = dataInputStream.readUTF();
         this.uploadActivityReportUrl = dataInputStream.readUTF();
         this.updateDataSetUrl = dataInputStream.readUTF();
+        this.changeUpdateDataSetLangUrl = dataInputStream.readUTF();
     }
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java	2011-03-22 04:36:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java	2011-04-14 03:30:48 +0000
@@ -43,6 +43,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.importexport.dxf2.model.OrgUnit;
 import org.hisp.dhis.importexport.dxf2.service.OrgUnitMapper;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -78,6 +79,8 @@
 
     private FacilityReportingService facilityReportingService;
 
+    private I18nService i18nService;
+
     @PathParam( "id" )
     private String id;
 
@@ -129,6 +132,7 @@
         mobileModel.setPrograms( programService.getPrograms( getUnit(), locale ) );
         mobileModel.setDatasets( facilityReportingService.getMobileDataSetsForUnit( getUnit(), locale ) );
         mobileModel.setServerCurrentDate( new Date() );
+        mobileModel.setLocales( i18nService.getAvailableLocales() );
         return mobileModel;
     }
 
@@ -139,6 +143,13 @@
         return facilityReportingService.getUpdatedDataSet( dataSetList, getUnit(), locale );
     }
 
+    @GET
+    @Path( "changeLanguageDataSet" )
+    public DataSetList changeLanguageDataSet( @HeaderParam( "accept-language" ) String locale )
+    {
+        return facilityReportingService.getDataSetsForLocale( getUnit(), locale );
+    }
+
     /**
      * Save a facility report for unit
      * 
@@ -195,6 +206,8 @@
             .toString() );
         orgUnit.setUpdateDataSetUrl( getOrgUnitUrlBuilder( uriInfo ).path( "updateDataSets" ).build( unit.getId() )
             .toString() );
+        orgUnit.setChangeUpdateDataSetLangUrl( getOrgUnitUrlBuilder( uriInfo ).path( "changeLanguageDataSet" )
+            .build( unit.getId() ).toString() );
         return orgUnit;
     }
 
@@ -227,4 +240,10 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    @Required
+    public void setI18nService( I18nService i18nService )
+    {
+        this.i18nService = i18nService;
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java	2011-02-25 07:08:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java	2011-04-14 03:30:48 +0000
@@ -51,5 +51,7 @@
         throws NotAllowedException;
     
     public DataSetList getUpdatedDataSet(DataSetList dataSetList, OrganisationUnit unit, String locale);
+    
+    public DataSetList getDataSetsForLocale( OrganisationUnit unit, String locale );
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2011-04-08 12:10:37 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2011-04-14 03:30:48 +0000
@@ -184,6 +184,13 @@
 
         return updatedDataSetList;
     }
+    
+    public DataSetList getDataSetsForLocale( OrganisationUnit unit, String locale ){
+        DataSetList dataSetList = new DataSetList();
+        List<DataSet> dataSets = this.getMobileDataSetsForUnit( unit, locale );
+        dataSetList.setModifiedDataSets( dataSets );
+        return dataSetList;
+    }
 
     public DataSet getDataSetForLocale( int dataSetId, Locale locale )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2011-03-22 04:36:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2011-04-14 03:30:48 +0000
@@ -37,6 +37,7 @@
     <property name="activityReportingService" ref="org.hisp.dhis.web.api.service.ActivityReportingService" />
     <property name="programService" ref="org.hisp.dhis.web.api.service.IProgramService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+    <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
   </bean>
 
   <!-- Services -->