use of mondrian.mdx.MemberExpr in project mondrian by pentaho.
the class SqlConstraintUtilsTest method makeAggregateExprMember.
private Member makeAggregateExprMember(Evaluator mockEvaluator, List<Member> endMembers) {
Member member = Mockito.mock(Member.class);
Mockito.doReturn(true).when(member).isCalculated();
Member aggregatedMember0 = Mockito.mock(Member.class);
Exp aggregateArg0 = new MemberExpr(aggregatedMember0);
FunDef dummy = Mockito.mock(FunDef.class);
Mockito.doReturn(Syntax.Function).when(dummy).getSyntax();
Mockito.doReturn("dummy").when(dummy).getName();
FunDef funDef = new AggregateFunDef(dummy);
Exp[] args = new Exp[] { aggregateArg0 };
Type returnType = new DecimalType(1, 1);
Exp memberExp = new ResolvedFunCall(funDef, args, returnType);
Mockito.doReturn(memberExp).when(member).getExpression();
SetEvaluator setEvaluator = Mockito.mock(SetEvaluator.class);
Mockito.doReturn(setEvaluator).when(mockEvaluator).getSetEvaluator(aggregateArg0, true);
Mockito.doReturn(new UnaryTupleList(endMembers)).when(setEvaluator).evaluateTupleIterable();
Assert.assertEquals(true, member.isCalculated());
Assert.assertEquals(true, SqlConstraintUtils.isSupportedCalculatedMember(member));
return member;
}
use of mondrian.mdx.MemberExpr in project mondrian by pentaho.
the class SqlConstraintUtilsTest method makeSupportedExpressionForCalculatedMember.
private Exp makeSupportedExpressionForCalculatedMember() {
Exp memberExpr = new MemberExpr(Mockito.mock(Member.class));
Assert.assertEquals(true, SqlConstraintUtils.isSupportedExpressionForCalculatedMember(memberExpr));
return memberExpr;
}
use of mondrian.mdx.MemberExpr in project mondrian by pentaho.
the class SqlContextConstraint method findMeasures.
/**
* Extracts the stored measures referenced in an expression
*
* @param exp expression
* @param baseCubes set of base cubes
*/
private static void findMeasures(Exp exp, Set<RolapCube> baseCubes, List<RolapCube> baseCubeList) {
if (exp instanceof MemberExpr) {
MemberExpr memberExpr = (MemberExpr) exp;
Member member = memberExpr.getMember();
if (member instanceof RolapStoredMeasure) {
addMeasure((RolapStoredMeasure) member, baseCubes, baseCubeList);
} else if (member instanceof RolapCalculatedMember) {
findMeasures(member.getExpression(), baseCubes, baseCubeList);
}
} else if (exp instanceof ResolvedFunCall) {
ResolvedFunCall funCall = (ResolvedFunCall) exp;
Exp[] args = funCall.getArgs();
for (Exp arg : args) {
findMeasures(arg, baseCubes, baseCubeList);
}
}
}
Aggregations