1 package com.calipso.reportgenerator.reportcalculator; 2 3 import java.util.Arrays ; 4 import java.io.Serializable ; 5 6 9 10 public class StaticQuery implements Serializable { 11 private int[] groupDimensions; 12 private int[] noGroupDimensions; 13 private int[] metrics; 14 private int[] accumulableMetrics; 15 private int[] dimensions; 16 private boolean[] ascending; 17 private ExpressionCubeFilter filter; 18 private EnumerationCubeFilter rankingFilter; 19 20 public void setRankingFilter(EnumerationCubeFilter rankingFilter) { 21 this.rankingFilter = rankingFilter; 22 } 23 24 27 public StaticQuery() { 28 initialize(); 29 } 30 31 34 private void initialize() { 35 setGroupDimensions(new int[0]); 36 setNoGroupDimensions(new int[0]); 37 setMetrics(new int[0]); 38 } 39 40 44 public int[] getGroupDimensions() { 45 return groupDimensions; 46 } 47 48 52 public void setGroupDimensions(int[] groupDimensions) { 53 this.groupDimensions = groupDimensions; 54 } 55 56 60 public int[] getNoGroupDimensions() { 61 return noGroupDimensions; 62 } 63 64 68 public void setNoGroupDimensions(int[] noGroupDimensions) { 69 this.noGroupDimensions = noGroupDimensions; 70 } 71 72 76 public int[] getMetrics() { 77 return metrics; 78 } 79 80 84 public int[] getAccumulableMetrics() { 85 return accumulableMetrics; 86 } 87 88 92 public void setMetrics(int[] metrics) { 93 this.metrics = metrics; 94 } 95 96 100 public void setAccumulableMetrics(int [] accumulableMetrics) { 101 this.accumulableMetrics = accumulableMetrics; 102 } 103 104 109 public boolean[] getAscending() { 110 if (ascending == null) { 111 ascending = new boolean[dimensions.length]; 112 Arrays.fill(ascending, true); 113 } 114 return ascending; 115 } 116 117 122 public void setAscending(boolean[] ascending) { 123 this.ascending = ascending; 124 } 125 126 131 public int[] getDimensions() { 132 if (dimensions == null) { 133 fillDimensions(); 134 } 135 return dimensions; 136 } 137 138 142 private void fillDimensions() { 143 int groupLenght; 144 int noGroupLenght; 145 int dimensionsLenght; 146 int index; 147 148 groupLenght = groupDimensions.length; 149 noGroupLenght = noGroupDimensions.length; 150 dimensionsLenght = groupLenght + noGroupLenght; 151 dimensions = new int[dimensionsLenght]; 152 for (index = 0; index < groupLenght; ++index) { 153 dimensions[index] = groupDimensions[index]; 154 } 155 for (index = 0; index < noGroupLenght; ++index) { 156 dimensions[index + groupLenght] = noGroupDimensions[index]; 157 } 158 } 159 160 public ExpressionCubeFilter getFilter() { 161 return filter; 162 } 163 164 public void setFilter(ExpressionCubeFilter filter) { 165 this.filter = filter; 166 } 167 168 173 public boolean matches(Object [] row) { 174 return ((filter == null) || filter.matches(row)) && ((rankingFilter==null) || rankingFilter.matches(row)); 175 } 176 } 177 | Popular Tags |