← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17997: Dashboard, added search for event reports

 

------------------------------------------------------------
revno: 17997
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-14 18:55:17 +0100
message:
  Dashboard, added search for event reports
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardSearchResult.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js


--
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/dashboard/DashboardItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java	2015-01-14 12:50:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java	2015-01-14 17:55:17 +0000
@@ -68,6 +68,7 @@
     public static final String TYPE_EVENT_CHART = "eventChart"; //TODO use enum
     public static final String TYPE_MAP = "map";
     public static final String TYPE_REPORT_TABLE = "reportTable";
+    public static final String TYPE_EVENT_REPORT = "eventReport";
     public static final String TYPE_USERS = "users";
     public static final String TYPE_REPORT_TABLES = "reportTables";
     public static final String TYPE_REPORTS = "reports";
@@ -90,9 +91,6 @@
     private List<User> users = new ArrayList<>();
 
     @Scanned
-    private List<ReportTable> reportTables = new ArrayList<>();
-
-    @Scanned
     private List<Report> reports = new ArrayList<>();
 
     @Scanned
@@ -144,10 +142,6 @@
         {
             return TYPE_USERS;
         }
-        else if ( !reportTables.isEmpty() )
-        {
-            return TYPE_REPORT_TABLES;
-        }
         else if ( !reports.isEmpty() )
         {
             return TYPE_REPORTS;
@@ -200,10 +194,6 @@
         {
             return users;
         }
-        else if ( !reportTables.isEmpty() )
-        {
-            return reportTables;
-        }
         else if ( !reports.isEmpty() )
         {
             return reports;
@@ -226,7 +216,6 @@
         count += map != null ? 1 : 0;
         count += reportTable != null ? 1 : 0;
         count += users.size();
-        count += reportTables.size();
         count += reports.size();
         count += resources.size();
         count += messages != null ? 1 : 0;
@@ -246,10 +235,6 @@
         {
             return removeContent( uid, users );
         }
-        else if ( !reportTables.isEmpty() )
-        {
-            return removeContent( uid, reportTables );
-        }
         else if ( !reports.isEmpty() )
         {
             return removeContent( uid, reports );
@@ -351,21 +336,6 @@
         this.users = users;
     }
 
-    @JsonProperty( "reportTables" )
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JacksonXmlElementWrapper( localName = "reportTables", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "reportTableItem", namespace = DxfNamespaces.DXF_2_0 )
-    public List<ReportTable> getReportTables()
-    {
-        return reportTables;
-    }
-
-    public void setReportTables( List<ReportTable> reportTables )
-    {
-        this.reportTables = reportTables;
-    }
-
     @JsonProperty( "reports" )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
@@ -439,7 +409,6 @@
             map = item.getMap() == null ? map : item.getMap();
             reportTable = item.getReportTable() == null ? reportTable : item.getReportTable();
             users = item.getUsers() == null ? users : item.getUsers();
-            reportTables = item.getReportTables() == null ? reportTables : item.getReportTables();
             reports = item.getReports() == null ? reports : item.getReports();
             resources = item.getResources() == null ? resources : item.getResources();
             messages = item.getMessages() == null ? messages : item.getMessages();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardSearchResult.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardSearchResult.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardSearchResult.java	2015-01-14 17:55:17 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.eventchart.EventChart;
+import org.hisp.dhis.eventreport.EventReport;
 import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.reporttable.ReportTable;
@@ -60,6 +61,8 @@
 
     private List<ReportTable> reportTables = new ArrayList<>();
     
+    private List<EventReport> eventReports = new ArrayList<>();
+    
     private List<Report> reports = new ArrayList<>();
 
     private List<Document> resources = new ArrayList<>();
@@ -85,6 +88,7 @@
         results += eventCharts.size();
         results += maps.size();
         results += reportTables.size();
+        results += eventReports.size();
         results += reports.size();
         results += resources.size();
         return results;
@@ -121,6 +125,12 @@
     }
 
     @JsonProperty
+    public int getEventReportCount()
+    {
+        return eventReports.size();
+    }
+    
+    @JsonProperty
     public int getReportCount()
     {
         return reports.size();
@@ -206,6 +216,20 @@
         this.reportTables = reportTables;
     }
 
+    @JsonProperty( value = "eventReports" )
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JacksonXmlElementWrapper( localName = "eventReports", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( localName = "eventReport", namespace = DxfNamespaces.DXF_2_0)
+    public List<EventReport> getEventReports()
+    {
+        return eventReports;
+    }
+
+    public void setEventReports( List<EventReport> eventReports )
+    {
+        this.eventReports = eventReports;
+    }
+
     @JsonProperty( value = "reports" )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JacksonXmlElementWrapper( localName = "reports", namespace = DxfNamespaces.DXF_2_0)

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2015-01-13 18:53:55 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2015-01-14 17:55:17 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.dashboard.DashboardService;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.eventchart.EventChart;
+import org.hisp.dhis.eventreport.EventReport;
 import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.reporttable.ReportTable;
@@ -108,6 +109,7 @@
         result.setEventCharts( objectManager.getBetweenLikeName( EventChart.class, query, 0, getMax( TYPE_EVENT_CHART, maxTypes ) ) );
         result.setMaps( objectManager.getBetweenLikeName( Map.class, query, 0, getMax( TYPE_MAP, maxTypes ) ) );
         result.setReportTables( objectManager.getBetweenLikeName( ReportTable.class, query, 0, getMax( TYPE_REPORT_TABLE, maxTypes ) ) );
+        result.setEventReports( objectManager.getBetweenLikeName( EventReport.class, query, 0, getMax( TYPE_EVENT_REPORT, maxTypes ) ) );
         result.setReports( objectManager.getBetweenLikeName( Report.class, query, 0, getMax( TYPE_REPORTS, maxTypes ) ) );
         result.setResources( objectManager.getBetweenLikeName( Document.class, query, 0, getMax( TYPE_RESOURCES, maxTypes ) ) );
 
@@ -164,10 +166,6 @@
             {
                 item.getUsers().add( objectManager.get( User.class, contentUid ) );
             }
-            else if ( TYPE_REPORT_TABLES.equals( type ) )
-            {
-                item.getReportTables().add( objectManager.get( ReportTable.class, contentUid ) );
-            }
             else if ( TYPE_REPORTS.equals( type ) )
             {
                 item.getReports().add( objectManager.get( Report.class, contentUid ) );
@@ -233,11 +231,6 @@
             item.setUsers( objectManager.getByUid( User.class, getUids( item.getUsers() ) ) );
         }
 
-        if ( item.getReportTables() != null )
-        {
-            item.setReportTables( objectManager.getByUid( ReportTable.class, getUids( item.getReportTables() ) ) );
-        }
-
         if ( item.getReports() != null )
         {
             item.setReports( objectManager.getByUid( Report.class, getUids( item.getReports() ) ) );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml	2015-01-13 18:53:55 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml	2015-01-14 17:55:17 +0000
@@ -29,12 +29,6 @@
       <many-to-many column="userid" class="org.hisp.dhis.user.User" foreign-key="fk_dashboarditem_users_userinfoid" />
     </list>
     
-    <list name="reportTables" table="dashboarditem_reporttables">
-      <key column="dashboarditemid" foreign-key="fk_dashboarditem_reporttables_dashboardid" />
-      <list-index column="sort_order" base="0" />
-      <many-to-many column="reporttableid" class="org.hisp.dhis.reporttable.ReportTable" foreign-key="fk_dashboarditem_reporttables_reporttableid" />
-    </list>
-    
     <list name="reports" table="dashboarditem_reports">
       <key column="dashboarditemid" foreign-key="fk_dashboarditem_reports_dashboardid" />
       <list-index column="sort_order" base="0" />

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-01-14 16:58:34 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-01-14 17:55:17 +0000
@@ -985,6 +985,17 @@
 				$h.append( $.tmpl( dhis2.db.tmpl.hitItem, { "canManage": canManage, "link": "../dhis-web-pivot/index.html?id=" + o.id, "img": "table_small", "name": o.name, "type": "reportTable", "id": o.id, "i18n_add": i18n_add } ) );
 			}
 		}
+		
+		if ( data.eventReportCount > 0 )
+		{
+			$h.append( $.tmpl( dhis2.db.tmpl.hitHeader, { "title": "Event reports", "type": "eventReport", "i18n_see_more_hits": i18n_see_more_hits, "i18n_see_fewer_hits": i18n_see_fewer_hits } ) );
+
+			for ( var i in data.eventReports )
+			{
+				var o = data.eventReports[i];
+				$h.append( $.tmpl( dhis2.db.tmpl.hitItem, { "canManage": canManage, "link": "../dhis-web-event-reports/index.html?id=" + o.id, "img": "table_small", "name": o.name, "type": "eventReport", "id": o.id, "i18n_add": i18n_add } ) );
+			}
+		}
 
 		if ( data.reportCount > 0 )
 		{