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
;
19 import java
.awt
.Color
;
22 import javax
.servlet
.http
.HttpServletRequest
;
23 import javax
.servlet
.http
.HttpServletResponse
;
25 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
26 import org
.argeo
.slc
.core
.test
.SlcTestUtils
;
27 import org
.argeo
.slc
.core
.test
.tree
.PartSubList
;
28 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
29 import org
.argeo
.slc
.test
.TestResultPart
;
30 import org
.argeo
.slc
.test
.TestStatus
;
31 import org
.springframework
.web
.servlet
.view
.document
.AbstractPdfView
;
33 import com
.lowagie
.text
.Cell
;
34 import com
.lowagie
.text
.Document
;
35 import com
.lowagie
.text
.Paragraph
;
36 import com
.lowagie
.text
.Table
;
37 import com
.lowagie
.text
.pdf
.PdfWriter
;
39 public class ResultPdfView
extends AbstractPdfView
{
40 // private static final Log log = LogFactory.getLog(ResultPdfView.class);
42 public final static String MODELKEY_RESULT
= "result";
45 @SuppressWarnings(value
= { "unchecked" })
46 protected void buildPdfDocument(Map model
, Document document
,
47 PdfWriter writer
, HttpServletRequest request
,
48 HttpServletResponse response
) throws Exception
{
49 TreeTestResult ttr
= (TreeTestResult
) model
.get(MODELKEY_RESULT
);
51 document
.addTitle("Result " + ttr
.getUuid());
52 document
.add(new Paragraph("Result " + ttr
.getUuid()));
54 for (TreeSPath path
: ttr
.getResultParts().keySet()) {
55 PartSubList lst
= ttr
.getResultParts().get(path
);
56 document
.add(new Paragraph("Path " + path
));
57 Table table
= new Table(2, lst
.getParts().size());
58 for (TestResultPart part
: lst
.getParts()) {
59 Integer status
= part
.getStatus();
60 Cell statusCell
= new Cell(SlcTestUtils
.statusToString(status
));
62 if (status
.equals(TestStatus
.PASSED
))
64 else if (status
.equals(TestStatus
.FAILED
))
67 color
= Color
.MAGENTA
;
69 statusCell
.setBackgroundColor(color
);
70 table
.addCell(statusCell
);
71 table
.addCell(part
.getMessage());