Domain Reference Material

Domain Reference Material

Domain Design in XML Format

The CZS-sales-Domain.xml file defines a Domain that returns data from the sales_fact_2006 table stored in a MySQL database. It includes the three fields that CZS is interested in displaying, as well as the data that corresponds to the attributes described in the security file.

<schema xmlns="http://www.jaspersoft.com/2007/SL/XMLSchema" version="1.0">
  <itemGroups>
    <itemGroup description="Product family and department" descriptionId=""
      id="Products" label="Products" labelId="" resourceId="JoinTree_1">
      <items>
        <item description="Family" descriptionId="" id="Family" label="Family"
          labelId="" resourceId="JoinTree_1.product_class.product_family" />
        <item description="Department" descriptionId="" id="Department"
          label="Department" labelId=""
          resourceId="JoinTree_1.product_class.product_department" />
      </items>
    </itemGroup>
    <itemGroup description="Geography" descriptionId="" id="Geography"
      label="Geography" labelId="" resourceId="JoinTree_1">
      <items>
        <item description="City" descriptionId="" id="City" label="City" labelId=""
          resourceId="JoinTree_1.store.store_city" />
        <item description="Country" descriptionId="" id="Country" label="Country"
          labelId="" resourceId="JoinTree_1.store.store_country" />
        <item description="State" descriptionId="" id="State" label="State"
          labelId="" resourceId="JoinTree_1.store.store_state" />
      </items>
    </itemGroup>
    <itemGroup description="Sales Data" descriptionId="" id="SalesData" label="Sales
      Data" labelId="" resourceId="JoinTree_1">
      <items>
        <item description="Store Cost" descriptionId="" id="StoreCost" label="Store
          Cost" labelId="" resourceId="JoinTree_1.sales_fact_2006.store_cost" />
        <item description="Store Sales" descriptionId="" id="StoreSales" label="Store
          Sales" labelId="" resourceId="JoinTree_1.sales_fact_2006.store_sales" />
        <item description="Unit Sales" descriptionId="" id="UnitSales" label="Unit
          Sales" labelId="" resourceId="JoinTree_1.sales_fact_2006.unit_sales" />
      </items>
    </itemGroup>
  </itemGroups>
