Skip to content

Commit

Permalink
MONDRIAN:
Browse files Browse the repository at this point in the history
Sweep through the olap directory moving the code towards
compliance with the style guidelines. In addition, instance
variables were made "private" and/or "final" where possible.
It was discovered that 7 "public" instance variables could not
be made "private" because they are directly accessed by
JPivot code - amazing. As needed, getters and setters are now
provided for those instance varables and directly accessing
implementation details rather than type interfaces should be 
deprecated. Also, there are 3 classes in JPivot that access
classes in the Mondrian rolap implementation directory.

[git-p4: depot-paths = "//open/mondrian/": change = 3313]
  • Loading branch information
Richard Emberson committed Mar 4, 2005
1 parent c62f002 commit e4c6c9b
Show file tree
Hide file tree
Showing 65 changed files with 3,275 additions and 2,202 deletions.
12 changes: 6 additions & 6 deletions src/main/mondrian/olap/CellFormatter.java
Expand Up @@ -15,11 +15,11 @@
*/
public interface CellFormatter {

/**
* user provided cell formatting function
* @param value
* @return the formatted value
*/
public String formatCell(Object value);
/**
* user provided cell formatting function
* @param value
* @return the formatted value
*/
String formatCell(Object value);

} // CellFormatter
20 changes: 20 additions & 0 deletions src/main/mondrian/olap/Connection.java
Expand Up @@ -11,6 +11,7 @@
*/

package mondrian.olap;

import java.util.Locale;

