PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://sigma-h.googlecode.com/
Java | 78 lines | 48 code | 23 blank | 7 comment | 2 complexity | 88b49d9117a45b677313754f6b01281d 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.*;
 9import org.sigmah.shared.report.model.*;
10
11import java.util.ArrayList;
12import java.util.List;
13
14/**
15 * @author Alex Bertram (akbertram@gmail.com)
16 */
17public class DummyPivotTableData {
18
19
20
21    public Dimension partnerDim = new Dimension(DimensionType.Partner);
22    public Dimension provinceDim = new AdminDimension(1);
23    public List<Dimension> rowDims = new ArrayList<Dimension>();
24
25    public Dimension yearDim = new DateDimension(DateUnit.YEAR);
26    public Dimension indicatorDim = new DateDimension(DateUnit.YEAR);
27    public List<Dimension> colDims = new ArrayList<Dimension>();
28
29
30    public PivotTableData.Axis[] leafRows = new PivotTableData.Axis[4];
31    public PivotTableData.Axis[] leafCols = new PivotTableData.Axis[5];
32    public PivotTableData table = new PivotTableData(rowDims, colDims);
33    public PivotTableData.Axis row1 = table.getRootRow().addChild(partnerDim, new EntityCategory(1, "AVSI"), "AVSI", null);
34    public PivotTableData.Axis row2 = table.getRootRow().addChild(partnerDim, new EntityCategory(1, "NRC"), "NRC", null);
35    public PivotTableData.Axis col1 = table.getRootColumn().addChild(yearDim, new YearCategory(2007), "2007", null );
36    public PivotTableData.Axis col2 = table.getRootColumn().addChild(yearDim, new YearCategory(2009), "2009", null );
37
38    public DummyPivotTableData() {
39
40        rowDims.add(partnerDim);
41        rowDims.add(provinceDim);
42
43        colDims.add(yearDim);
44        colDims.add(indicatorDim);
45
46        leafRows[0] = row1.addChild(provinceDim, new EntityCategory(61, "Nord Kivu"), "Nord", null);
47        leafRows[1] = row1.addChild(provinceDim, new EntityCategory(62, "Sud Kivu"), "Sud Kivu", null);
48
49        leafRows[2] = row2.addChild(provinceDim, new EntityCategory(61, "Nord Kivu"), "Nord", null);
50        leafRows[3] = row2.addChild(provinceDim, new EntityCategory(62, "Sud Kivu"), "Sud Kivu", null);
51
52        leafCols[0] = col1.addChild(indicatorDim, new EntityCategory(201, "NFI"), "NFI", null );
53        leafCols[1] = col1.addChild(indicatorDim, new EntityCategory(202, "Bache"), "Bache", null );
54
55        leafCols[2] = col2.addChild(indicatorDim, new EntityCategory(201, "NFI"), "NFI", null );
56        leafCols[3] = col2.addChild(indicatorDim, new EntityCategory(202, "Bache"), "Bache", null );
57        leafCols[4] = col2.addChild(indicatorDim, new EntityCategory(203, "Abri"), "Abri", null );
58
59        for(int i=0; i!= leafRows.length; ++i) {
60            for(int j=0; j!= leafCols.length; ++j) {
61                leafRows[i].setValue(leafCols[j], (double)(i * (j+9) * 100), 1, 0);
62            }
63        }
64    }
65
66
67    public PivotTableElement Foobar1612Element() {
68        PivotTableElement element = new PivotTableElement();
69        element.setTitle("Foobar 1612");
70        element.setRowDimensions(rowDims);
71        element.setColumnDimensions(colDims);
72        element.setContent(new PivotContent(table, new ArrayList<FilterDescription>()));
73       
74        return element;
75    }
76
77
78}