<resources>
  <jdbcTable datasourceId="czsdata" id="product" tableName="product">
    <fieldList>
      <field id="brand_name" type="java.lang.String" />
      <field id="gross_weight" type="java.lang.Double" />
      <field id="net_weight" type="java.lang.Double" />
      <field id="product_class_id" type="java.lang.Integer" />
      <field id="product_id" type="java.lang.Integer" />
      <field id="product_name" type="java.lang.String" />
      <field id="recyclable_package" type="java.lang.Boolean" />
      <field id="shelf_depth" type="java.lang.Double" />
      <field id="shelf_height" type="java.lang.Double" />
      <field id="shelf_width" type="java.lang.Double" />
      <field id="SKU" type="java.lang.Long" />
      <field id="SRP" type="java.math.BigDecimal" />
      <field id="units_per_case" type="java.lang.Short" />
    </fieldList>
  </jdbcTable>
  <jdbcTable datasourceId="czsdata" id="product_class" tableName="product_class">
    <fieldList>
      <field id="product_category" type="java.lang.String" />
      <field id="product_class_id" type="java.lang.Integer" />
      <field id="product_department" type="java.lang.String" />
      <field id="product_family" type="java.lang.String" />
      <field id="product_subcategory" type="java.lang.String" />
    </fieldList>
  </jdbcTable>
  <jdbcTable datasourceId="czsdata" id="product" tableName="product">
    <fieldList>
      <field id="brand_name" type="java.lang.String" />
      <field id="gross_weight" type="java.lang.Double" />
      <field id="net_weight" type="java.lang.Double" />
      <field id="product_class_id" type="java.lang.Integer" />
      <field id="product_id" type="java.lang.Integer" />
      <field id="product_name" type="java.lang.String" />
      <field id="recyclable_package" type="java.lang.Boolean" />
      <field id="shelf_depth" type="java.lang.Double" />
      <field id="shelf_height" type="java.lang.Double" />
      <field id="shelf_width" type="java.lang.Double" />
      <field id="SKU" type="java.lang.Long" />
      <field id="SRP" type="java.math.BigDecimal" />
      <field id="units_per_case" type="java.lang.Short" />
    </fieldList>
  </jdbcTable>
  <jdbcTable datasourceId="czsdata" id="sales_fact_2006" 
    tableName="sales_fact_2006">
    <fieldList>
      <field id="customer_id" type="java.lang.Integer" />
      <field id="product_id" type="java.lang.Integer" />
      <field id="promotion_id" type="java.lang.Integer" />
      <field id="store_cost" type="java.math.BigDecimal" />
      <field id="store_id" type="java.lang.Integer" />
      <field id="store_sales" type="java.math.BigDecimal" />
      <field id="time_id" type="java.lang.Integer" />
      <field id="unit_sales" type="java.math.BigDecimal" />
    </fieldList>
  </jdbcTable>
  <jdbcTable datasourceId="czsdata" id="store" tableName="store">
    <fieldList>
      <field id="coffee_bar" type="java.lang.Boolean" />
      <field id="first_opened_date" type="java.sql.Timestamp" />
      <field id="last_remodel_date" type="java.sql.Timestamp" />
      <field id="region_id" type="java.lang.Integer" />
      <field id="store_city" type="java.lang.String" />
      <field id="store_country" type="java.lang.String" />
      <field id="store_fax" type="java.lang.String" />
      <field id="store_id" type="java.lang.Integer" />
      <field id="store_manager" type="java.lang.String" />
      <field id="store_name" type="java.lang.String" />
      <field id="store_number" type="java.lang.Integer" />
      <field id="store_phone" type="java.lang.String" />
      <field id="store_postal_code" type="java.lang.String" />
      <field id="store_sqft" type="java.lang.Integer" />
      <field id="store_state" type="java.lang.String" />
      <field id="store_street_address" type="java.lang.String" />
      <field id="store_type" type="java.lang.String" />
      <field id="video_store" type="java.lang.Boolean" />
    </fieldList>
  </jdbcTable>
  <jdbcTable datasourceId="czsdata" id="JoinTree_1" tableName="product">
    <fieldList>
      <field id="product_class.product_category" type="java.lang.String" />
      <field id="product_class.product_class_id" type="java.lang.Integer" />
      <field id="product_class.product_department" type="java.lang.String" />
      <field id="product_class.product_family" type="java.lang.String" />
      <field id="product_class.product_subcategory" type="java.lang.String" />
      <field id="sales_fact_2006.customer_id" type="java.lang.Integer" />
      <field id="sales_fact_2006.product_id" type="java.lang.Integer" />
      <field id="sales_fact_2006.promotion_id" type="java.lang.Integer" />
      <field id="sales_fact_2006.store_cost" type="java.math.BigDecimal" />
      <field id="sales_fact_2006.promotion_id" type="java.lang.Integer" />
      <field id="sales_fact_2006.store_cost" type="java.math.BigDecimal" />
      <field id="sales_fact_2006.store_id" type="java.lang.Integer" />
      <field id="sales_fact_2006.store_sales" type="java.math.BigDecimal" />
      <field id="sales_fact_2006.time_id" type="java.lang.Integer" />
      <field id="sales_fact_2006.unit_sales" type="java.math.BigDecimal" />
      <field id="product.brand_name" type="java.lang.String" />
      <field id="product.gross_weight" type="java.lang.Double" />
      <field id="product.net_weight" type="java.lang.Double" />
      <field id="product.product_class_id" type="java.lang.Integer" />
      <field id="product.product_id" type="java.lang.Integer" />
      <field id="product.product_name" type="java.lang.String" />
      <field id="product.recyclable_package" type="java.lang.Boolean" />
      <field id="product.shelf_depth" type="java.lang.Double" />
      <field id="product.shelf_height" type="java.lang.Double" />
      <field id="product.shelf_width" type="java.lang.Double" />
      <field id="product.SKU" type="java.lang.Long" />
      <field id="product.SRP" type="java.math.BigDecimal" />
      <field id="product.units_per_case" type="java.lang.Short" />
      <field id="store.coffee_bar" type="java.lang.Boolean" />
      <field id="store.first_opened_date" type="java.sql.Timestamp" />
      <field id="store.grocery_sqft" type="java.lang.Integer" />
      <field id="store.last_remodel_date" type="java.sql.Timestamp" />
      <field id="store.meat_sqft" type="java.lang.Integer" />
      <field id="store.region_id" type="java.lang.Integer" />
      <field id="store.store_city" type="java.lang.String" />
      <field id="store.store_country" type="java.lang.String" />
      <field id="store.store_fax" type="java.lang.String" />
      <field id="store.store_id" type="java.lang.Integer" />
      <field id="store.store_manager" type="java.lang.String" />
      <field id="store.store_name" type="java.lang.String" />
      <field id="store.store_number" type="java.lang.Integer" />
      <field id="store.store_phone" type="java.lang.String" />
      <field id="store.store_postal_code" type="java.lang.String" />
      <field id="store.store_sqft" type="java.lang.Integer" />
      <field id="store.store_state" type="java.lang.String" />
      <field id="store.store_street_address" type="java.lang.String" />
      <field id="store.store_type" type="java.lang.String" />
      <field id="store.video_store" type="java.lang.Boolean" />
    </fieldList>
    <joinInfo alias="product" referenceId="product" />
      <joinedDataSetList>
        <joinedDataSetRef>
          <joinString>join product_class product_class on (product.product_class_id
            == product_class.product_class_id) />
        </joinedDataSetRef>
        <joinedDataSetRef>
          <joinString>join sales_fact_2006 sales_fact_2006 on (product.product_id ==
            sales_fact_2006.product_id) />
        </joinedDataSetRef>
        <joinedDataSetRef>
          <joinString>join store store on (sales_fact_2006.store_id ==
            store.store_id) />
        </joinedDataSetRef>
      </joinedDataSetList>
    </jdbcTable>
  </resources>