/**
Expand All @@ -19,8 +20,26 @@
* @see DriverManager
**/
public interface Connection {

/**
* Get the Connect String associated with this Connection.
*
* @return the Connect String (never null).
*/
String getConnectString();

/**
* Get the name of the Catalog associated with this Connection.
*
* @return the Catalog name (never null).
*/
String getCatalogName();

/**
* Get the Schema associated with this Connection.
*
* @return the Schema (never null).
*/
Schema getSchema();

/**
Expand Down Expand Up @@ -66,6 +85,7 @@ public interface Connection {
* @post role.isMutable()
*/
Role getRole();

/**
* Returns a schema reader with access control appropriate to the current
* role.
Expand Down
21 changes: 13 additions & 8 deletions src/main/mondrian/olap/ConnectionBase.java
Expand Up @@ -22,23 +22,27 @@
* @since 6 August, 2001
* @version $Id$
**/
public abstract class ConnectionBase implements Connection
{
public abstract class ConnectionBase implements Connection {

protected ConnectionBase() {
}

protected abstract Logger getLogger();

public String getFullConnectString()
{
String s = getConnectString(),
catalogName = getCatalogName();
public String getFullConnectString() {
String s = getConnectString();
String catalogName = getCatalogName();
if (catalogName != null) {
int len = s.length() + catalogName.length() + 32;
StringBuffer buf = new StringBuffer(len);
buf.append(s);
if (!s.endsWith(";")) {
s += ";";
buf.append(';');
}
s += "Initial Catalog=" + catalogName + ";";
buf.append("Initial Catalog=");
buf.append(catalogName);
buf.append(';');
s = buf.toString();
}
return s;
}
Expand All @@ -58,6 +62,7 @@ public Exp parseExpression(String s) {
Util.assertTrue(
s.startsWith("'") && s.endsWith("'"),
"only string literals are supported right now");

String s2 = s.substring(1, s.length() - 1);
return Literal.createString(s2);
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/mondrian/olap/Cube.java
Expand Up @@ -45,10 +45,35 @@ public interface Cube extends OlapElement {
*/
Dimension getTimeDimension();

/**
* Helper method that returns the Year Level or returns null if the Time
* Dimension does not exist or if Year is not defined in the Time Dimension.
*
* @return Level or null.
*/
Level getYearLevel();

/**
* Return Quarter Level or null.
*
* @return Quarter Level or null.
*/
Level getQuarterLevel();

/**
* Return Month Level or null.
*
* @return Month Level or null.
*/
Level getMonthLevel();

/**
* Return Week Level or null.
*
* @return Week Level or null.
*/
Level getWeekLevel();

/**
* Returns a {@link SchemaReader} for which this cube is the context for
* lookup up members.
Expand Down
70 changes: 38 additions & 32 deletions src/main/mondrian/olap/CubeAccess.java
Expand Up @@ -18,16 +18,16 @@
* This class implements object of type GrantCube to apply permissions
* on user's MDX query
**/
public class CubeAccess
{
public class CubeAccess {

private boolean hasRestrictions;
/** array of hierarchies with no access */
Hierarchy[] noAccessHierarchies;
private Hierarchy[] noAccessHierarchies;
/** array of members which have limited access */
Member[] limitedMembers;
final List hierarchyList;
final List memberList;
Cube mdxCube;
private Member[] limitedMembers;
private final List hierarchyList;
private final List memberList;
private final Cube mdxCube;

/**
* Creates a CubeAccess object.
Expand All @@ -37,8 +37,7 @@ public class CubeAccess
* members by calling addSlicer(). Do NOT forget to call
* {@link #normalizeCubeAccess()} after you done filling cubeAccess.
*/
public CubeAccess(Cube mdxCube)
{
public CubeAccess(Cube mdxCube) {
this.mdxCube = mdxCube;
noAccessHierarchies = null;
limitedMembers = null;
Expand All @@ -47,35 +46,43 @@ public CubeAccess(Cube mdxCube)
memberList = new ArrayList();
}

public boolean hasRestrictions(){ return hasRestrictions; }
public Hierarchy[] getNoAccessHierarchies(){return noAccessHierarchies;}
public Member[] getLimitedMembers(){return limitedMembers; }
public List getNoAccessHierarchyList(){ return hierarchyList; }
public List getLimitedMemberList(){ return memberList; }
public boolean isHierarchyAllowed( Hierarchy mdxHierarchy )
{
public boolean hasRestrictions() {
return hasRestrictions;
}
public Hierarchy[] getNoAccessHierarchies() {
return noAccessHierarchies;
}
public Member[] getLimitedMembers() {
return limitedMembers;
}
public List getNoAccessHierarchyList() {
return hierarchyList;
}
public List getLimitedMemberList() {
return memberList;
}
public boolean isHierarchyAllowed(Hierarchy mdxHierarchy) {
String hierName = mdxHierarchy.getUniqueName();
if( noAccessHierarchies == null || hierName == null ){
if(noAccessHierarchies == null || hierName == null) {
return true;
}
for( int i = 0; i < noAccessHierarchies.length; i++ ){
if( hierName.equalsIgnoreCase(noAccessHierarchies[i].getUniqueName()) ){
for(int i = 0; i < noAccessHierarchies.length; i++) {
if(hierName.equalsIgnoreCase(noAccessHierarchies[i].getUniqueName()) ) {
return false;
}
}
return true;
}

public Member getLimitedMemberForHierarchy(Hierarchy mdxHierarchy)
{
public Member getLimitedMemberForHierarchy(Hierarchy mdxHierarchy) {
String hierName = mdxHierarchy.getUniqueName();
if (limitedMembers == null || hierName == null) {
return null;
}
for (int i = 0; i < limitedMembers.length; i++) {
Hierarchy limitedHierarchy =
limitedMembers[i].getHierarchy();
if (hierName.equalsIgnoreCase( limitedHierarchy.getUniqueName())) {
if (hierName.equalsIgnoreCase(limitedHierarchy.getUniqueName())) {
return limitedMembers[i];
}
}
Expand All @@ -85,13 +92,14 @@ public Member getLimitedMemberForHierarchy(Hierarchy mdxHierarchy)
/**
* Adds restricted hierarchy or limited member based on bMember
*/
public void addGrantCubeSlicer(
String sHierarchy, String sMember, boolean bMember)
{
public void addGrantCubeSlicer(String sHierarchy,
String sMember,
boolean bMember) {
if (bMember) {
boolean fail = false;
Member member = mdxCube.getSchemaReader(null).getMemberByUniqueName(
Util.explode(sMember), fail);
String[] sMembers = Util.explode(sMember);
SchemaReader schemaReader = mdxCube.getSchemaReader(null);
Member member = schemaReader.getMemberByUniqueName(sMembers, fail);
if (member == null) {
throw Util.getRes().newMdxCubeSlicerMemberError(
sMember, sHierarchy, mdxCube.getUniqueName());
Expand All @@ -114,8 +122,7 @@ public void addGrantCubeSlicer(
/** Initializes internal arrays of restricted hierarchies and limited
* members. It has to be called after all 'addSlicer()' calls.
*/
public void normalizeCubeAccess()
{
public void normalizeCubeAccess() {
if (memberList.size() > 0) {
limitedMembers = (Member[])
memberList.toArray(new Member[memberList.size()]);
Expand All @@ -130,8 +137,7 @@ public void normalizeCubeAccess()

/**compares this CubeAccess to the specified Object
*/
public boolean equals( Object object )
{
public boolean equals(Object object) {
if (!(object instanceof CubeAccess)) {
return false;
}
Expand All @@ -148,7 +154,7 @@ public boolean equals( Object object )
return false;
}
}
for (int i = 0; i < limitedMemberList.size(); i++ ){
for (int i = 0; i < limitedMemberList.size(); i++ ) {
if (!this.memberList.contains( limitedMemberList.get(i))) {
return false;
}
Expand Down

0 comments on commit e4c6c9b

Please sign in to comment.