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