Skip to content

Commit

Permalink
MONDRIAN-LAGUNITAS: Integrate from main @14886.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian-release/lagunitas/": change = 14889]
  • Loading branch information
julianhyde committed Jan 18, 2012
1 parent 70b3dc7 commit b47d0a1
Show file tree
Hide file tree
Showing 25 changed files with 574 additions and 68 deletions.
10 changes: 7 additions & 3 deletions src/main/mondrian/olap/Formula.java
Expand Up @@ -4,7 +4,7 @@
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2000-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.
*/
Expand Down Expand Up @@ -125,7 +125,10 @@ void accept(Validator validator) {
if (isMember) {
Exp formatExp = getFormatExp(validator);
if (formatExp != null) {
mdxMember.setProperty(Property.FORMAT_EXP.name, formatExp);
mdxMember.setProperty(
Property.FORMAT_EXP_PARSED.name, formatExp);
mdxMember.setProperty(
Property.FORMAT_EXP.name, Util.unparse(formatExp));
}

final List<MemberProperty> memberPropertyList =
Expand Down Expand Up @@ -610,7 +613,8 @@ private void returnFormula(Member member) {
}

private Exp getFormula(Member member) {
return (Exp) member.getPropertyValue(Property.FORMAT_EXP.name);
return (Exp)
member.getPropertyValue(Property.FORMAT_EXP_PARSED.name);
}
}
}
Expand Down
68 changes: 57 additions & 11 deletions src/main/mondrian/olap/Property.java
Expand Up @@ -4,7 +4,7 @@
// 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.
//
Expand Down Expand Up @@ -84,14 +84,15 @@ public enum Datatype {
public static final Map<String, Property> mapUpperNameToProperties =
new HashMap<String, Property>();

public static final int FORMAT_EXP_ORDINAL = 0;
public static final int FORMAT_EXP_PARSED_ORDINAL = 0;
/**
* Definition of the internal property which
* holds the parsed format string (an object of type {@link Exp}).
*/
public static final Property FORMAT_EXP =
public static final Property FORMAT_EXP_PARSED =
new Property(
"$format_exp", Datatype.TYPE_OTHER, FORMAT_EXP_ORDINAL, true, false,
"$format_exp", Datatype.TYPE_OTHER,
FORMAT_EXP_PARSED_ORDINAL, true, false,
false, null);

public static final int AGGREGATION_TYPE_ORDINAL = 1;
Expand Down Expand Up @@ -662,6 +663,46 @@ public enum Datatype {
false, false, true,
"The translation expressed as an LCID. Only valid for property translations.");

public static final int FORMAT_EXP_ORDINAL = 53;

/**
* Definition of the property which
* holds the format string.
*/
public static final Property FORMAT_EXP =
new Property(
"FORMAT_EXP", Datatype.TYPE_STRING, FORMAT_EXP_ORDINAL, true, true,
false, null);

public static final int ACTION_TYPE_ORDINAL = 54;

/**
* Definition of the property which
* holds the format string.
*/
public static final Property ACTION_TYPE =
new Property(
"ACTION_TYPE", Datatype.TYPE_NUMERIC, ACTION_TYPE_ORDINAL, false,
false, true, null);

public static final int DRILLTHROUGH_COUNT_ORDINAL = 55;

/**
* Definition of the property that
* holds the number of fact rows that contributed to this cell.
* If the cell is not drillable, returns -1.
*
* <p>Note that this property may be expensive to compute for some
* cubes.</p>
*/
public static final Property DRILLTHROUGH_COUNT =
new Property(
"DRILLTHROUGH_COUNT", Datatype.TYPE_NUMERIC,
DRILLTHROUGH_COUNT_ORDINAL, false,
false, true,
"Number of fact rows that contributed to this cell. If the cell is "
+ "not drillable, value is -1.");

/**
* The various property names which define a format string.
*/
Expand Down Expand Up @@ -741,24 +782,23 @@ public boolean isMemberProperty() {
}

/**
* Returns whether this property is a standard member property.
* Returns whether this property is a standard cell property.
*/
public boolean isCellProperty() {
return cell && ordinal <= VALUE_ORDINAL;
return cell && isStandard();
}

/**
* Returns whether this property is standard.
*/
public boolean isStandard() {
return ordinal <= VALUE_ORDINAL;
return ordinal < MAX_ORDINAL;
}


public static final EnumeratedValues<Property> enumeration =
new EnumeratedValues<Property>(
new Property[] {
FORMAT_EXP,
FORMAT_EXP_PARSED,
AGGREGATION_TYPE,
NAME,
CAPTION,
Expand Down Expand Up @@ -803,18 +843,24 @@ public boolean isStandard() {
KEY,
SCENARIO,
DISPLAY_FOLDER,
FORMAT_EXP,
ACTION_TYPE,
DRILLTHROUGH_COUNT,
});

private static final int MAX_ORDINAL = 56;

static {
// Populate synonyms.
synonyms.put("CAPTION", MEMBER_CAPTION);
synonyms.put("FORMAT", FORMAT_STRING);

// Populate map of upper-case property names.
for (String propertyName : enumeration.getNames()) {
final Property property = enumeration.getValue(propertyName, true);
mapUpperNameToProperties.put(
propertyName.toUpperCase(),
enumeration.getValue(propertyName, true));
propertyName.toUpperCase(), property);
assert property.getOrdinal() < MAX_ORDINAL;
}

// Add synonyms.
Expand Down
12 changes: 10 additions & 2 deletions src/main/mondrian/olap4j/MondrianOlap4jCatalog.java
Expand Up @@ -3,13 +3,14 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2011 Julian Hyde
// Copyright (C) 2007-2012 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap4j;

import mondrian.olap.Access;
import mondrian.olap.OlapElement;
import mondrian.rolap.RolapSchema;

import org.olap4j.OlapDatabaseMetaData;
Expand All @@ -27,7 +28,10 @@
* @version $Id$
* @since May 23, 2007
*/
class MondrianOlap4jCatalog implements Catalog, Named {
class MondrianOlap4jCatalog
extends MondrianOlap4jMetadataElement
implements Catalog, Named
{
final MondrianOlap4jDatabaseMetaData olap4jDatabaseMetaData;
final String name;
final Map<String, RolapSchema> schemaMap;
Expand Down Expand Up @@ -95,6 +99,10 @@ public OlapDatabaseMetaData getMetaData() {
public Database getDatabase() {
return olap4jDatabase;
}

protected OlapElement getOlapElement() {
return null;
}
}

// End MondrianOlap4jCatalog.java
@@ -1,8 +1,9 @@
/*
// $Id$
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2012 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -59,6 +60,10 @@ class MondrianOlap4jCellSetAxisMetaData implements CellSetAxisMetaData {
olap4jProperty =
Util.lookup(
Property.StandardMemberProperty.class, names[0]);
if (olap4jProperty == null) {
olap4jProperty =
MondrianOlap4jProperty.MEMBER_EXTENSIONS.get(names[0]);
}
}
if (olap4jProperty == null) {
final UnresolvedFunCall call =
Expand Down
16 changes: 11 additions & 5 deletions src/main/mondrian/olap4j/MondrianOlap4jCellSetMetaData.java
Expand Up @@ -3,19 +3,20 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2012 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap4j;

import mondrian.olap.Query;
import mondrian.olap.QueryAxis;
import mondrian.olap.*;

import org.olap4j.CellSetAxisMetaData;
import org.olap4j.CellSetMetaData;
import org.olap4j.impl.ArrayNamedListImpl;
import org.olap4j.metadata.*;
import org.olap4j.metadata.Cube;
import org.olap4j.metadata.Property;

import java.sql.SQLException;

Expand Down Expand Up @@ -64,8 +65,13 @@ protected String getName(Property property) {
return property.getName();
}
};
for (Property.StandardCellProperty property
: Property.StandardCellProperty.values())
for (Property property : Property.StandardCellProperty.values()) {
if (query.hasCellProperty(property.getName())) {
list.add(property);
}
}
for (Property property
: MondrianOlap4jProperty.CELL_EXTENSIONS.values())
{
if (query.hasCellProperty(property.getName())) {
list.add(property);
Expand Down
26 changes: 24 additions & 2 deletions src/main/mondrian/olap4j/MondrianOlap4jConnection.java
Expand Up @@ -12,6 +12,7 @@
import mondrian.mdx.*;
import mondrian.olap.*;
import mondrian.olap.Member;
import mondrian.olap.fun.MondrianEvaluationException;
import mondrian.rolap.*;
import mondrian.xmla.XmlaHandler;

Expand Down Expand Up @@ -738,7 +739,7 @@ OlapException createException(Cell context, String msg) {
OlapException createException(
Cell context, String msg, Throwable cause)
{
OlapException exception = new OlapException(msg, cause);
OlapException exception = createException(msg, cause);
exception.setContext(context);
return exception;
}
Expand All @@ -753,7 +754,28 @@ OlapException createException(
OlapException createException(
String msg, Throwable cause)
{
return new OlapException(msg, cause);
String sqlState = deduceSqlState(cause);
assert !mondrian.util.Bug.olap4jUpgrade(
"use OlapException(String, String, Throwable) ctor");
final OlapException e = new OlapException(msg, sqlState);
e.initCause(cause);
return e;
}

private String deduceSqlState(Throwable cause) {
if (cause == null) {
return null;
}
if (cause instanceof ResourceLimitExceededException) {
return "ResourceLimitExceeded";
}
if (cause instanceof QueryTimeoutException) {
return "QueryTimeout";
}
if (cause instanceof MondrianEvaluationException) {
return "EvaluationException";
}
return null;
}

/**
Expand Down
26 changes: 15 additions & 11 deletions src/main/mondrian/olap4j/MondrianOlap4jCube.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2011 Julian Hyde
// Copyright (C) 2007-2012 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -32,7 +32,10 @@
* @version $Id$
* @since May 24, 2007
*/
class MondrianOlap4jCube implements Cube, Named {
class MondrianOlap4jCube
extends MondrianOlap4jMetadataElement
implements Cube, Named
{
final mondrian.olap.Cube cube;
final MondrianOlap4jSchema olap4jSchema;

Expand Down Expand Up @@ -103,9 +106,7 @@ public NamedList<Hierarchy> getHierarchies() {
}

public List<Measure> getMeasures() {
final Dimension dimension =
(MondrianOlap4jDimension)
getDimensions().get("Measures");
final Dimension dimension = getDimensions().get("Measures");
if (dimension == null) {
return Collections.emptyList();
}
Expand All @@ -119,17 +120,17 @@ public List<Measure> getMeasures() {
(MondrianOlap4jLevel)
dimension.getDefaultHierarchy()
.getLevels().get(0);
final List<Measure> measaures =
final List<Measure> measures =
new ArrayList<Measure>();
List<mondrian.olap.Member> levelMembers =
schemaReader.getLevelMembers(
measuresLevel.level,
true);
for (mondrian.olap.Member member : levelMembers) {
measaures.add(
(Measure)olap4jConnection.toOlap4j(member));
measures.add(
(Measure) olap4jConnection.toOlap4j(member));
}
return measaures;
return measures;
} catch (OlapException e) {
// OlapException not possible, since measures are stored in memory.
// Demote from checked to unchecked exception.
Expand Down Expand Up @@ -162,8 +163,7 @@ public String getUniqueName() {

public String getCaption() {
return cube.getLocalized(
OlapElement.LocalizedProperty.CAPTION,
olap4jSchema.getLocale());
OlapElement.LocalizedProperty.CAPTION, olap4jSchema.getLocale());
}

public String getDescription() {
Expand Down Expand Up @@ -310,6 +310,10 @@ private void addDescendants(
public boolean isDrillThroughEnabled() {
return true;
}

protected OlapElement getOlapElement() {
return cube;
}
}

// End MondrianOlap4jCube.java

0 comments on commit b47d0a1

Please sign in to comment.