Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Problem with dynamic roles

Help
zerba78
2009-03-02
2013-04-29
  • zerba78
    zerba78
    2009-03-02

    Hi!

    I use
    - JPivot 1.8.0 + patch found at https://sourceforge.net/tracker/index.php?func=detail&aid=1940610&group_id=58645&atid=488474
    - Mondrian 3.0.4

    I have a problem with mondrian dynamic roles.
    I cannot use roles statically defined in the xml schema definition file, I must use dynamic roles.
    After using the mondrianQuery JPivot tag in my jsp, I make something like this:

    RoleImpl connRole = (RoleImpl) monConnection.getRole();
    ...
    connRole.grant(aDimension, Access.NONE);
    connRole.grant(aHierarchy, Access.CUSTOM, topLev, bottomLev, rollupPolicy);
    connRole.grant(aMember, Access.NONE);

    I want to define a custom access to "Product" dimension:
    topLevel="[Product].[Product Family]"
    bottomLevel="[Product].[Product Department]"
    rollupPolicy="PARTIAL"

    [Product].[All Products].[Food] access="all"
    [Product].[All Products].[Drink] access="none"

    Firts time I enter the cube it works properly, but when I remove and re-insert the Product dimension, I see the All Products member (which should be avoided by topLevel) and the rollup policy is not considered. In some cases I get java.lang.NullPointerException at com.tonbeller.jpivot.mondrian.MondrianMember.(MondrianMember.java:47).

    Am I making something wrong?
    What should be the best way to set a dynamic role in jpivot - mondrian?

    Thanks for any suggestion.

    Davide Zerbetto

     
    • zerba78
      zerba78
      2009-03-03

      Hi!

      I have reproduced the error using mondrian original war file.

      The query is:

      <jp:mondrianQuery id="query01" dataSource="jdbc/foodmart" catalogUri="/WEB-INF/queries/FoodMart.xml" role="Drink manager">
      select
        {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns,
        {[Product]} on rows
      from Sales
      where ([Time].[1997])
      </jp:mondrianQuery>

      The role is defined as:

      <Role name="Drink manager">
        <SchemaGrant access="none">
          <CubeGrant cube="Sales" access="all">
            <HierarchyGrant hierarchy="[Product]" access="custom"
                topLevel="[Product].[Product Family]">
              <MemberGrant member="[Product].[All Products].[Drink]" access="all"/>
              <MemberGrant member="[Product].[All Products].[Food]" access="none"/>
            </HierarchyGrant>
            <HierarchyGrant hierarchy="[Gender]" access="none"/>
          </CubeGrant>
        </SchemaGrant>
      </Role>

      I get a
      java.lang.NullPointerException
              at com.tonbeller.jpivot.mondrian.MondrianMember.<init>(MondrianMember.java:47)
              at com.tonbeller.jpivot.mondrian.MondrianModel.addMember(MondrianModel.java:677)
              at com.tonbeller.jpivot.mondrian.MondrianResult.initData(MondrianResult.java:79)
              at com.tonbeller.jpivot.mondrian.MondrianResult.<init>(MondrianResult.java:49)
              at com.tonbeller.jpivot.mondrian.MondrianModel.getResult(MondrianModel.java:334)
              at com.tonbeller.jpivot.olap.model.OlapModelDecorator.getResult(OlapModelDecorator.java:54)
              at com.tonbeller.jpivot.olap.model.CachingOlapModel.getResult(CachingOlapModel.java:48)
              at com.tonbeller.jpivot.olap.model.OlapModelDecorator.getResult(OlapModelDecorator.java:54)
              at com.tonbeller.jpivot.table.TableComponent.updateOlapModel(TableComponent.java:246)
              at com.tonbeller.jpivot.table.TableComponent.render2(TableComponent.java:251)
              at com.tonbeller.jpivot.table.TableComponent.render(TableComponent.java:235)
              at com.tonbeller.wcf.component.RendererTag.doEndTag(RendererTag.java:137)
              ....
      when I remove the dimension "Product" from the MDX query and then I re-put it on the MDX query.
      I suppose it is trying to render the [Product].[All Products] member (that is not accessible by the role) and it fails.

      Any ideas?

      Thanks and best regards.

      Davide

       
    • zerba78
      zerba78
      2009-03-03

      Using this role:
      <Role name="Drink manager">
        <SchemaGrant access="none">
          <CubeGrant cube="Sales" access="all">
            <HierarchyGrant hierarchy="[Product]" access="custom"
                rollupPolicy="partial" bottomLevel="[Product].[Product Department]">
              <MemberGrant member="[Product].[All Products].[Drink]" access="all"/>
              <MemberGrant member="[Product].[All Products].[Food]" access="none"/>
            </HierarchyGrant>
            <HierarchyGrant hierarchy="[Gender]" access="none"/>
          </CubeGrant>
        </SchemaGrant>
      </Role>
      the PARTIAL rollup policy is corretly applied when I enter the cube, but if I remove the "Product" dimension and then re-use it in the MDX query, the rollup policy does not work anymore (it turns to ALL).

      Any ideas? is there a patch for this problem somewhere?

      Regards

      Davide

       
    • Andreas Voss
      Andreas Voss
      2009-04-01

      Sorry, we do not use the Mondrian roles, so I dont know what happens here. I think after the connection is established, the schema including the roles is parsed and everything is initialized. Probably it can not be changed afterwards.

      What we do is we create a dynamic schema using the DynamicSchemaProcessor, i.e. we process and modify the Mondrian schema xml before it is passed over to Mondrian. This works very well. Maybe you could create/change the roles this way?

      Regards,
      Andreas

       
    • zerba78
      zerba78
      2009-04-23

      Hi!

      could someone please post a simple example of DynamicSchemaProcessor for dimensions filtering?
      I suppose it is a very low level xml parsing job: are there some utilities from JPivot/Mondrian to make it easier?

      Best regards

      Davide

       
      • Andreas Voss
        Andreas Voss
        2009-04-24

        Look at the Mondrian source code, there are some Examples, e.g. the LocalizingDynamicSchemaProcessor

         
        • zerba78
          zerba78
          2009-07-22

          Hi!
          I tried with

          <Dimension name="Product">
          <Hierarchy hasAll="false" primaryKey="product_id">
          <View alias="Product">
          <SQL dialect="generic">
          select
                p.product_id as product_id,
                p.product_name as product_name,
                p.brand_name as brand_name,
                pc.product_subcategory as product_subcategory,
                pc.product_category as product_category,
                pc.product_department as product_department,
                pc.product_family as product_family
          from
                product as p, product_class as pc
          where
                p.product_class_id = pc.product_class_id
                and pc.product_family = '${family}'
          </SQL>
          </View>
          <Level name="Product Department" column="product_department" uniqueMembers="false"/>
          <Level name="Product Category" column="product_category" uniqueMembers="false"/>
          <Level name="Product Subcategory" column="product_subcategory" uniqueMembers="false"/>
          <Level name="Brand Name" column="brand_name" uniqueMembers="false"/>
          <Level name="Product Name" column="product_name" uniqueMembers="true"/>
          </Hierarchy>
          </Dimension>

          and I wrote a dynamic schema processor that substitutes ${family} parameter according to user attributes.
          The schema processor is invoked every time any user executes the MDX query, but all users see the members of the first user who executed the query (probably this is caused by Mondrian members cache???) so my roles are not working.
          Any ideas?

          regards

          Davide

           
          • Ati Rosselet
            Ati Rosselet
            2009-07-22

            I have had trouble with Mondrian's schema caching mechanism - specifically if the filename/url matched, then it assumed that it already had the file.  If I remember correctly, I used a servlet to return the schema, but appended the sessionid to the url - which allowed mondrian to recognize each user's as distinct.   Not sure if this applies in your case, but may be worth a try.
            Cheers.

             
            • zerba78
              zerba78
              2009-09-07

              Hi Ati Rosselet
              thanks for your reply, you are right.
              More into details, I found the property "UseContentChecksum" to be applied to Mondrian connection string: if it is false (that is the default), the url or the schema is used as key for caching mechanism; if it is true, than the checksum of the schema (the one returned by the dynamic schema processor) is used as key instead.
              Cheers
              Davide

               
  • rajeev
    rajeev
    2011-06-28

    how do you create monConnection after tag. pls help