Skip to content

Commit

Permalink
MONDRIAN-LAGUNITAS: Fix issues in AccessControlTest, CompoundSlicerTest,
Browse files Browse the repository at this point in the history
   TestCalculatedMembers, InlineTableTest. Also issues with composite keys
   (levels that are not unique without their parent). Now 2411/3138 tests pass
    (727 failures).

[git-p4: depot-paths = "//open/mondrian-release/lagunitas/": change = 14938]
  • Loading branch information
julianhyde committed Feb 13, 2012
1 parent 0028dd9 commit f8dae45
Show file tree
Hide file tree
Showing 32 changed files with 1,002 additions and 496 deletions.
16 changes: 11 additions & 5 deletions demo/NewFoodMart.xml
Expand Up @@ -202,9 +202,6 @@
<Hierarchy name='Store Size in SQFT'>
<Level attribute='Store Sqft'/>
</Hierarchy>
<Hierarchy name='Store Type'>
<Level attribute='Store Type'/>
</Hierarchy>
</Hierarchies>
</Dimension>

Expand Down Expand Up @@ -397,9 +394,18 @@
<Dimension name='Customer' table='customer' key='Name'>
<Attributes>
<Attribute name='Country' keyColumn='country'/>
<Attribute name='State Province' keyColumn='state_province'/>
<Attribute name='State Province'>
<Key>
<Column name='country'/>
<Column name='state_province'/>
</Key>
<Name>
<Column name='state_province'/>
</Name>
</Attribute>
<Attribute name='City'>
<Key>
<Column name='country'/>
<Column name='state_province'/>
<Column name='city'/>
</Key>
Expand All @@ -409,7 +415,7 @@
</Attribute>
<Attribute name='Name' keyColumn='customer_id' nameColumn='full_name' orderByColumn='full_name'/>
<Attribute name='Gender' keyColumn='gender'/>
<Attribute name='Marital Status' keyColumn='marital_status'/>
<Attribute name='Marital Status' keyColumn='marital_status' approxRowCount='111'/>
<Attribute name='Education' keyColumn='education'/>
<Attribute name='Yearly Income' keyColumn='yearly_income'/>
</Attributes>
Expand Down
8 changes: 6 additions & 2 deletions src/main/mondrian/olap/DimensionBase.java
Expand Up @@ -4,14 +4,17 @@
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2001-2002 Kana Software, Inc.
// Copyright (C) 2001-2011 Julian Hyde and others
// Copyright (C) 2001-2012 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap;

import mondrian.resource.MondrianResource;

import org.olap4j.impl.NamedListImpl;
import org.olap4j.metadata.NamedList;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -29,7 +32,8 @@ public abstract class DimensionBase
protected final String name;
protected final String uniqueName;
protected final String description;
protected final List<Hierarchy> hierarchyList = new ArrayList<Hierarchy>();
protected final NamedList<Hierarchy> hierarchyList =
new NamedListImpl<Hierarchy>();
protected final DimensionType dimensionType;

