Problem with dynamic roles

  • zerba78

    zerba78 - 2009-03-02


    I use
    - JPivot 1.8.0 + patch found at
    - 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]"

    [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.(

    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


      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">
        {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns,
        {[Product]} on rows
      from Sales
      where ([Time].[1997])

      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 hierarchy="[Gender]" access="none"/>

      I get a
              at com.tonbeller.jpivot.mondrian.MondrianMember.<init>(
              at com.tonbeller.jpivot.mondrian.MondrianModel.addMember(
              at com.tonbeller.jpivot.mondrian.MondrianResult.initData(
              at com.tonbeller.jpivot.mondrian.MondrianResult.<init>(
              at com.tonbeller.jpivot.mondrian.MondrianModel.getResult(
              at com.tonbeller.jpivot.olap.model.OlapModelDecorator.getResult(
              at com.tonbeller.jpivot.olap.model.CachingOlapModel.getResult(
              at com.tonbeller.jpivot.olap.model.OlapModelDecorator.getResult(
              at com.tonbeller.jpivot.table.TableComponent.updateOlapModel(
              at com.tonbeller.jpivot.table.TableComponent.render2(
              at com.tonbeller.jpivot.table.TableComponent.render(
              at com.tonbeller.wcf.component.RendererTag.doEndTag(
      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.


    • 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 hierarchy="[Gender]" access="none"/>
      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?



    • 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?


    • zerba78

      zerba78 - 2009-04-23


      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


      • 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

          I tried with

          <Dimension name="Product">
          <Hierarchy hasAll="false" primaryKey="product_id">
          <View alias="Product">
          <SQL dialect="generic">
                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
                product as p, product_class as pc
                p.product_class_id = pc.product_class_id
                and pc.product_family = '${family}'
          <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"/>

          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?



          • 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.

            • 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.

  • rajeev

    rajeev - 2011-06-28

    how do you create monConnection after tag. pls help


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks