------------------------------------------------------------ revno: 16939 committer: Lars Helge Overland <larshe...@gmail.com> branch nick: dhis2 timestamp: Thu 2014-10-02 19:01:16 +0200 message: Web API. Added new resource representation html+css for sql view and analytics added: dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html-css.vm modified: dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html.vm dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.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-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java 2014-09-08 13:02:43 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java 2014-10-02 17:01:16 +0000 @@ -159,11 +159,12 @@ @Override public Grid getSqlViewGrid( SqlView sqlView, Map<String, String> criteria ) { - Grid sqlViewGrid = new ListGrid(); - - sqlViewExpandStore.setUpDataSqlViewTable( sqlViewGrid, sqlView.getViewName(), criteria ); - - return sqlViewGrid; + Grid grid = new ListGrid(); + grid.setTitle( sqlView.getName() ); + + sqlViewExpandStore.setUpDataSqlViewTable( grid, sqlView.getViewName(), criteria ); + + return grid; } @Override === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java 2014-09-25 10:17:34 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java 2014-10-02 17:01:16 +0000 @@ -124,6 +124,7 @@ private static final String KEY_PARAMS = "params"; private static final String JASPER_TEMPLATE = "grid.vm"; private static final String HTML_TEMPLATE = "grid-html.vm"; + private static final String HTML_CSS_TEMPLATE = "grid-html-css.vm"; private static final String ATTR_GRID = "grid"; private static final String ATTR_TITLE = "title"; @@ -395,13 +396,22 @@ } /** - * Writes a JRXML (Jasper Reports XML) representation of the given Grid to the given Writer. + * Writes a HTML representation of the given Grid to the given Writer. */ public static void toHtml( Grid grid, Writer writer ) throws Exception { render( grid, null, writer, HTML_TEMPLATE ); } + + /** + * Writes a HTML representation of the given Grid to the given Writer. + */ + public static void toHtmlCss( Grid grid, Writer writer ) + throws Exception + { + render( grid, null, writer, HTML_CSS_TEMPLATE ); + } /** * Writes an XML representation of the given Grid to the given OutputStream. === added file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html-css.vm' --- dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html-css.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html-css.vm 2014-10-02 17:01:16 +0000 @@ -0,0 +1,22 @@ +<style type="text/css"> +.gridDiv { + font-family: sans-serif, arial; +} + +table.gridTable { + border-collapse: collapse; + font-size: 11pt; +} + +.gridTable th, td { + padding: 8px 4px 7px 4px; + border: 1px solid #e7e7e7; +} + +.gridTable th { + background-color: #f3f3f3; + font-weight: bold; +} +</style> + +#parse( "grid-html.vm" ) \ No newline at end of file === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html.vm' --- dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html.vm 2013-08-07 10:03:12 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/resources/grid-html.vm 2014-10-02 17:01:16 +0000 @@ -1,10 +1,11 @@ +<div class="gridDiv"> <h3>$!encoder.htmlEncode( $grid.title )</h3> <h4>$!encoder.htmlEncode( $grid.subtitle )</h4> <table class="listTable gridTable"> <thead> <tr> #foreach( $header in $grid.getVisibleHeaders() ) -<th #if( $header.meta )style="text-align:left"#end>$!encoder.htmlEncode( $header.name )</th> +<th#if( $header.meta ) style="text-align:left"#end>$!encoder.htmlEncode( $header.name )</th> #end </tr> </thead> @@ -22,4 +23,5 @@ </tr> #end </tbody> -</table> \ No newline at end of file +</table> +</div> \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java 2014-09-29 16:10:58 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java 2014-10-02 17:01:16 +0000 @@ -156,6 +156,33 @@ GridUtils.toHtml( substituteMetaData( grid ), response.getWriter() ); } + @RequestMapping( value = RESOURCE_PATH + ".html+css", method = RequestMethod.GET ) + public void getHtmlCss( + @RequestParam Set<String> dimension, + @RequestParam( required = false ) Set<String> filter, + @RequestParam( required = false ) AggregationType aggregationType, + @RequestParam( required = false ) String measureCriteria, + @RequestParam( required = false ) boolean skipMeta, + @RequestParam( required = false ) boolean skipRounding, + @RequestParam( required = false ) boolean hierarchyMeta, + @RequestParam( required = false ) boolean ignoreLimit, + @RequestParam( required = false ) boolean tableLayout, + @RequestParam( required = false ) boolean hideEmptyRows, + @RequestParam( required = false ) boolean showHierarchy, + @RequestParam( required = false ) DisplayProperty displayProperty, + @RequestParam( required = false ) String columns, + @RequestParam( required = false ) String rows, + Model model, + HttpServletResponse response ) throws Exception + { + DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, + skipMeta, skipRounding, hierarchyMeta, ignoreLimit, hideEmptyRows, showHierarchy, displayProperty, i18nManager.getI18nFormat() ); + + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING ); + Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) ); + GridUtils.toHtmlCss( substituteMetaData( grid ), response.getWriter() ); + } + @RequestMapping( value = RESOURCE_PATH + ".csv", method = RequestMethod.GET ) public void getCsv( @RequestParam Set<String> dimension, === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2014-06-11 20:00:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2014-10-02 17:01:16 +0000 @@ -177,6 +177,20 @@ GridUtils.toHtml( grid, response.getWriter() ); } + @RequestMapping( value = "/{uid}/data.html+css", method = RequestMethod.GET ) + public void getReportTableHtmlCss( @PathVariable( "uid" ) String uid, + @RequestParam( value = "ou", required = false ) String organisationUnitUid, + @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date, + HttpServletResponse response ) throws Exception + { + Grid grid = getReportTableGrid( uid, organisationUnitUid, date ); + + String filename = filenameEncode( grid.getTitle() ) + ".html"; + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, false ); + + GridUtils.toHtmlCss( grid, response.getWriter() ); + } + @RequestMapping( value = "/{uid}/data.xml", method = RequestMethod.GET ) public void getReportTableXml( @PathVariable( "uid" ) String uid, @RequestParam( value = "ou", required = false ) String organisationUnitUid, === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java 2014-05-22 12:40:24 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java 2014-10-02 17:01:16 +0000 @@ -130,6 +130,19 @@ GridUtils.toHtml( grid, response.getWriter() ); } + @RequestMapping( value = "/{uid}/data.html+css", method = RequestMethod.GET ) + public void getViewHtmlCss( @PathVariable( "uid" ) String uid, + @RequestParam(required=false) Set<String> criteria, HttpServletResponse response ) throws Exception + { + SqlView sqlView = sqlViewService.getSqlViewByUid( uid ); + + Grid grid = sqlViewService.getSqlViewGrid( sqlView, SqlView.getCriteria( criteria ) ); + + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING ); + + GridUtils.toHtmlCss( grid, response.getWriter() ); + } + @RequestMapping( value = "/{uid}/data.pdf", method = RequestMethod.GET ) public void getViewPdf( @PathVariable( "uid" ) String uid, @RequestParam(required=false) Set<String> criteria, HttpServletResponse response ) throws Exception === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm 2014-08-28 08:47:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm 2014-10-02 17:01:16 +0000 @@ -20,7 +20,7 @@ <input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.xls'" style="width:135px"/> <input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.csv'" style="width:135px"/> <input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.pdf'" style="width:135px"/> -<input type="button" value="$i18n.getString( 'get_report_as_html' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.html'" style="width:135px"/> +<input type="button" value="$i18n.getString( 'get_report_as_html' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.html+css'" style="width:135px"/> <input type="button" value="$i18n.getString( 'get_report_as_xml' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.xml'" style="width:135px"/> <input type="button" value="$i18n.getString( 'get_report_as_json' )" onclick="window.location.href='../api/sqlViews/${sqlView.uid}/data.json'" style="width:135px"/> <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='sqlView.action'" style="width:140px" style="width:135px"/>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp