US and Worldwide: +1 (866) 660-7555
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: DimensionUsage twice in the same cube, pointing to the same shared Dimension

  1. #1
    Join Date
    Nov 2007
    Posts
    1

    Default DimensionUsage twice in the same cube, pointing to the same shared Dimension

    This is my inaugural post, so please be kind. I apologize in advance for being a newbie. I am trying my best to digest Mondrian and all it entails, but it hasn't been easy.

    Right now, I am trying to build a cube around a fact table that contains many timestamps. I have built a shared dimension for time and placed it outside the cube in the schema definition. It worked great when I added my first DimensionUsage (resolve time), but when I added a second one (creation time), I ran into a roadblock: It wants to have the "name" attribute be the same as the "source" attribute. I do not understand why this is the case, but have attempted to work around it by using the "usagePrefix" attribute. The cube is now functional and I can access it in cmdrunner and in my analysis tool (JasperAnalysis), but the time dimension appears only once. It would be very useful to be able to do my time analysis or more than one column in my fact table.

    Here is the beginning of my schema, where the relevant portions are shown:

    Code:
    <Schema name="services-assurance">
      <Dimension name="time-traditional" type="TimeDimension">
        <Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="day_key">
          <Table name="dimension_time"/>
          <Level name="Year" column="year_key" ordinalColumn="year_key" uniqueMembers="true" nameColumn="year_name" levelType="TimeYears" type="Integer"/>
          <Level name="Quarter" column="quarter_key" uniqueMembers="false" nameColumn="quarter_name" captionColumn="quarter_text" levelType="TimeQuarters" type="Integer"/>
          <Level name="Month" column="month_key" ordinalColumn="month_key" uniqueMembers="false" nameColumn="month_name" captionColumn="month_text" levelType="TimeMonths" type="Integer"/>
          <Level name="Week" column="week_key" ordinalColumn="week_key" uniqueMembers="false" nameColumn="week_name" captionColumn="week_text" levelType="TimeWeeks" type="Integer"/>
          <Level name="Day" column="day_key" ordinalColumn="day_key" uniqueMembers="false" nameColumn="day_name" captionColumn="day_text" levelType="TimeDays" type="Integer"/>
        </Hierarchy>   </Dimension>
    
      <Cube name="cb-so-service-order" caption="service orders" cache="true" enabled="true">
        <Table name="av_service_orders" schema="public" />
    
        <DimensionUsage usagePrefix="resolve-" name="time-traditional" source="time-traditional" foreignKey="resolve_day_key" caption="resolve time, traditional calendar"/>
        <DimensionUsage usagePrefix="creation-" name="time-traditional" source="time-traditional" foreignKey="creation_day_key" caption="creation time, traditional calendar"/>
    Does anyone have suggestions as to where I would look next? Perhaps I am headed entirely the wrong direction.

    Thanks in advance for your help.

    Kind regards,
    Justis Peters

  2. #2
    Join Date
    Jan 2007
    Posts
    584

    Default

    Welcome to the forum Justis!

    You've come across a limitation of Mondrian. Fortunately, our next release will include the ability to use a shared dimension multiple times in the same cube. We hope to release the new version sometime in January, but if you want to try out the functionality now, you can get Mondrian's source code from our Perforce repository:

    http://mondrian.pentaho.org/document...pers_guide.php

    In the mean time, you could define the dimensions individually in your cube using aliases for each dimension_time table.

    Hope that helps!

    Will

  3. #3
    Join Date
    Feb 2008
    Posts
    11

    Default

    Quote Originally Posted by wgorman View Post
    Welcome to the forum Justis!

    You've come across a limitation of Mondrian. Fortunately, our next release will include the ability to use a shared dimension multiple times in the same cube. We hope to release the new version sometime in January, but if you want to try out the functionality now, you can get Mondrian's source code from our Perforce repository:

    http://mondrian.pentaho.org/document...pers_guide.php

    In the mean time, you could define the dimensions individually in your cube using aliases for each dimension_time table.

    Hope that helps!

    Will
    Hi Will.
    I've just installed mondrian 3.0 and I'm testing the shared dimension multiple times in the same cube.

    I have defined this dimension:

    <Dimension name="LoadingDate" type="TimeDimension">
    <Hierarchy hasAll="true" primaryKey="IDTIME">
    <Table name="TIME" schema="DWHDEMO" alias="subTime1"/>
    <Level name="Year" column="YEAR" type="Numeric" uniqueMembers="true" levelType="TimeYears"/>
    <Level name="Month" column="MONTH" uniqueMembers="false" type="Numeric" levelType="TimeMonths"/>
    <Level name="Day" column="DAYOFMONTH" uniqueMembers="false" type="Numeric" levelType="TimeDays"/>
    </Hierarchy>
    </Dimension>


    and then I use it in this way:


    <DimensionUsage caption="LoadingDateA" name="LoadingDate1" source="LoadingDate" foreignKey="ACCTROPERATIONDATE"/>
    <DimensionUsage caption="LoadingDateB" name="LoadingDate2" source="LoadingDate" foreignKey="ACCTRVALUEDATE"/>
    <DimensionUsage caption="LoadingDateC" name="LoadingDate3" source="LoadingDate" foreignKey="ACCTRBOOKINGDATE"/>


    It works fine because I can see this triple dimension.
    But even if I used caption="LoadingDateA", caption="LoadingDateB", caption="LoadingDateC", the name shown is the "source" name (source="LoadingDate").

    Am I doing anything wrong? Where?
    Or is it a BUG of mondrian or Jpivot?

    Thanks in advance

  4. #4
    Join Date
    Jan 2007
    Posts
    584

    Default

    Axiome,

    I just took a look at the source code, there is currently no implementation of that caption attribute in DimensionUsage. Please create a sourceforge bug here:

    http://www.sourceforge.net/projects/mondrian

    I will attach a test case to the bug once you've created it.

    Thanks,

    Will

  5. #5
    Join Date
    Feb 2008
    Posts
    11

    Default

    Quote Originally Posted by wgorman View Post
    Axiome,

    I just took a look at the source code, there is currently no implementation of that caption attribute in DimensionUsage. Please create a sourceforge bug here:

    http://www.sourceforge.net/projects/mondrian

    I will attach a test case to the bug once you've created it.

    Thanks,

    Will
    OK created.
    Thanks

  6. #6
    Join Date
    Feb 2008
    Posts
    11

    Default

    Quote Originally Posted by Axiome View Post
    Hi Will.
    I've just installed mondrian 3.0 and I'm testing the shared dimension multiple times in the same cube.

    I have defined this dimension:

    <Dimension name="LoadingDate" type="TimeDimension">
    <Hierarchy hasAll="true" primaryKey="IDTIME">
    <Table name="TIME" schema="DWHDEMO" alias="subTime1"/>
    <Level name="Year" column="YEAR" type="Numeric" uniqueMembers="true" levelType="TimeYears"/>
    <Level name="Month" column="MONTH" uniqueMembers="false" type="Numeric" levelType="TimeMonths"/>
    <Level name="Day" column="DAYOFMONTH" uniqueMembers="false" type="Numeric" levelType="TimeDays"/>
    </Hierarchy>
    </Dimension>


    and then I use it in this way:


    <DimensionUsage caption="LoadingDateA" name="LoadingDate1" source="LoadingDate" foreignKey="ACCTROPERATIONDATE"/>
    <DimensionUsage caption="LoadingDateB" name="LoadingDate2" source="LoadingDate" foreignKey="ACCTRVALUEDATE"/>
    <DimensionUsage caption="LoadingDateC" name="LoadingDate3" source="LoadingDate" foreignKey="ACCTRBOOKINGDATE"/>


    It works fine because I can see this triple dimension.
    But even if I used caption="LoadingDateA", caption="LoadingDateB", caption="LoadingDateC", the name shown is the "source" name (source="LoadingDate").

    Am I doing anything wrong? Where?
    Or is it a BUG of mondrian or Jpivot?

    Thanks in advance
    I'm testing Mondrian 3.0.2 and reading the logs I can see that the caption of the dimensionUsage is being set up correctly, but JPIVOT still uses the dimension name as caption.
    Debugging the source I found out that the method getCaption() of the class mondrian.rolap.RolapCubeHierarchy returns the hierarchy caption. Ex:

    /**
    * Returns the display name of this catalog element.
    * If no caption is defined, the name is returned.
    */
    public String getCaption() {
    return rolapHierarchy.getCaption();
    }

    I think that If I want to use the caption of the dimensionUsage the call should be super.getCaption().
    According to me the source code should be the following:

    String tmp=super.getCaption();
    if (tmp != null && !tmp.equals(""))
    return tmp;
    else
    return rolapHierarchy.getCaption();

    Please let me know if it's correct or where the mistake is.
    Thanks in advance for your answers.

  7. #7
    Join Date
    Feb 2008
    Posts
    11

    Default

    JHyde can u please help me?

  8. #8
    Join Date
    Jan 2007
    Posts
    584

    Default

    Axiome,

    When Julian fixed this, he updated the RolapCubeDimension.getCaption(). JPivot uses RolapCubeHierarchy.getCaption(). We'll need to figure out what the best approach is for getting the caption updated in the Hierarchy as well as the dimension.

    Will

  9. #9
    Join Date
    Aug 2008
    Posts
    11

    Default

    Any solution to this issue?
    What is the Jira opened to this problem?

  10. #10
    Join Date
    Sep 2008
    Posts
    25

    Default

    Hi,

    I needed the feature to get the DimensionUsage name displayed, so I refactored the following methods of mondrian.rolap.RolapHierarchy:

    Code:
    RolapHierarchy(
            RolapDimension dimension,
            MondrianDef.Hierarchy xmlHierarchy,
            MondrianDef.CubeDimension xmlCubeDimension)
        {
            this(dimension, xmlHierarchy.name, xmlHierarchy.hasAll);
    
           (...)
    
            if (xmlCubeDimension instanceof MondrianDef.DimensionUsage) {
                String sharedDimensionName =
                    ((MondrianDef.DimensionUsage) xmlCubeDimension).name;
                String sharedDimensionCaption =
                    ((MondrianDef.DimensionUsage) xmlCubeDimension).caption;
                this.sharedHierarchyName = sharedDimensionName;
                if (subName != null) {
                    this.sharedHierarchyName += "." + subName; // e.g. "Time.Weekly"
                }
                
                if (sharedDimensionCaption != null){
                    this.sharedHierarchyCaption = sharedDimensionCaption;
                    if (subName != null) {
                        this.sharedHierarchyCaption += "." + subName; // e.g. "Time.Weekly"
                    }
            	
                }
            } else {
                this.sharedHierarchyName = null;
                this.sharedHierarchyCaption = null;
            }
    
    (...)
        }
    Code:
        
        @Override
        public String getCaption(){
    	if (this.sharedHierarchyCaption != null){
    	    return this.sharedHierarchyCaption;
    	}
    	if (sharedHierarchyName != null){
    	    return this.sharedHierarchyName;
    	}
    	else return super.getCaption();
        }
    this seems to work for me

    regards
    Philipp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •