mondrain 直接用SQL做源写到XML,开发效率极其提高 博客分类: BI mondraidbi多维建模
程序员文章站
2024-03-13 23:56:58
...
1、数据源配置:datasources.xml
<DataSource>
<DataSourceName>Provider=Mondrian;DataSource=**;</DataSourceName>
<DataSourceDescription>**</DataSourceDescription>
<URL>http://localhost:8080/mondrian/xmla</URL>
<DataSourceInfo>Provider=mondrian;Jdbc=jdbc:db2://10.1.*.*:50000/**;JdbcUser=db2admin;JdbcPassword=db2admin;JdbcDrivers=com.ibm.db2.jcc.DB2Driver;Catalog=/WEB-INF/queries/**1.xml</DataSourceInfo>
<ProviderName>Mondrian</ProviderName>
<ProviderType>MDP</ProviderType>
<AuthenticationMode>Unauthenticated</AuthenticationMode>
<Catalogs>
<Catalog name="FoodMartCN1">
<Definition>/WEB-INF/queries/ReserveCashDB2.xml</Definition>
</Catalog>
<Catalog name="PrePayCard">
<Definition>/WEB-INF/queries/**2.xml</Definition>
</Catalog>
</Catalogs>
</DataSource>
2、例如:**2.xml
<?xml version="1.0" encoding="GBK"?>
<Schema name="库名">
<Dimension name="机构" >
<Hierarchy hasAll="true" primaryKey="IBANKID">
<Table name="PACA_DIM_BANK"/>
<Level name="机构" column="SBANKNAME" uniqueMembers="true">
</Level>
</Hierarchy>
</Dimension>
<Dimension name="时间" type="TimeDimension">
<Hierarchy hasAll="false" primaryKey="DAY_SHORT_DESC">
<Table name="PACA_DIM_TIME"/>
<Level name="年" column="YEAR_LONG_DESC" uniqueMembers="true" levelType="TimeYears"/>
<Level name="季" column="QUARTER_LONG_DESC" uniqueMembers="false" levelType="TimeQuarters"/>
<Level name="月" column="MONTH_LONG_DESC" uniqueMembers="false" levelType="TimeMonths"/>
</Hierarchy>
</Dimension>
<Cube name="**-按地区" defaultMeasure="IVALUE">
<View alias="211AREA">
<SQL dialect="generic"> <![CDATA[
select * from a where a.id='1'
]]>
</SQL>
</View>
<DimensionUsage name="时间" source="时间" foreignKey="DDATE"/>
<DimensionUsage name="机构" source="机构" foreignKey="SBANKCODE"/>
<!--add 地区 dim -->
<Measure name="IVALUE" caption="金额" column="IVALUE" datatype="Numeric" aggregator="sum" formatString="#,###.00"/>
</Cube>
<Cube name="**-按对象" defaultMeasure="IVALUE">
<View alias="211PRS">
<SQL dialect="generic"> <![CDATA[
select * from a where a.id='2' ]]>
</SQL>
</View>
<DimensionUsage name="时间" source="时间" foreignKey="DDATE"/>
<DimensionUsage name="机构" source="机构" foreignKey="SBANKCODE"/>
<!--add 对象 dim-->
<Measure name="IVALUE" caption="金额" column="IVALUE" datatype="Numeric" aggregator="sum" formatString="#,###.00"/>
</Cube>
</Schema>
<DataSource>
<DataSourceName>Provider=Mondrian;DataSource=**;</DataSourceName>
<DataSourceDescription>**</DataSourceDescription>
<URL>http://localhost:8080/mondrian/xmla</URL>
<DataSourceInfo>Provider=mondrian;Jdbc=jdbc:db2://10.1.*.*:50000/**;JdbcUser=db2admin;JdbcPassword=db2admin;JdbcDrivers=com.ibm.db2.jcc.DB2Driver;Catalog=/WEB-INF/queries/**1.xml</DataSourceInfo>
<ProviderName>Mondrian</ProviderName>
<ProviderType>MDP</ProviderType>
<AuthenticationMode>Unauthenticated</AuthenticationMode>
<Catalogs>
<Catalog name="FoodMartCN1">
<Definition>/WEB-INF/queries/ReserveCashDB2.xml</Definition>
</Catalog>
<Catalog name="PrePayCard">
<Definition>/WEB-INF/queries/**2.xml</Definition>
</Catalog>
</Catalogs>
</DataSource>
2、例如:**2.xml
<?xml version="1.0" encoding="GBK"?>
<Schema name="库名">
<Dimension name="机构" >
<Hierarchy hasAll="true" primaryKey="IBANKID">
<Table name="PACA_DIM_BANK"/>
<Level name="机构" column="SBANKNAME" uniqueMembers="true">
</Level>
</Hierarchy>
</Dimension>
<Dimension name="时间" type="TimeDimension">
<Hierarchy hasAll="false" primaryKey="DAY_SHORT_DESC">
<Table name="PACA_DIM_TIME"/>
<Level name="年" column="YEAR_LONG_DESC" uniqueMembers="true" levelType="TimeYears"/>
<Level name="季" column="QUARTER_LONG_DESC" uniqueMembers="false" levelType="TimeQuarters"/>
<Level name="月" column="MONTH_LONG_DESC" uniqueMembers="false" levelType="TimeMonths"/>
</Hierarchy>
</Dimension>
<Cube name="**-按地区" defaultMeasure="IVALUE">
<View alias="211AREA">
<SQL dialect="generic"> <![CDATA[
select * from a where a.id='1'
]]>
</SQL>
</View>
<DimensionUsage name="时间" source="时间" foreignKey="DDATE"/>
<DimensionUsage name="机构" source="机构" foreignKey="SBANKCODE"/>
<!--add 地区 dim -->
<Measure name="IVALUE" caption="金额" column="IVALUE" datatype="Numeric" aggregator="sum" formatString="#,###.00"/>
</Cube>
<Cube name="**-按对象" defaultMeasure="IVALUE">
<View alias="211PRS">
<SQL dialect="generic"> <![CDATA[
select * from a where a.id='2' ]]>
</SQL>
</View>
<DimensionUsage name="时间" source="时间" foreignKey="DDATE"/>
<DimensionUsage name="机构" source="机构" foreignKey="SBANKCODE"/>
<!--add 对象 dim-->
<Measure name="IVALUE" caption="金额" column="IVALUE" datatype="Numeric" aggregator="sum" formatString="#,###.00"/>
</Cube>
</Schema>