Changeset 545 for trunk/grails-app/controllers
- Timestamp:
- May 25, 2010, 12:17:20 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/ReportController.groovy
r544 r545 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 import org.codehaus.groovy.grails.commons.ConfigurationHolder 2 3 import org.springframework.web.servlet.support.RequestContextUtils as RCU 3 4 … … 14 15 15 16 def templatePortrait = { 16 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 17 18 params.startDate = new Date() 19 params.endDate = new Date() 17 20 18 21 params.reportTitle = "Template Report (Portrait)" 22 params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL() 19 23 params.currentUser = authService.currentUser 24 params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate) 25 params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) 26 20 27 def dataModel = createTemplateData() 21 28 22 chain(controller:'jasper', action:'index', model:[data: dataModel], params:params) 23 } 29 // Jasper plugin controller expects data to be a Collection. 30 chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params) 31 32 } // templatePortrait 24 33 25 34 def templateLandscape = { 26 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 35 36 params.startDate = new Date() 37 params.endDate = new Date() 27 38 28 39 params.reportTitle = "Template Report (Landscape)" 40 params.logoUrl = grailsApplication.mainContext.getResource('images/logo.png').getURL() 29 41 params.currentUser = authService.currentUser 42 params.startDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.startDate) 43 params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) 44 30 45 def dataModel = createTemplateData() 31 46 32 chain(controller:'jasper', action:'index', model:[data: dataModel], params:params) 33 } 47 // Jasper plugin controller expects data to be a Collection. 48 chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params) 49 50 } // templateLandscape 34 51 35 52 private createTemplateData() { 36 def dataModel = [] 53 54 def result = [:] 55 result.summaryOfCalculationMethod = "Summary string of the calculations performed." 56 result.dataList = [] 37 57 for(i in 1..5) { 38 def data = [:]39 data .description = "Data description " + i.toString()40 dataModel.add(data)58 def dataDetails = [:] 59 dataDetails.description = "Data description " + i.toString() 60 result.dataList << dataDetails 41 61 } 42 return dataModel 43 } 62 63 // Success. 64 return result 65 66 } // createTemplateData 67 68 def downloadTemplate = { 69 70 // params.fileName is not used directly to negate any security issues.. 71 def fileName = (params.fileName == 'templateLandscape.jrxml') ? 'templateLandscape.jrxml' : 'templatePortrait.jrxml' 72 def f = grailsApplication.mainContext.getResource("reports/${fileName}").getFile() 73 if(f.isFile()) { 74 response.contentType = ConfigurationHolder.config.grails.mime.types["text"] 75 response.setHeader("Content-disposition", "attachment; filename=${fileName}") 76 render f.text 77 } 78 else 79 render(status:404, text: "File Not Found: ${f}") 80 81 } // downLoadTemplate 44 82 45 83 def reactiveRatio = { … … 51 89 params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) 52 90 53 def dataModel = [taskReportService.getReactiveRatio(params, RCU.getLocale(request))]91 def dataModel = taskReportService.getReactiveRatio(params, RCU.getLocale(request)) 54 92 55 chain(controller:'jasper', action:'index', model:[data: dataModel], params:params) 56 } 93 // Jasper plugin controller expects data to be a Collection. 94 chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params) 95 96 } // reactiveRatio 57 97 58 98 def immediateCallouts = { … … 64 104 params.endDateString = g.formatDate(format: "EEE, dd-MMM-yyyy", date: params.endDate) 65 105 66 def dataModel = [taskReportService.getImmediateCallouts(params, RCU.getLocale(request))]106 def dataModel = taskReportService.getImmediateCallouts(params, RCU.getLocale(request)) 67 107 68 // render dataModel 69 chain(controller:'jasper', action:'index', model:[data: dataModel], params:params)108 // Jasper plugin controller expects data to be a Collection. 109 chain(controller:'jasper', action:'index', model:[data: [dataModel]], params:params) 70 110 71 } 111 } // immediateCallouts 72 112 73 113 } // end of class.
Note: See TracChangeset
for help on using the changeset viewer.