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