← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11022: Including period name is map response

 

------------------------------------------------------------
revno: 11022
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-05-27 18:40:21 +0200
message:
  Including period name is map response
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java


--
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/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2013-05-25 12:22:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2013-05-27 16:40:21 +0000
@@ -215,10 +215,10 @@
             chart.getParentGraphMap().put( organisationUnit.getUid(), organisationUnit.getParentGraph() );
         }
         
-        I18nFormat format = i18nManager.getI18nFormat();
-        
         if ( chart.getPeriods() != null && !chart.getPeriods().isEmpty() )
         {
+            I18nFormat format = i18nManager.getI18nFormat();
+            
             for ( Period period : chart.getPeriods() )
             {
                 period.setName( format.formatPeriod( period ) );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java	2013-05-27 12:47:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java	2013-05-27 16:40:21 +0000
@@ -32,6 +32,8 @@
 import org.hisp.dhis.dataelement.DataElementOperandService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.mapping.MapView;
@@ -90,6 +92,9 @@
     @Autowired
     private CurrentUserService currentUserService;
 
+    @Autowired
+    private I18nManager i18nManager;
+
     //--------------------------------------------------------------------------
     // CRUD
     //--------------------------------------------------------------------------
@@ -183,15 +188,25 @@
     }
 
     @Override
-    public void postProcessEntity( Map map )
+    public void postProcessEntity( Map map ) throws Exception
     {
         for ( MapView view : map.getMapViews() )
         {
-            if ( view != null && view.getParentOrganisationUnit() != null )
+            if ( view != null )
             {
-                String parentUid = view.getParentOrganisationUnit().getUid();
-                view.setParentGraph( view.getParentOrganisationUnit().getParentGraph() + "/" + parentUid );
-                view.setParentLevel( organisationUnitService.getLevelOfOrganisationUnit( view.getParentOrganisationUnit().getId() ) );
+                if ( view.getPeriod() != null )
+                {
+                    I18nFormat format = i18nManager.getI18nFormat();
+                    
+                    view.getPeriod().setName( format.formatPeriod( view.getPeriod() ) );
+                }
+                
+                if ( view.getParentOrganisationUnit() != null )
+                {
+                    String parentUid = view.getParentOrganisationUnit().getUid();
+                    view.setParentGraph( view.getParentOrganisationUnit().getParentGraph() + "/" + parentUid );
+                    view.setParentLevel( organisationUnitService.getLevelOfOrganisationUnit( view.getParentOrganisationUnit().getId() ) );
+                }
             }
         }
     }