Search in sources :

Example 1 with Dimension

use of mondrian.olap.Dimension in project mondrian by pentaho.

the class RestrictedMemberReaderTest method testGetHierarchy_allAccess.

public void testGetHierarchy_allAccess() {
    Schema schema = Mockito.mock(Schema.class);
    Dimension dimension = Mockito.mock(Dimension.class);
    RolapHierarchy hierarchy = Mockito.mock(RolapHierarchy.class);
    Level[] hierarchyAccessLevels = new Level[] { null };
    MemberReader delegateMemberReader = Mockito.mock(MemberReader.class);
    HierarchyAccess roleAccess = null;
    Role role = Mockito.mock(Role.class);
    Mockito.doReturn(schema).when(dimension).getSchema();
    Mockito.doReturn(dimension).when(hierarchy).getDimension();
    Mockito.doReturn(hierarchyAccessLevels).when(hierarchy).getLevels();
    Mockito.doReturn(true).when(hierarchy).isRagged();
    Mockito.doReturn(roleAccess).when(role).getAccessDetails(Mockito.any(Hierarchy.class));
    Mockito.doReturn(hierarchy).when(delegateMemberReader).getHierarchy();
    rmr = new RestrictedMemberReader(delegateMemberReader, role);
    Assert.assertSame(hierarchy, rmr.getHierarchy());
}
Also used : Role(mondrian.olap.Role) Hierarchy(mondrian.olap.Hierarchy) Schema(mondrian.olap.Schema) Level(mondrian.olap.Level) Dimension(mondrian.olap.Dimension) HierarchyAccess(mondrian.olap.Role.HierarchyAccess)

Example 2 with Dimension

use of mondrian.olap.Dimension in project mondrian by pentaho.

the class RestrictedMemberReaderTest method testDefaultMember_allAccess.

public void testDefaultMember_allAccess() {
    Schema schema = Mockito.mock(Schema.class);
    Dimension dimension = Mockito.mock(Dimension.class);
    RolapHierarchy hierarchy = Mockito.mock(RolapHierarchy.class);
    Level[] hierarchyAccessLevels = new Level[] { null };
    MemberReader delegateMemberReader = Mockito.mock(MemberReader.class);
    HierarchyAccess roleAccess = null;
    Role role = Mockito.mock(Role.class);
    Mockito.doReturn(schema).when(dimension).getSchema();
    Mockito.doReturn(dimension).when(hierarchy).getDimension();
    Mockito.doReturn(hierarchyAccessLevels).when(hierarchy).getLevels();
    Mockito.doReturn(true).when(hierarchy).isRagged();
    Mockito.doReturn(roleAccess).when(role).getAccessDetails(Mockito.any(Hierarchy.class));
    Mockito.doReturn(hierarchy).when(delegateMemberReader).getHierarchy();
    RolapMember hDefaultMember = mockMember();
    Mockito.doReturn(hDefaultMember).when(hierarchy).getDefaultMember();
    rmr = new RestrictedMemberReader(delegateMemberReader, role);
    Assert.assertSame(hDefaultMember, rmr.getDefaultMember());
}
Also used : Role(mondrian.olap.Role) Hierarchy(mondrian.olap.Hierarchy) Schema(mondrian.olap.Schema) Level(mondrian.olap.Level) Dimension(mondrian.olap.Dimension) HierarchyAccess(mondrian.olap.Role.HierarchyAccess)

Example 3 with Dimension

use of mondrian.olap.Dimension in project pentaho-platform by pentaho.

the class MDXMetaDataTest method mockMember.

private Member mockMember(String caption, String name) {
    Level level = mockLevel(name);
    Dimension dimension = mockDimension(name);
    Hierarchy hierarchy = mockHierarchy(name, caption);
    Member member = mock(Member.class);
    when(member.getCaption()).thenReturn(caption);
    when(member.getHierarchy()).thenReturn(hierarchy);
    when(member.getDimension()).thenReturn(dimension);
    when(member.getLevel()).thenReturn(level);
    return member;
}
Also used : Hierarchy(mondrian.olap.Hierarchy) Level(mondrian.olap.Level) Dimension(mondrian.olap.Dimension) Member(mondrian.olap.Member)

Example 4 with Dimension

use of mondrian.olap.Dimension in project mondrian by pentaho.

the class SqlMemberSourceTest method getStoreHierarchyMock.

// Mock for the Store hierarchy
private RolapHierarchy getStoreHierarchyMock() {
    MondrianDef.Relation relationMock = mock(MondrianDef.Relation.class);
    when(relationMock.getAlias()).thenReturn(STORE_TABLE);
    Dimension dimMock = mock(Dimension.class);
    when(dimMock.getDimensionType()).thenReturn(null);
    SchemaKey sKeyMock = mock(SchemaKey.class);
    RolapConnection rlConnectionMock = mock(RolapConnection.class);
    RolapSchema rlSchema = new RolapSchema(sKeyMock, MD5_BYTE_STRING, rlConnectionMock);
    RolapHierarchy rlHierarchyStoreMock = mock(RolapHierarchy.class);
    when(rlConnectionMock.getDataSource()).thenReturn(dataSourceMock);
    when(rlHierarchyStoreMock.getRolapSchema()).thenReturn(rlSchema);
    when(rlHierarchyStoreMock.getUniqueName()).thenReturn("[Store]");
    when(rlHierarchyStoreMock.getUniqueTable()).thenReturn(relationMock);
    when(rlHierarchyStoreMock.getDimension()).thenReturn(dimMock);
    when(rlHierarchyStoreMock.tableExists(STORE_TABLE)).thenReturn(true);
    return rlHierarchyStoreMock;
}
Also used : MondrianDef(mondrian.olap.MondrianDef) Dimension(mondrian.olap.Dimension)

Example 5 with Dimension

use of mondrian.olap.Dimension in project mondrian by pentaho.

the class SqlConstraintUtils method hasMultipleLevelSlicer.

public static boolean hasMultipleLevelSlicer(Evaluator evaluator) {
    Map<Dimension, Level> levels = new HashMap<Dimension, Level>();
    List<Member> slicerMembers = expandSupportedCalculatedMembers(((RolapEvaluator) evaluator).getSlicerMembers(), evaluator).getMembers();
    for (Member member : slicerMembers) {
        if (member.isAll()) {
            continue;
        }
        Level before = levels.put(member.getDimension(), member.getLevel());
        if (before != null && !before.equals(member.getLevel())) {
            return true;
        }
    }
    return false;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Level(mondrian.olap.Level) Dimension(mondrian.olap.Dimension) Member(mondrian.olap.Member) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)

Aggregations

Dimension (mondrian.olap.Dimension)7 Hierarchy (mondrian.olap.Hierarchy)4 Level (mondrian.olap.Level)4 Member (mondrian.olap.Member)3 Schema (mondrian.olap.Schema)3 Role (mondrian.olap.Role)2 HierarchyAccess (mondrian.olap.Role.HierarchyAccess)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Cube (mondrian.olap.Cube)1 MondrianDef (mondrian.olap.MondrianDef)1 MondrianException (mondrian.olap.MondrianException)1 Query (mondrian.olap.Query)1 MultiCardinalityDefaultMember (mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)1 LimitedRollupMember (mondrian.rolap.RolapHierarchy.LimitedRollupMember)1 Locus (mondrian.server.Locus)1 MondrianCatalogComplementInfo (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogComplementInfo)1