Skip to content

Commit

Permalink
A few more parameters to OlapDatabaseMetaData.getXxx methods
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@30 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Sep 21, 2007
1 parent 9c858b6 commit b07c768
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 49 deletions.
16 changes: 13 additions & 3 deletions src/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,9 @@ public ResultSet getLiterals() throws OlapException {
}

public ResultSet getDatabaseProperties(
String dataSourceName, String propertyNamePattern) throws OlapException {
String dataSourceName,
String propertyNamePattern) throws OlapException
{
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

Expand Down Expand Up @@ -861,7 +863,9 @@ public ResultSet getDimensions(
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

public ResultSet getFunctions() throws OlapException {
public ResultSet getFunctions(
String functionNamePattern) throws OlapException
{
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

Expand All @@ -876,7 +880,13 @@ public ResultSet getHierarchies(
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

public ResultSet getMeasures(String catalog, String schemaPattern, String cubeNamePattern, String measureNamePattern, String measureUniqueName) throws OlapException {
public ResultSet getMeasures(
String catalog,
String schemaPattern,
String cubeNamePattern,
String measureNamePattern,
String measureUniqueName) throws OlapException
{
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

Expand Down
51 changes: 41 additions & 10 deletions src/org/olap4j/OlapDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public interface OlapDatabaseMetaData extends DatabaseMetaData, OlapWrapper {
* action description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getActions(
String catalog,
Expand Down Expand Up @@ -127,6 +129,8 @@ ResultSet getDatasources(
* the description of a database property
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getDatabaseProperties(
String dataSourceName,
Expand Down Expand Up @@ -184,6 +188,8 @@ ResultSet getDatabaseProperties(
* description of a member or cell property
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getProperties(
String catalog,
Expand Down Expand Up @@ -228,6 +234,8 @@ ResultSet getProperties(
* @return <code>ResultSet</code> in which each row is a cube description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
public ResultSet getCubes(
String catalog,
Expand Down Expand Up @@ -267,6 +275,8 @@ public ResultSet getCubes(
* dimension description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getDimensions(
String catalog,
Expand All @@ -282,12 +292,19 @@ ResultSet getDimensions(
*
* <p>todo: document parameters and result set columns
*
* @param functionNamePattern a function name pattern; must match the
* function name as it is stored in the database; <code>null</code>
* means that the function name should not be used to narrow the
* search
*
* @return a <code>ResultSet</code> object in which each row is a
* function description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getFunctions() throws OlapException;
ResultSet getFunctions(String functionNamePattern) throws OlapException;

/**
* Retrieves a result set describing each hierarchy within a particular
Expand Down Expand Up @@ -326,6 +343,8 @@ ResultSet getDimensions(
* hierarchy description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getHierarchies(
String catalog,
Expand Down Expand Up @@ -369,6 +388,8 @@ ResultSet getHierarchies(
* measure description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getMeasures(
String catalog,
Expand Down Expand Up @@ -419,19 +440,25 @@ ResultSet getMeasures(
* the search
*
* @param treeOp Only applies to a single member.
* {@link org.olap4j.metadata.Member.TreeOp#ANCESTORS} returns all of the ancestors;
* {@link org.olap4j.metadata.Member.TreeOp#CHILDREN} returns only the immediate
* children;
* {@link org.olap4j.metadata.Member.TreeOp#SIBLINGS} returns members on the same level;
* {@link org.olap4j.metadata.Member.TreeOp#PARENT} returns only the immediate parent;
* {@link org.olap4j.metadata.Member.TreeOp#SELF} returns itself in the list of returned
* rows;
* {@link org.olap4j.metadata.Member.TreeOp#DESCENDANTS} returns all of the descendants.
* {@link org.olap4j.metadata.Member.TreeOp#ANCESTORS}
* returns all of the ancestors;
* {@link org.olap4j.metadata.Member.TreeOp#CHILDREN}
* returns only the immediate children;
* {@link org.olap4j.metadata.Member.TreeOp#SIBLINGS}
* returns members on the same level;
* {@link org.olap4j.metadata.Member.TreeOp#PARENT}
* returns only the immediate parent;
* {@link org.olap4j.metadata.Member.TreeOp#SELF}
* returns itself in the list of returned rows;
* {@link org.olap4j.metadata.Member.TreeOp#DESCENDANTS}
* returns all of the descendants.
*
* @return a <code>ResultSet</code> object in which each row is a
* member description
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getMembers(
String catalog,
Expand Down Expand Up @@ -484,7 +511,9 @@ ResultSet getMembers(
* @return a <code>ResultSet</code> object in which each row is a
* level description
*
* @exception OlapException if a database access error occurs @param catalog
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getLevels(
String catalog,
Expand Down Expand Up @@ -525,6 +554,8 @@ ResultSet getLevels(
* description of a named set
*
* @exception OlapException if a database access error occurs
*
* @see #getSearchStringEscape
*/
ResultSet getSets(
String catalog,
Expand Down
16 changes: 13 additions & 3 deletions src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,9 @@ public ResultSet getDimensions(
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

public ResultSet getFunctions() throws OlapException {
public ResultSet getFunctions(
String functionNamePattern) throws OlapException
{
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

Expand All @@ -857,7 +859,13 @@ public ResultSet getHierarchies(
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

public ResultSet getMeasures(String catalog, String schemaPattern, String cubeNamePattern, String measureNamePattern, String measureUniqueName) throws OlapException {
public ResultSet getMeasures(
String catalog,
String schemaPattern,
String cubeNamePattern,
String measureNamePattern,
String measureUniqueName) throws OlapException
{
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}

Expand All @@ -867,7 +875,9 @@ public ResultSet getMembers(
String cubeNamePattern,
String dimensionNamePattern,
String hierarchyNamePattern,
String levelNamePattern, String memberUniqueName, Member.TreeOp treeOp) throws OlapException
String levelNamePattern,
String memberUniqueName,
Member.TreeOp treeOp) throws OlapException
{
return olap4jConnection.factory.newEmptyResultSet(olap4jConnection);
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/olap4j/metadata/Dimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public enum Type {
CUSTOMERS(7),
PRODUCTS(8),
SCENARIO(9),
UTILIY(10),
UTILITY(10),
CURRENCY(11),
RATES(12),
CHANNEL(13),
Expand Down
77 changes: 53 additions & 24 deletions src/org/olap4j/metadata/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,34 +203,63 @@ private Type(int ordinal) {
*/
Member getDataMember();

enum TreeOp {
CHILDREN("MDTREEOP_CHILDREN", 1, "Returns only the immediate children"),
SIBLINGS("MDTREEOP_SIBLINGS", 2, "Returns members on the same level"),
PARENT("MDTREEOP_PARENT", 4, "Returns only the immediate parent"),
SELF("MDTREEOP_SELF", 8, "Returns the immediate member in the list of returned rows"),
DESCENDANTS("MDTREEOP_DESCENDANTS", 16, "Returns all descendants"),
ANCESTORS("MDTREEOP_ANCESTORS", 32, "Returns all ancestors");

private final String userName;
private final int userOrdinal;
private final String description;

TreeOp(String userName, int userOrdinal, String description) {
this.userName = userName;
this.userOrdinal = userOrdinal;
this.description = description;
}
/**
* Enumeration of tree operations which can be used when querying
* members.
*
* <p>Some of the values are as specified by XMLA.
* For example, XMLA specifies MDTREEOP_CHILDREN with ordinal 1,
* which corresponds to the value {@link #CHILDREN}.
*
* @see org.olap4j.OlapDatabaseMetaData#getMembers
*/
public enum TreeOp {
/**
* Tree operation which returns only the immediate children.
*/
CHILDREN(1),

public int userOrdinal() {
return userOrdinal;
}
/**
* Tree operation which returns members on the same level.
*/
SIBLINGS(2),

/**
* Tree operation which returns only the immediate parent.
*/
PARENT(4),

/**
* Tree operation which returns itself in the list of returned rows.
*/
SELF(8),

/**
* Tree operation which returns all of the descendants.
*/
DESCENDANTS(16),

public String userName() {
return userName;
/**
* Tree operation which returns all of the ancestors.
*/
ANCESTORS(32);

private final int xmlaOrdinal;

private TreeOp(int userOrdinal) {
this.xmlaOrdinal = userOrdinal;
}

public String getDescription() {
return description;
/**
* Returns the ordinal code as specified by XMLA.
*
* <p>For example, the XMLA specification says that the ordinal of
* {@link #ANCESTORS} is 32.
*
* @return ordinal code as specified by XMLA.
*/
public int xmlaOrdinal() {
return xmlaOrdinal;
}
}
}
Expand Down
21 changes: 13 additions & 8 deletions testsrc/org/olap4j/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public void testDatabaseMetaData() throws SQLException {
String measureNamePattern = null;
String measureUniqueName = null;
Member.TreeOp treeOp = null;
String functionNamePattern = null;

checkResultSet(
olapDatabaseMetaData.getActions(
Expand Down Expand Up @@ -354,27 +355,29 @@ public void testDatabaseMetaData() throws SQLException {
assertTrue(k > 0);

checkResultSet(
olapDatabaseMetaData.getDatabaseProperties(dataSourceName, propertyNamePattern));
olapDatabaseMetaData.getDatabaseProperties(
dataSourceName, propertyNamePattern));

checkResultSet(
olapDatabaseMetaData.getDatasources(dataSourceName));

checkResultSet(
olapDatabaseMetaData.getDimensions(
catalogNamePattern, schemaPattern, cubeNamePattern, dimensionNamePattern));
catalogNamePattern, schemaPattern, cubeNamePattern,
dimensionNamePattern));

checkResultSet(
olapDatabaseMetaData.getFunctions());
olapDatabaseMetaData.getFunctions(functionNamePattern));

checkResultSet(
olapDatabaseMetaData.getHierarchies(
catalogNamePattern, schemaPattern, cubeNamePattern, dimensionNamePattern,
hierarchyNamePattern));
catalogNamePattern, schemaPattern, cubeNamePattern,
dimensionNamePattern, hierarchyNamePattern));

checkResultSet(
olapDatabaseMetaData.getLevels(
catalogNamePattern, schemaPattern, cubeNamePattern, dimensionNamePattern,
hierarchyNamePattern, levelNamePattern));
catalogNamePattern, schemaPattern, cubeNamePattern,
dimensionNamePattern, hierarchyNamePattern, levelNamePattern));

checkResultSet(
olapDatabaseMetaData.getLiterals());
Expand All @@ -398,7 +401,8 @@ public void testDatabaseMetaData() throws SQLException {

checkResultSet(
olapDatabaseMetaData.getSets(
catalogNamePattern, schemaPattern, cubeNamePattern, setNamePattern));
catalogNamePattern, schemaPattern, cubeNamePattern,
setNamePattern));

// todo: More tests required for other methods on DatabaseMetaData
}
Expand Down Expand Up @@ -630,6 +634,7 @@ public void testPreparedStatement() throws SQLException {
assertIsClosed(cellSet6, true);

// todo: test all of the PreparedOlapStatement.setXxx methods
if (false) pstmt.getCube();
}

public void testCellSetMetaData() throws SQLException {
Expand Down

0 comments on commit b07c768

Please sign in to comment.