PageRenderTime 23ms CodeModel.GetById 2ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

/sigmah/src/test/java/org/sigmah/server/report/DummyPivotTableData2.java

http://sigma-h.googlecode.com/
Java | 69 lines | 40 code | 22 blank | 7 comment | 1 complexity | c7264f505852ab4df8dab3f8b68e1d0c MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.server.report;
 7
 8import org.sigmah.shared.report.content.EntityCategory;
 9import org.sigmah.shared.report.content.FilterDescription;
10import org.sigmah.shared.report.content.PivotContent;
11import org.sigmah.shared.report.content.PivotTableData;
12import org.sigmah.shared.report.model.AdminDimension;
13import org.sigmah.shared.report.model.Dimension;
14import org.sigmah.shared.report.model.DimensionType;
15import org.sigmah.shared.report.model.PivotTableElement;
16
17import java.util.ArrayList;
18import java.util.List;
19
20/**
21 * @author Alex Bertram (akbertram@gmail.com)
22 */
23public class DummyPivotTableData2 {
24
25
26
27    public Dimension partnerDim = new Dimension(DimensionType.Partner);
28    public Dimension provinceDim = new AdminDimension(1);
29    public List<Dimension> rowDims = new ArrayList<Dimension>();
30    public List<Dimension> colDims = new ArrayList<Dimension>();
31
32
33    public PivotTableData.Axis[] leafRows = new PivotTableData.Axis[4];
34    public PivotTableData table = new PivotTableData(rowDims, colDims);
35    public PivotTableData.Axis row1 = table.getRootRow().addChild(partnerDim, new EntityCategory(1, "AVSI"), "AVSI", null);
36    public PivotTableData.Axis row2 = table.getRootRow().addChild(partnerDim, new EntityCategory(1, "NRC"), "NRC", null);
37
38    public DummyPivotTableData2() {
39
40        rowDims.add(partnerDim);
41        rowDims.add(provinceDim);
42
43        leafRows[0] = row1.addChild(provinceDim, new EntityCategory(61, "Nord Kivu"), "Nord", null);
44        leafRows[1] = row1.addChild(provinceDim, new EntityCategory(62, "Sud Kivu"), "Sud Kivu", null);
45
46        leafRows[2] = row2.addChild(provinceDim, new EntityCategory(61, "Nord Kivu"), "Nord", null);
47        leafRows[3] = row2.addChild(provinceDim, new EntityCategory(62, "Sud Kivu"), "Sud Kivu", null);
48
49        for(int i=0; i!= leafRows.length; ++i) {
50
51            leafRows[i].setValue(table.getRootColumn(), (double)((i+1) * 100), 1, 0);
52
53        }
54
55    }
56
57
58    public PivotTableElement testElement() {
59        PivotTableElement element = new PivotTableElement();
60        element.setTitle("Foobar 1612");
61        element.setRowDimensions(rowDims);
62        element.setColumnDimensions(colDims);
63        element.setContent(new PivotContent(table, new ArrayList<FilterDescription>()));
64
65        return element;
66    }
67
68
69}