/**
Expand Down
98 changes: 63 additions & 35 deletions src/main/mondrian/olap/Mondrian4.xml
Expand Up @@ -624,8 +624,8 @@ Revision is $Id$
<![CDATA[
private static final Dimensions EMPTY;
static {
EMPTY = new Dimensions();
EMPTY.array = new Dimension[0];
EMPTY = new Dimensions();
EMPTY.array = new Dimension[0];
}
public NamedList<Dimension> list() {
return new NamedListImpl<Dimension>(
Expand Down Expand Up @@ -747,8 +747,8 @@ Revision is $Id$
<![CDATA[
private static final Hierarchies EMPTY;
static {
EMPTY = new Hierarchies();
EMPTY.array = new Hierarchy[0];
EMPTY = new Hierarchies();
EMPTY.array = new Hierarchy[0];
}
public NamedList<Hierarchy> list() {
return new NamedListImpl<Hierarchy>(
Expand All @@ -773,8 +773,8 @@ Revision is $Id$
<![CDATA[
private static final Attributes EMPTY;
static {
EMPTY = new Attributes();
EMPTY.array = new Attribute[0];
EMPTY = new Attributes();
EMPTY.array = new Attribute[0];
}
public NamedList<Attribute> list() {
return new NamedListImpl<Attribute>(
Expand Down Expand Up @@ -1370,8 +1370,8 @@ Revision is $Id$
<![CDATA[
private static final CalculatedMembers EMPTY;
static {
EMPTY = new CalculatedMembers();
EMPTY.array = new CalculatedMember[0];
EMPTY = new CalculatedMembers();
EMPTY.array = new CalculatedMember[0];
}
public NamedList<CalculatedMember> list() {
return new NamedListImpl<CalculatedMember>(
Expand Down Expand Up @@ -1542,8 +1542,8 @@ Revision is $Id$
<![CDATA[
private static final NamedSets EMPTY;
static {
EMPTY = new NamedSets();
EMPTY.array = new NamedSet[0];
EMPTY = new NamedSets();
EMPTY.array = new NamedSet[0];
}
private NamedList<NamedSet> list() {
return namedList(array);
Expand Down Expand Up @@ -1831,8 +1831,8 @@ Revision is $Id$
<Code><![CDATA[
private static final Hints EMPTY;
static {
EMPTY = new Hints();
EMPTY.array = new Hint[0];
EMPTY = new Hints();
EMPTY.array = new Hint[0];
}
private List<Hint> list() {
return MondrianDef.list(array);
Expand Down Expand Up @@ -1871,8 +1871,6 @@ Revision is $Id$
Rows in table. Maybe empty.</p>
</Doc>
</Array>
<Object name="columnDefs" type="ColumnDefs" required="true"/>
<Object name="rows" type="Rows" required="true"/>
<Code><![CDATA[
public String getAlias() {
return alias;
Expand Down Expand Up @@ -1913,8 +1911,8 @@ Revision is $Id$
<![CDATA[
private static final ColumnDefs EMPTY;
static {
EMPTY = new ColumnDefs();
EMPTY.array = new RealOrCalcColumnDef[0];
EMPTY = new ColumnDefs();
EMPTY.array = new RealOrCalcColumnDef[0];
}
public List<RealOrCalcColumnDef> list() {
return new MutableArrayList<RealOrCalcColumnDef>() {
Expand Down Expand Up @@ -1981,7 +1979,7 @@ Revision is $Id$
<Object name="expression" type="Expression" required="true"/>
</Element>

<Element type="Rows" class="InlineTableElement">
<Element type="Rows" class="Holder,InlineTableElement">
<Doc>
Holder for an array of Row elements.
</Doc>
Expand All @@ -1990,11 +1988,18 @@ Revision is $Id$
<![CDATA[
private static final Rows EMPTY;
static {
EMPTY = new Rows();
EMPTY.array = new Row[0];
EMPTY = new Rows();
EMPTY.array = new Row[0];
}
private List<Row> list() {
return MondrianDef.list(array);
public List<Row> list() {
return new MutableArrayList<Row>() {
protected Row[] getArray() {
return array == null ? EMPTY.array : array;
}
protected void setArray(Row[] ts) {
array = ts;
}
};
}
]]>
</Code>
Expand Down Expand Up @@ -2221,8 +2226,8 @@ Revision is $Id$
<![CDATA[
private static final Aggregates EMPTY;
static {
EMPTY = new Aggregates();
EMPTY.array = new AggTable[0];
EMPTY = new Aggregates();
EMPTY.array = new AggTable[0];
}
private List<AggTable> list() {
return MondrianDef.list(array);
Expand All @@ -2241,8 +2246,8 @@ Revision is $Id$
<![CDATA[
private static final Columns EMPTY;
static {
EMPTY = new Columns();
EMPTY.array = new Column[0];
EMPTY = new Columns();
EMPTY.array = new Column[0];
}
public List<Column> list() {
return new MutableArrayList<Column>() {
Expand Down Expand Up @@ -2494,13 +2499,36 @@ Revision is $Id$
</Element>

<!-- Union ============================================================ -->
<Element type="Union" class="RoleElement">
<Element type="Union" class="Holder,RoleElement">
<Doc>
Body of a Role definition which defines a Role to be the union
of several Roles. The RoleUsage elements must refer to Roles that
have been declared earlier in this schema file.
</Doc>
<Array name="roleUsages" type="RoleUsage" required="true"/>
<Array name="array" type="RoleUsage" required="true">
<Doc>
Role usages.
</Doc>
</Array>
<Code>
<![CDATA[
private static final Union EMPTY;
static {
EMPTY = new Union();
EMPTY.array = new RoleUsage[0];
}
public List<RoleUsage> list() {
return new MutableArrayList<RoleUsage>() {
protected RoleUsage[] getArray() {
return array == null ? EMPTY.array : array;
}
protected void setArray(RoleUsage[] ts) {
array = ts;
}
};
}
]]>
</Code>
</Element>

<!-- RoleUsage ======================================================== -->
Expand Down Expand Up @@ -2601,8 +2629,8 @@ Revision is $Id$
<![CDATA[
private static final Annotations EMPTY;
static {
EMPTY = new Annotations();
EMPTY.array = new Annotation[0];
EMPTY = new Annotations();
EMPTY.array = new Annotation[0];
}
public NamedList<Annotation> list() {
return new NamedListImpl<Annotation>(
Expand Down Expand Up @@ -2815,8 +2843,8 @@ Revision is $Id$
<![CDATA[
private static final MeasureGroups EMPTY;
static {
EMPTY = new MeasureGroups();
EMPTY.array = new MeasureGroup[0];
EMPTY = new MeasureGroups();
EMPTY.array = new MeasureGroup[0];
}
public NamedList<MeasureGroup> list() {
return new NamedListImpl<MeasureGroup>(
Expand Down Expand Up @@ -2905,8 +2933,8 @@ Revision is $Id$
<![CDATA[
private static final Measures EMPTY;
static {
EMPTY = new Measures();
EMPTY.array = new Measure[0];
EMPTY = new Measures();
EMPTY.array = new Measure[0];
}
public NamedList<Measure> list() {
return new NamedListImpl<Measure>(
Expand Down Expand Up @@ -2937,8 +2965,8 @@ Revision is $Id$
<![CDATA[
private static final DimensionLinks EMPTY;
static {
EMPTY = new DimensionLinks();
EMPTY.array = new DimensionLink[0];
EMPTY = new DimensionLinks();
EMPTY.array = new DimensionLink[0];
}
public List<DimensionLink> list() {
return new MutableArrayList<DimensionLink>() {
Expand Down
7 changes: 4 additions & 3 deletions src/main/mondrian/olap/OlapElement.java
Expand Up @@ -4,14 +4,16 @@
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 1998-2002 Kana Software, Inc.
// Copyright (C) 2001-2011 Julian Hyde and others
// Copyright (C) 2001-2012 Julian Hyde and others
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
// jhyde, 21 January, 1999
*/
package mondrian.olap;