</schema>

Domain Security File

The CZS-sales-security.xml file is based on the CZS-sales-domain.xml Domain design file, and defines access for users with Cities and ProductDepartment attributes.

<securityDefinition xmlns="http://www.jaspersoft.com/2007/SL/XMLSchema" version="1.0" itemGroupDefaultAccess="granted">
<resourceAccessGrants>
   <!-- Row level security -->  
  <!-- What access do roles/users have to the rows in the resource? -->
  <resourceAccessGrantList id="JoinTree_1_List" label="ListLabel"
    resourceId="JoinTree_1">
    <resourceAccessGrants>    
      <!-- Row level for Cities -->
      <resourceAccessGrant id="Jointree_1_row_access_grant_20">
        <principalExpression>attributesService.getAttribute('Cities', null, true) != null 
          </principalExpression>
        <filterExpression>testProfileAttribute(store.store_city,'Cities')
        </filterExpression>
      </resourceAccessGrant> 
        <!-- Row level for Product Dept -->
      <resourceAccessGrant id="Jointree_1_row_access_grant_30"> 
        <principalExpression>
          attributesService.getAttribute('ProductDepartment', null, true) != null
        </principalExpression>
        <filterExpression>testProfileAttribute(product_class.product_department,
          'ProductDepartment')</filterExpression>
      </resourceAccessGrant> 
    </resourceAccessGrants>    
  </resourceAccessGrantList>
  <!-- Column level security -->
  <!-- What access do roles/users have to the fields in an item group? -->
  <itemGroupAccessGrants>
    <itemGroupAccessGrantList id="restrict_Jointree_1_item_group_Sales" label="aLabel"
      itemGroupId="SalesData" defaultAccess="denied">
      <itemGroupAccessGrants>
        <!-- Column level for managers and admin -->
        <itemGroupAccessGrant id="Jointree1_item_group_access_grant_1" access="granted">
          <principalExpression>authentication.getPrincipal().getRoles().any
            { it.getRoleName() in ['ROLE_ADMINISTRATOR','ROLE_SALES_MANAGER'] }
            </principalExpression>
        </itemGroupAccessGrant>
        <!-- Column level for sales reps -->
        <itemGroupAccessGrant id="Jointree_1_item_group_access_grant_2" 
          access="granted">
            <principalExpression>authentication.getPrincipal().getRoles().any
              { it.getRoleName() in ['ROLE_SALES_REP'] }</principalExpression>
          <itemAccessGrantList id="Jointree_1_grant2_item_group_items"
            defaultAccess="denied">
            <itemAccessGrants>
              <itemAccessGrant id="Jointree_1_grant2_items_grant1" itemId="StoreSales" 
                access="granted" />
              <itemAccessGrant id="Jointree_1_grant2_items_grant2" itemId="UnitSales" 
                access="granted" />
            </itemAccessGrants>
          </itemAccessGrantList>
        </itemGroupAccessGrant>
      </itemGroupAccessGrants>
    </itemGroupAccessGrantList>
   </itemGroupAccessGrants>
</securityDefinition>

Feedback