]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/controllers/RenderingResultController.java
clean org.argeo.slc.server project:
[gpl/argeo-slc.git] / runtime / org.argeo.slc.server / src / main / java / org / argeo / slc / web / mvc / controllers / RenderingResultController.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 package org.argeo.slc.web.mvc.controllers;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.argeo.slc.SlcException;
22 import org.argeo.slc.core.test.tree.TreeTestResult;
23 import org.argeo.slc.dao.test.tree.TreeTestResultDao;
24 import org.argeo.slc.web.mvc.result.ResultExcelView;
25 import org.argeo.slc.web.mvc.result.ResultPdfView;
26 import org.springframework.stereotype.Controller;
27 import org.springframework.web.bind.annotation.RequestMapping;
28 import org.springframework.web.bind.annotation.RequestParam;
29 import org.springframework.web.servlet.ModelAndView;
30
31 /**
32 * Sends back the results, rendered or as collection.
33 */
34
35 @Controller
36 public class RenderingResultController {
37 private final static Log log = LogFactory.getLog(RenderingResultController.class);
38
39 public final static String KEY_ANSWER = "__answer";
40 public final static String MODELKEY_RESULT = "result";
41
42 // IoC
43 private TreeTestResultDao testResultDao;
44 private ResultExcelView resultExcelView;
45 private ResultPdfView resultPdfView;
46
47 @RequestMapping("/resultView.pdf")
48 public void getPdfResultView(@RequestParam(value = "uuid") String uuid,
49 ModelAndView modelAndView) {
50 TreeTestResult result = testResultDao.getTestResult(uuid);
51 if (result == null)
52 throw new SlcException("No result found for uuid " + uuid);
53 modelAndView.getModelMap().addAttribute(MODELKEY_RESULT, result);
54 modelAndView.setView(resultPdfView);
55 }
56
57 @RequestMapping("/resultView.xls")
58 public void getXlsResultView(@RequestParam(value = "uuid") String uuid,
59 ModelAndView modelAndView) {
60 TreeTestResult result = testResultDao.getTestResult(uuid);
61 if (result == null)
62 throw new SlcException("No result found for uuid " + uuid);
63 modelAndView.getModelMap().addAttribute(MODELKEY_RESULT, result);
64 modelAndView.setView(resultExcelView);
65 }
66
67 public void setResultExcelView(ResultExcelView resultExcelView) {
68 this.resultExcelView = resultExcelView;
69 }
70
71 public void setResultPdfView(ResultPdfView resultPdfView) {
72 this.resultPdfView = resultPdfView;
73 }
74
75 }