1
1
package au.org.ala.merit
2
2
3
3
import au.org.ala.merit.command.EditManagementUnitReportCommand
4
- import au.org.ala.merit.command.ManagementUnitReportCommand
5
4
import au.org.ala.merit.command.PrintManagementUnitReportCommand
6
5
import au.org.ala.merit.command.SaveReportDataCommand
7
6
import au.org.ala.merit.command.ViewManagementUnitReportCommand
8
7
import au.org.ala.merit.util.ProjectGroupingHelper
9
8
import grails.converters.JSON
10
9
import grails.core.GrailsApplication
11
- import grails.plugin.cache.Cacheable
12
10
import grails.web.mapping.LinkGenerator
13
11
import org.apache.http.HttpStatus
14
-
15
- import java.text.DateFormat
16
12
import java.text.ParseException
17
- import java.text.SimpleDateFormat
18
-
19
- import static ReportService.ReportMode
20
13
21
14
/**
22
15
* Processes requests relating to MUs
@@ -29,7 +22,6 @@ class ManagementUnitController {
29
22
30
23
ReportService reportService
31
24
ActivityService activityService
32
- PdfGenerationService pdfGenerationService
33
25
ProjectService projectService
34
26
ProjectGroupingHelper projectGroupingHelper
35
27
@@ -239,19 +231,6 @@ class ManagementUnitController {
239
231
chain(action :' editReport' , id :id, params :[reportId :reportId])
240
232
}
241
233
242
- private Map activityReportModel (String managementUnitId , String reportId , ReportMode mode , Integer formVersion = null ) {
243
- Map mu = managementUnitService. get(managementUnitId)
244
- Map config = mu. config
245
- Map model = reportService. activityReportModel(reportId, mode, formVersion)
246
-
247
- model. context = mu
248
- model. returnTo = createLink(action :' index' , id :managementUnitId)
249
- model. contextViewUrl = model. returnTo
250
- model. reportHeaderTemplate = ' /managementUnit/managementUnitReportHeader'
251
- model. config = config
252
- model
253
- }
254
-
255
234
@PreAuthorise (accessLevel = ' readOnly' , redirectController = ' managementUnit' )
256
235
def viewReport (ViewManagementUnitReportCommand cmd ) {
257
236
if (cmd. hasErrors()) {
@@ -263,29 +242,14 @@ class ManagementUnitController {
263
242
}
264
243
265
244
@PreAuthorise (accessLevel = ' readOnly' )
266
- def printableReport ( String id , String reportId ) {
267
- if (! id || ! reportId ) {
268
- error(' An invalid report was selected for download ' , id)
245
+ def printManagementUnitReport ( PrintManagementUnitReportCommand cmd ) {
246
+ if (cmd . hasErrors() ) {
247
+ error(cmd . errors . toString(), cmd . id)
269
248
return
270
249
}
271
- Map model = activityReportModel(id, reportId, ReportMode . PRINT )
272
250
273
- render view :' /activity/activityReportView' , model :model
274
- }
275
-
276
- /**
277
- * This is designed as a callback from the PDF generation service. It produces a HTML report that will
278
- * be converted into PDF.
279
- * @param id the project id
280
- */
281
- def viewReportCallback (PrintManagementUnitReportCommand cmd ) {
251
+ render model :cmd. model, view :' /activity/activityReportView'
282
252
283
- if (pdfGenerationService. authorizePDF(request)) {
284
- render view :' /activity/activityReportView' , model :cmd. model
285
- }
286
- else {
287
- render status :HttpStatus . SC_UNAUTHORIZED
288
- }
289
253
}
290
254
291
255
@PreAuthorise (accessLevel = ' editor' )
0 commit comments