<?xml version="1.0" encoding="UTF-8"?> <Schema name="Mondrian"> <Cube name="Person"> <Table name="PERSON" /> <Dimension name="部门" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有部门" > <Table name="PERSON" alias="a"/> <Level name="部门" column="DEPARTMENT" uniqueMembers="true" /> <Level name="姓名" column="USERNAME" uniqueMembers="true" /> </Hierarchy> </Dimension> <Dimension name="性别" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有性别"> <Table name="PERSON" alias="b" /> <Level name="性别" column="SEX" uniqueMembers="true" /> </Hierarchy> </Dimension> <Dimension name="专业技术资格类别" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有专业技术资格类别"> <Table name="PERSON" alias="c" /> <Level name="资格类别" column="ZYJSLB" uniqueMembers="true" /> </Hierarchy> </Dimension> <Dimension name="专业技术资格等级" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有专业技术资格等级"> <Table name="PERSON" alias="d" /> <Level name="资格等级" column="ZYJSDJ" uniqueMembers="true" /> </Hierarchy> </Dimension> <Dimension name="职系" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有职系"> <Table name="PERSON" alias="e" /> <Level name="职系" column="ZHIXI" uniqueMembers="true" /> </Hierarchy> </Dimension> <Dimension name="民族" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有民族"> <Table name="PERSON" alias="f" /> <Level name="民族" column="NATIONALITY" uniqueMembers="true" /> </Hierarchy> </Dimension> <Dimension name="学历" foreignKey="USERID" > <Hierarchy hasAll="true" primaryKey="USERID" allMemberName="所有学历"> <Table name="PERSON" alias="g" /> <Level name="学历" column="XUELI" uniqueMembers="true" /> </Hierarchy> </Dimension> <Measure name="人数" column="USERID" aggregator="distinct count" /> </Cube> </Schema>
一、节点结构:
Schema
|- Cube
|-Table
|-Dimension
|-Hierarchy
|-Table
|-Level
|-Measure
|-Role
注意:
1、一个schema文件中只有一个Schema节点
2、通常Measure都作为统计的列,Dimension都作为统计的行
3、Cube可有多个,通过name来区分,上述配置只有一个Cube,名字标识为Person
二、MDX语句查询DEMO
<jp:mondrianQuery
id="query01"
jdbcDriver="com.mysql.jdbc.Driver"
jdbcUrl="jdbc:mysql://localhost:3306/test"
catalogUri="/WEB-INF/queries/personDemo.xml"
jdbcUser="root"
jdbcPassword="root"
connectionPooling="false">
select
NON EMPTY {[Measures].[人数]} on columns, NON EMPTY {(
[部门].[所有部门],
[职系].[所有职系],
[专业技术资格类别].[所有专业技术资格类别],
[专业技术资格等级].[所有专业技术资格等级],
[学历].[所有学历],
[民族].[所有民族],
[性别].[所有性别]
)} ON rows from Person
</jp:mondrianQuery>
注意:
1、<jp:mondrianQuery>的属性配置的是mondrian的链接信息
2、MDX的查询语句是通过name属性值进行查询的
<Cube name="Person"> 对应 from CubeName
<Dimension name="学历"> 对应 [DimensionName].[HierarchyName]
<Measure name="人数"> 对应 [Measures].[MeasuresName]
参考资料:
http://files.cnblogs.com/files/avivaye/Mondrian_Schema%28%E5%A4%9A%E7%BB%B4%E5%88%86%E6%9E%90%29%E5%B1%9E%E6%80%A7%E8%AF%A6%E8%A7%A3.rar