]> 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
remove unused static variable
[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 javax.servlet.http.HttpServletRequest;
20
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.springframework.stereotype.Controller;
25 import org.springframework.ui.ModelMap;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.RequestParam;
28
29 /**
30 * Sends back the results, rendered or as collection.
31 */
32
33 @Controller
34 public class RenderingResultController {
35 // private static final Log log = LogFactory
36 // .getLog(RenderingResultController.class);
37
38 public final static String MODELKEY_RESULT = "result";
39
40 // IoC
41 private TreeTestResultDao treeTestResultDao;
42
43 @RequestMapping("/resultView.*")
44 public String getPdfResultView(@RequestParam("uuid") String uuid,
45 ModelMap model, HttpServletRequest request) {
46
47 TreeTestResult result = treeTestResultDao.getTestResult(uuid);
48 if (result == null)
49 throw new SlcException("No result found for uuid " + uuid);
50 model.addAttribute(MODELKEY_RESULT, result);
51
52 String docType = request.getRequestURI().substring(
53 request.getRequestURI().lastIndexOf(".") + 1);
54
55 if ("pdf".equals(docType))
56 return "resultPdfView";
57 if ("xls".equals(docType))
58 return "resultExcelView";
59 if ("xslt".equals(docType))
60 return "resultXsltView";
61 if ("xml".equals(docType))
62 return "resultXmlView";
63
64 throw new SlcException("No renderer found for files of extension "
65 + docType);
66 }
67
68 // IoC
69
70 public void setTreeTestResultDao(TreeTestResultDao treeTestResultDao) {
71 this.treeTestResultDao = treeTestResultDao;
72 }
73
74 }