2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.web
.mvc
.controllers
;
19 import org
.argeo
.slc
.SlcException
;
20 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
21 import org
.argeo
.slc
.dao
.test
.tree
.TreeTestResultDao
;
22 import org
.argeo
.slc
.web
.mvc
.result
.ResultExcelView
;
23 import org
.argeo
.slc
.web
.mvc
.result
.ResultPdfView
;
24 import org
.springframework
.stereotype
.Controller
;
25 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
26 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
27 import org
.springframework
.web
.servlet
.ModelAndView
;
30 * Sends back the results, rendered or as collection.
34 public class RenderingResultController
{
36 public final static String KEY_ANSWER
= "__answer";
37 public final static String MODELKEY_RESULT
= "result";
40 private TreeTestResultDao testResultDao
;
41 private ResultExcelView resultExcelView
;
42 private ResultPdfView resultPdfView
;
44 @RequestMapping("/resultView.pdf")
45 public void getPdfResultView(@RequestParam(value
= "uuid") String uuid
,
46 ModelAndView modelAndView
) {
47 TreeTestResult result
= testResultDao
.getTestResult(uuid
);
49 throw new SlcException("No result found for uuid " + uuid
);
50 modelAndView
.getModelMap().addAttribute(MODELKEY_RESULT
, result
);
51 modelAndView
.setView(resultPdfView
);
54 @RequestMapping("/resultView.xls")
55 public void getXlsResultView(@RequestParam(value
= "uuid") String uuid
,
56 ModelAndView modelAndView
) {
57 TreeTestResult result
= testResultDao
.getTestResult(uuid
);
59 throw new SlcException("No result found for uuid " + uuid
);
60 modelAndView
.getModelMap().addAttribute(MODELKEY_RESULT
, result
);
61 modelAndView
.setView(resultExcelView
);
64 public void setResultExcelView(ResultExcelView resultExcelView
) {
65 this.resultExcelView
= resultExcelView
;
68 public void setResultPdfView(ResultPdfView resultPdfView
) {
69 this.resultPdfView
= resultPdfView
;