## 整理此文章方便大家做测试(手写Mondrian Schema自测),不必每次都向saiku上传文件了
## 关键文件
* foodmart4.xml 测试对应的schema文件
* foodmart-sql.zip 测试对应的数据库脚本
maven项目:
pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.firewarm</groupId>
<artifactId>testMondrian</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>testMondrian Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>mine</id>
<name>public Releases</name>
<layout>default</layout>
<url>http://nexus.liuyingguang.cn:8081/nexus/content/groups/public/</url>
</repository>
<repository>
<id>mine-meteorite-bi-release</id>
<name>public Releases</name>
<layout>default</layout>
<url>http://nexus.liuyingguang.cn:8081/nexus/content/repositories/meteorite-bi-release/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>mondrian</artifactId>
<version>4.5.0.2-208</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
</dependencies>
<build>
<finalName>testMondrian</finalName>
</build>
</project>
foodmart4.xml文件
<?xml version='1.0'?>
<Schema name='FoodMart' metamodelVersion='4.0'>
<!--
== This software is subject to the terms of the Eclipse Public License v1.0
== Agreement, available at the following URL:
== http://www.eclipse.org/legal/epl-v10.html.
== You must accept the terms of that agreement to use this software.
==
== Copyright (C) 2000-2005 Julian Hyde
== Copyright (C) 2005-2013 Pentaho and others
== All Rights Reserved.
-->
<PhysicalSchema>
<Table name='salary'/>
<Table name='salary' alias='salary2'/>
<Table name='department'>
<Key>
<Column name='department_id'/>
</Key>
</Table>
<Table name='employee'>
<Key>
<Column name='employee_id'/>
</Key>
</Table>
<Table name='employee_closure'>
<Key>
<Column name='employee_id'/>
</Key>
</Table>
<Link source='employee' target='employee_closure'>
<ForeignKey>
<Column name='employee_id'/>
</ForeignKey>
</Link>
<Table name='position'>
<Key>
<Column name='position_id'/>
</Key>
</Table>
<Link source='position' target='employee'>
<ForeignKey>
<Column name='position_id'/>
</ForeignKey>
</Link>
<Table name='promotion'>
<Key>
<Column name='promotion_id'/>
</Key>
</Table>
<Table name='store'>
<Key>
<Column name='store_id'/>
</Key>
</Table>
<Link source='store' target='employee'>
<ForeignKey>
<Column name='store_id'/>
</ForeignKey>
</Link>
<Table name='product' keyColumn='product_id'/>
<Table name='product_class' keyColumn='product_class_id'/>
<Link target='product' source='product_class'>
<ForeignKey>
<Column name='product_class_id'/>
</ForeignKey>
</Link>
<Table name='time_by_day'>
<Key>
<Column name='time_id'/>
</Key>
</Table>
<Table name='customer'>
<Key>
<Column name='customer_id'/>
</Key>
<ColumnDefs>
<CalculatedColumnDef name='full_name' type='String'>
<ExpressionView>
<SQL dialect='oracle'>
<Column name='fname'/> || ' ' || <Column name='lname'/>
</SQL>
<SQL dialect='access'>
<Column name='fname'/> + ' ' + <Column name='lname'/>
</SQL>
<SQL dialect='postgres'>
<Column name='fname'/> || ' ' || <Column name='lname'/>
</SQL>
<SQL dialect='mysql'>
CONCAT(<Column name='fname'/>, ' ', <Column name='lname'/>)
</SQL>
<SQL dialect='mssql'>
<Column name='fname'/> + ' ' + <Column name='lname'/>
</SQL>
<SQL dialect='derby'>
<Column name='fullname'/>
</SQL>
<SQL dialect='db2'>
CONCAT(CONCAT(<Column name='fname'/>, ' '), <Column name='lname'/>)
</SQL>
<SQL dialect='luciddb'>
<Column name='fname'/> || ' ' || <Column name='lname'/>
</SQL>
<SQL dialect='generic'>
<Column name='fullname'/>
</SQL>
</ExpressionView>
</CalculatedColumnDef>
</ColumnDefs>
</Table>
<Table name='sales_fact_1997'>
<ColumnDefs>
<CalculatedColumnDef name='promotion_sales'>
<ExpressionView>
<SQL dialect='access'>
Iif(<Column table='sales_fact_1997' name='promotion_id'/> = 0, 0,
<Column table='sales_fact_1997' name='store_sales'/>)
</SQL>
<SQL dialect='generic'>
case when <Column table='sales_fact_1997' name='promotion_id'/> = 0 then 0
else <Column table='sales_fact_1997' name='store_sales'/> end
</SQL>
</ExpressionView>
</CalculatedColumnDef>
</ColumnDefs>
</Table>
<Table name='inventory_fact_1997'>
<ColumnDefs>
<CalculatedColumnDef name='warehouse_profit'>
<ExpressionView>
<SQL dialect='generic'>
<Column table='inventory_fact_1997' name='warehouse_sales'/>
-
<Column name='warehouse_cost'/>
</SQL>
</ExpressionView>
</CalculatedColumnDef>
</ColumnDefs>
</Table>
<Table name='warehouse'>
<Key>
<Column name='warehouse_id'/>
</Key>
</Table>
<Table name='agg_c_special_sales_fact_1997'/>
<Table name='agg_pl_01_sales_fact_1997'/>
<Table name='agg_l_05_sales_fact_1997'/>
<Table name='agg_g_ms_pcat_sales_fact_1997'/>
<Table name='agg_c_14_sales_fact_1997'/>
</PhysicalSchema>
<Dimension name='Store' table='store' key='Store Id'>
<Attributes>
<Attribute name='Store Country' hasHierarchy='false'>
<Key>
<Column name='store_country'/>
</Key>
</Attribute>
<Attribute name='Store State' keyColumn='store_state' hasHierarchy='false'/>
<Attribute name='Store City' hasHierarchy='false'>
<Key>
<Column name='store_state'/>
<Column name='store_city'/>
</Key>
<Name>
<Column name='store_city'/>
</Name>
</Attribute>
<Attribute name='Store Id' keyColumn='store_id' hasHierarchy='false'/>
<Attribute name='Store Name' keyColumn='store_name' hasHierarchy='false'>
<Property attribute='Store Type'/>
<Property attribute='Store Manager'/>
<Property attribute='Store Sqft'/>
<Property attribute='Grocery Sqft'/>
<Property attribute='Frozen Sqft'/>
<Property attribute='Meat Sqft'/>
<Property attribute='Has coffee bar'/>
<Property attribute='Street address'/>
</Attribute>
<Attribute name='Store Type' keyColumn='store_type' hierarchyAllMemberName='All Store Types'/>
<Attribute name='Store Manager' keyColumn='store_manager' hasHierarchy='false'/>
<Attribute name='Store Sqft' keyColumn='store_sqft' hasHierarchy='false'/>
<Attribute name='Grocery Sqft' keyColumn='grocery_sqft' hasHierarchy='false'/>
<Attribute name='Frozen Sqft' keyColumn='frozen_sqft' hasHierarchy='false'/>
<Attribute name='Meat Sqft' keyColumn='meat_sqft' hasHierarchy='false'/>
<Attribute name='Has coffee bar' keyColumn='coffee_bar' hasHierarchy='false'/>
<Attribute name='Street address'