1 package com.tonbeller.jpivot.olap.model.impl; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.List ; 6 7 import javax.servlet.ServletContext ; 8 9 import com.tonbeller.jpivot.core.ModelSupport; 10 import com.tonbeller.jpivot.olap.model.Axis; 11 import com.tonbeller.jpivot.olap.model.Dimension; 12 import com.tonbeller.jpivot.olap.model.Member; 13 import com.tonbeller.jpivot.olap.model.OlapException; 14 import com.tonbeller.jpivot.olap.model.OlapModel; 15 import com.tonbeller.jpivot.olap.model.Result; 16 import com.tonbeller.jpivot.olap.model.Visitor; 17 18 32 public class ScalarOlapModel extends ModelSupport implements OlapModel, Result { 33 private static final String MEASURES = "Measures"; 34 private static final String MEASURE = "Measure"; 35 36 MemberImpl measure; 37 MemberImpl[] measures; 38 LevelImpl level; 39 HierarchyImpl hierarchy; 40 DimensionImpl dimension; 41 DimensionImpl[] dimensions; 42 String ID; 43 44 CellImpl cell; 45 List cells; 46 Axis[] axes; 47 Axis slicer; 48 49 boolean overflowOccured; 50 51 public ScalarOlapModel() { 52 measure = new MemberImpl(); 53 measures = new MemberImpl[] { measure}; 54 level = new LevelImpl(); 55 level.setLabel(MEASURES); 56 measure.setLevel(level); 57 hierarchy = new HierarchyImpl(); 58 hierarchy.setLabel(MEASURES); 59 hierarchy.setLevels(new LevelImpl[] { level}); 60 level.setHierarchy(hierarchy); 61 dimension = new DimensionImpl(); 62 dimension.setLabel(MEASURES); 63 dimension.setHierarchies(new HierarchyImpl[] { hierarchy}); 64 hierarchy.setDimension(dimension); 65 dimensions = new DimensionImpl[] { dimension}; 66 67 PositionImpl pos = new PositionImpl(); 68 pos.setMembers(new Member[] { measure}); 69 List posns = new ArrayList (1); 70 posns.add(pos); 71 AxisImpl axis = new AxisImpl(); 72 axis.setPositions(posns); 73 axes = new Axis[] { axis}; 74 75 cell = new CellImpl(); 76 List list = new ArrayList (1); 77 list.add(cell); 78 cells = Collections.unmodifiableList(list); 79 80 slicer = new AxisImpl(); 81 82 setCaption(MEASURE); 84 setValue(new Double (0)); 85 setFormattedValue("0.00"); 86 } 87 88 91 public List getCells() { 92 return cells; 93 } 94 95 98 public Axis[] getAxes() { 99 return axes; 100 } 101 102 105 public Axis getSlicer() { 106 return slicer; 107 } 108 109 public void accept(Visitor visitor) { 110 visitor.visitResult(this); 111 } 112 113 public Object getRootDecoree() { 114 return this; 115 } 116 117 120 public String getFormattedValue() { 121 return cell.getFormattedValue(); 122 } 123 124 127 public void setFormattedValue(String formattedValue) { 128 cell.setFormattedValue(formattedValue); 129 fireModelChanged(); 130 } 131 132 135 public boolean isOverflowOccured() { 136 return overflowOccured; 137 } 138 139 142 public void setOverflowOccured(boolean overflowOccured) { 143 this.overflowOccured = overflowOccured; 144 fireModelChanged(); 145 } 146 147 150 public Object getValue() { 151 return cell.getValue(); 152 } 153 154 157 public void setValue(Object value) { 158 cell.setValue(value); 159 fireModelChanged(); 160 } 161 162 165 public void setCaption(String caption) { 166 measure.setLabel(caption); 167 fireModelChanged(); 168 } 169 170 173 public String getCaption() { 174 return measure.getLabel(); 175 } 176 177 public Result getResult() throws OlapException { 178 return this; 179 } 180 181 public Dimension[] getDimensions() { 182 return dimensions; 183 } 184 185 public Member[] getMeasures() { 186 return measures; 187 } 188 189 192 public void initialize() throws OlapException { 193 } 194 195 198 public void setServletContext(ServletContext servletContext) { 199 } 200 201 public String getID() { 202 return ID; 203 } 204 205 public void setID(String id) { 206 ID = id; 207 } 208 209 } 210 | Popular Tags |