import org.olap4j.impl.Named;

import java.util.Locale;

/**
Expand All @@ -20,9 +22,8 @@
*
* @version $Id$
*/
public interface OlapElement {
public interface OlapElement extends Named {
String getUniqueName();
String getName();

String getDescription();

Expand Down
17 changes: 13 additions & 4 deletions src/main/mondrian/olap/RoleImpl.java
Expand Up @@ -12,6 +12,7 @@

import mondrian.rolap.RolapCube;
import mondrian.rolap.RolapCubeDimension;
import mondrian.rolap.RolapCubeHierarchy;

import java.util.*;

Expand Down Expand Up @@ -321,12 +322,20 @@ public void grant(
hierarchy,
new HierarchyAccessImpl(
this, hierarchy, access, topLevel, bottomLevel, rollupPolicy));
// Cascade the access right to 'custom' on the parent dim if necessary
final Access dimAccess =
toAccess(dimensionGrants.get(hierarchy.getDimension()));

// Cascade the access right to 'custom' on the parent dim if necessary.
Access dimAccess = dimensionGrants.get(hierarchy.getDimension());
if (dimAccess == Access.NONE) {
grant(hierarchy.getDimension(), Access.CUSTOM);
dimAccess = Access.CUSTOM;
}
if (dimAccess == null && hierarchy instanceof RolapCubeHierarchy) {
RolapCube cube = ((RolapCubeHierarchy) hierarchy).getCube();
dimAccess = cubeGrants.get(cube);
}
if (dimAccess == null) {
dimAccess = Access.ALL;
}
grant(hierarchy.getDimension(), dimAccess);
}

public Access getAccess(Hierarchy hierarchy) {
Expand Down
18 changes: 7 additions & 11 deletions src/main/mondrian/rolap/PhysSchemaConverter.java
Expand Up @@ -208,37 +208,33 @@ private MondrianDef.InlineTable toDef(
MondrianDef.InlineTable xmlInlineTable =
new MondrianDef.InlineTable();
xmlInlineTable.alias = physInlineTable.getAlias();
final List<MondrianDef.ColumnDef> columnDefList =
new ArrayList<MondrianDef.ColumnDef>();
final List<MondrianDef.RealOrCalcColumnDef> xmlColumnDefs =
xmlInlineTable.children.holder(new MondrianDef.ColumnDefs()).list();
for (RolapSchema.PhysColumn elementDef
: physInlineTable.columnsByName.values())
{
MondrianDef.ColumnDef xmlColumn = new MondrianDef.ColumnDef();
xmlColumn.name = elementDef.name;
xmlColumn.type = elementDef.datatype.name();
columnDefList.add(xmlColumn);
xmlColumnDefs.add(xmlColumn);
}
xmlInlineTable.columnDefs.array =
columnDefList.toArray(
new MondrianDef.RealOrCalcColumnDef[columnDefList.size()]);
final List<MondrianDef.Row> rowList = new ArrayList<MondrianDef.Row>();
final List<MondrianDef.Row> xmlRows =
xmlInlineTable.children.holder(new MondrianDef.Rows()).list();
for (String[] values : physInlineTable.rowList) {
MondrianDef.Row xmlRow = new MondrianDef.Row();
final List<MondrianDef.Value> valueList =
new ArrayList<MondrianDef.Value>();
for (int i = 0; i < values.length; i++) {
String value = values[i];
MondrianDef.Value xmlValue = new MondrianDef.Value();
xmlValue.column = columnDefList.get(i).name;
xmlValue.column = xmlColumnDefs.get(i).name;
xmlValue.cdata = value;
valueList.add(xmlValue);
}
xmlRow.values =
valueList.toArray(new MondrianDef.Value[valueList.size()]);
rowList.add(xmlRow);
xmlRows.add(xmlRow);
}
xmlInlineTable.rows.array =
rowList.toArray(new MondrianDef.Row[rowList.size()]);
xmlTables.put(physInlineTable.getAlias(), xmlInlineTable);
return xmlInlineTable;
}
Expand Down

0 comments on commit f8dae45

Please sign in to comment.