← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7125: Web api interpretation of map views

 

------------------------------------------------------------
revno: 7125
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-06-01 00:31:59 +0200
message:
  Web api interpretation of map views
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.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-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2012-05-31 21:51:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2012-05-31 22:31:59 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.user.User;
@@ -55,6 +56,8 @@
 {
     private Chart chart;
 
+    private MapView mapView;
+    
     private ReportTable reportTable;
     
     private OrganisationUnit organisationUnit; // Applicable to report table only
@@ -84,6 +87,13 @@
         this.created = new Date();
     }
 
+    public Interpretation( MapView mapView, String text )
+    {
+        this.mapView = mapView;
+        this.text = text;
+        this.created = new Date();
+    }
+    
     public Interpretation( ReportTable reportTable, OrganisationUnit organisationUnit, String text )
     {
         this.reportTable = reportTable;
@@ -106,6 +116,11 @@
         return chart != null;
     }
     
+    public boolean isMapViewInterpretation()
+    {
+        return mapView != null;
+    }
+    
     public boolean isReportTableInterpretation()
     {
         return reportTable != null;
@@ -133,6 +148,20 @@
     @JsonDeserialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public MapView getMapView()
+    {
+        return mapView;
+    }
+
+    public void setMapView( MapView mapView )
+    {
+        this.mapView = mapView;
+    }
+
+    @JsonProperty
+    @JsonDeserialize( as = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public ReportTable getReportTable()
     {
         return reportTable;

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml	2012-05-31 21:51:26 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml	2012-05-31 22:31:59 +0000
@@ -18,6 +18,9 @@
     <many-to-one name="chart" class="org.hisp.dhis.chart.Chart" column="chartid"
         foreign-key="fk_interpretation_chartid" />
 
+    <many-to-one name="mapView" class="org.hisp.dhis.mapping.MapView" column="mapviewid"
+		foreign-key="fk_interpretation_mapviewid" />
+
 	<many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" column="reporttableid"
 		foreign-key="fk_interpretation_reporttableid" />
 	

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java	2012-05-31 21:51:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java	2012-05-31 22:31:59 +0000
@@ -27,12 +27,21 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
 import org.hisp.dhis.api.utils.ContextUtils;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.chart.ChartService;
 import org.hisp.dhis.common.Pager;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.interpretation.InterpretationService;
+import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.reporttable.ReportTable;
@@ -45,12 +54,6 @@
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
 /**
  * @author Lars Helge Overland
  */
@@ -73,6 +76,9 @@
     @Autowired
     private OrganisationUnitService organisationUnitService;
     
+    @Autowired
+    private MappingService mappingService;
+    
     @Override
     protected List<Interpretation> getEntityList( WebMetaData metaData, WebOptions options )
     {
@@ -111,7 +117,7 @@
         
         if ( chart == null )
         {
-            ContextUtils.conflictResponse( response, "Chart identifier not valid: " + chartUid);
+            ContextUtils.conflictResponse( response, "Chart identifier not valid: " + chartUid );
             return;
         }
         
@@ -122,6 +128,26 @@
         ContextUtils.okResponse( response, "Chart interpretation created" );
     }
 
+    @RequestMapping( value = "/map/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
+    public void shareMapInterpretation( 
+        @PathVariable( "uid" ) String mapViewUid, 
+        @RequestBody String text, HttpServletResponse response ) throws IOException
+    {
+        MapView mapView = mappingService.getMapView( mapViewUid );
+        
+        if ( mapView == null )
+        {
+            ContextUtils.conflictResponse( response, "Map view identifier not valid: " + mapViewUid );
+            return;
+        }
+        
+        Interpretation interpretation = new Interpretation( mapView, text );
+        
+        interpretationService.saveInterpretation( interpretation );
+        
+        ContextUtils.okResponse( response, "Map view interpretation created" );
+    }
+
     @RequestMapping( value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
     public void shareReportTableInterpretation( 
         @PathVariable( "uid" ) String reportTableUid, 
@@ -165,5 +191,4 @@
 
         ContextUtils.okResponse( response, "Comment created" );
     }
-    
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2012-05-31 21:51:26 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2012-05-31 22:31:59 +0000
@@ -41,4 +41,6 @@
 add_a_comment=Add a comment
 new_interpretations=new interpretations
 new_interpretation=new interpretation
-click_to_view_report_table=Click to view report table
\ No newline at end of file
+click_to_view_report_table=Click to view report table
+click_to_view_in_data_visualizer=Click to view in Data Visualizer
+click_to_view_in_gis=Click to view in GIS
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm	2012-05-31 21:51:26 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm	2012-05-31 22:31:59 +0000
@@ -14,19 +14,23 @@
 	<div class="interpretationText">
 		${ip.text}
 	</div>
-	#if( $ip.chartInterpretation )
 	<div class="interpretationChart">
+	#if( $ip.chartInterpretation )	
 		<img style="cursor:pointer" 
 		     src="../api/charts/${ip.chart.uid}/data?date=${format.formatDate( $ip.created )}&width=530&height=300" 
 		     onclick="javascript:window.location.href='../dhis-web-visualizer/app/index.html?id=${ip.chart.uid}&date=${format.formatDate( $ip.created )}'"
-		     title="Click to view in Data Visualizer">
-	</div>
+		     title="$i18n.getString( 'click_to_view_in_data_visualizer' )">
+	#elseif( $ip.mapViewInterpretation )
+		<a class="bold" 
+		   title="$i18n.getString( 'click_to_view_in_gis' )" 
+		   href="../dhis-web-mapping/mapping/index.html?id=${ip.mapView.uid}">$encoder.htmlEncode( $ip.mapView.name )</a>
 	#else
-	<div class="interpretationChart">
 		#if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end		
-		<a class="bold" title="$i18n.getString( 'click_to_view_report_table' )" href="../dhis-web-reporting/exportTable.action?uid=${ip.reportTable.uid}?pe=${format.formatDate( $ip.created )}${ou}">$encoder.htmlEncode( $ip.reportTable.name )</a>
-	</div>
+		<a class="bold" 
+		   title="$i18n.getString( 'click_to_view_report_table' )" 
+		   href="../dhis-web-reporting/exportTable.action?uid=${ip.reportTable.uid}?pe=${format.formatDate( $ip.created )}${ou}">$encoder.htmlEncode( $ip.reportTable.name )</a>
 	#end
+	</div>
 	
 	#set( $comments = $ip.comments )
 	<div class="interpretationCommentArea">