@@ -42,22 +42,26 @@ public class PlaceHierarchiesOnAxesImpl extends AbstractTransform implements
42
42
* @param connection
43
43
*/
44
44
public PlaceHierarchiesOnAxesImpl (QueryAdapter queryAdapter ,
45
- OlapConnection connection ) {
45
+ OlapConnection connection ) {
46
46
super (queryAdapter , connection );
47
47
}
48
48
49
+ public void placeHierarchies (Axis axis , List <Hierarchy > hierarchies ,
50
+ boolean expandAllMember ) {
51
+ placeHierarchies (axis , hierarchies , expandAllMember , true );
52
+ }
49
53
/**
50
54
* @see org.pivot4j.transform.PlaceHierarchiesOnAxes#placeHierarchies(org.olap4j.Axis,
51
- * java.util.List, boolean)
55
+ * java.util.List, boolean, boolean )
52
56
*/
53
57
public void placeHierarchies (Axis axis , List <Hierarchy > hierarchies ,
54
- boolean expandAllMember ) {
58
+ boolean expandAllMember , boolean includeAllMember ) {
55
59
QueryAdapter adapter = getQueryAdapter ();
56
60
57
61
List <Exp > memberExpressions = new ArrayList <Exp >();
58
62
for (Hierarchy hierarchy : hierarchies ) {
59
63
memberExpressions .add (createMemberExpression (hierarchy ,
60
- expandAllMember ));
64
+ expandAllMember , includeAllMember ));
61
65
}
62
66
63
67
Quax quax = adapter .getQuax (axis );
@@ -100,7 +104,17 @@ public void placeHierarchies(Axis axis, List<Hierarchy> hierarchies,
100
104
*/
101
105
@ Override
102
106
public void addHierarchy (Axis axis , Hierarchy hierarchy ,
103
- boolean expandAllMember , int position ) {
107
+ boolean expandAllMember , int position ) {
108
+ addHierarchy (axis , hierarchy , expandAllMember , true , position );
109
+ }
110
+
111
+ /**
112
+ * @see org.pivot4j.transform.PlaceHierarchiesOnAxes#addHierarchy(org.olap4j.Axis,
113
+ * org.olap4j.metadata.Hierarchy, boolean, boolean, int)
114
+ */
115
+ @ Override
116
+ public void addHierarchy (Axis axis , Hierarchy hierarchy ,
117
+ boolean expandAllMember , boolean includeAllMember , int position ) {
104
118
List <Hierarchy > hierarchies = findVisibleHierarchies (axis );
105
119
106
120
if (hierarchies .contains (hierarchy )) {
@@ -116,7 +130,7 @@ public void addHierarchy(Axis axis, Hierarchy hierarchy,
116
130
hierarchies .add (position , hierarchy );
117
131
}
118
132
119
- placeHierarchies (axis , hierarchies , expandAllMember );
133
+ placeHierarchies (axis , hierarchies , expandAllMember , includeAllMember );
120
134
}
121
135
122
136
/**
@@ -199,7 +213,7 @@ public List<Hierarchy> findVisibleHierarchies(Axis axis) {
199
213
* @return
200
214
*/
201
215
protected Exp createMemberExpression (Hierarchy hierarchy ,
202
- boolean expandAllMember ) {
216
+ boolean expandAllMember , boolean includeAllMember ) {
203
217
// if the query does not contain the hierarchy,
204
218
// just return the highest level
205
219
QueryAdapter adapter = getQueryAdapter ();
@@ -209,7 +223,7 @@ protected Exp createMemberExpression(Hierarchy hierarchy,
209
223
if (quax == null ) {
210
224
adapter .getCurrentMdx (true );
211
225
// the hierarchy was not found on any axis
212
- return topLevelMembers (hierarchy , expandAllMember );
226
+ return topLevelMembers (hierarchy , expandAllMember , includeAllMember );
213
227
// return top level members of the hierarchy
214
228
}
215
229
@@ -222,12 +236,12 @@ protected Exp createMemberExpression(Hierarchy hierarchy,
222
236
223
237
/**
224
238
* TODO Merge with {@link QuaxUtil#topLevelMembers(Hierarchy, boolean)}
225
- *
239
+ *
226
240
* @param hierarchy
227
241
* @param expandAllMember
228
242
* @return
229
243
*/
230
- protected Exp topLevelMembers (Hierarchy hierarchy , boolean expandAllMember ) {
244
+ protected Exp topLevelMembers (Hierarchy hierarchy , boolean expandAllMember , boolean includeAllMember ) {
231
245
try {
232
246
if (hierarchy .hasAll ()) {
233
247
// an "All" member is present -get it
@@ -260,20 +274,29 @@ protected Exp topLevelMembers(Hierarchy hierarchy, boolean expandAllMember) {
260
274
261
275
// must expand
262
276
// create Union({AllMember}, AllMember.children)
263
- Exp allExp = new MemberExp (allMember );
277
+ if (includeAllMember ) {
278
+ Exp allExp = new MemberExp (allMember );
264
279
265
- FunCall allSet = new FunCall ("{}" , Syntax .Braces );
266
- allSet .getArgs ().add (allExp );
280
+ FunCall allSet = new FunCall ("{}" , Syntax .Braces );
281
+ allSet .getArgs ().add (allExp );
267
282
268
- FunCall mAllChildren = new FunCall ("Children" ,
269
- Syntax .Property );
270
- mAllChildren .getArgs ().add (allExp );
283
+ FunCall mAllChildren = new FunCall ("Children" ,
284
+ Syntax .Property );
285
+ mAllChildren .getArgs ().add (allExp );
271
286
272
- FunCall union = new FunCall ("Union" , Syntax .Function );
273
- union .getArgs ().add (allSet );
274
- union .getArgs ().add (mAllChildren );
287
+ FunCall union = new FunCall ("Union" , Syntax .Function );
288
+ union .getArgs ().add (allSet );
289
+ union .getArgs ().add (mAllChildren );
275
290
276
- return union ;
291
+ return union ;
292
+ } else {
293
+ Exp allExp = new MemberExp (allMember );
294
+
295
+ FunCall mAllChildren = new FunCall ("Children" ,
296
+ Syntax .Property );
297
+ mAllChildren .getArgs ().add (allExp );
298
+ return mAllChildren ;
299
+ }
277
300
}
278
301
}
279
302
@@ -304,4 +327,4 @@ protected Exp topLevelMembers(Hierarchy hierarchy, boolean expandAllMember) {
304
327
throw new PivotException (e );
305
328
}
306
329
}
307
- }
330
+ }
0 commit comments