CDA-分角色用户查询
生活随笔
收集整理的這篇文章主要介紹了
CDA-分角色用户查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
參數
pentaho獲取當前角色:${[security:principalRoles]}
pentaho獲取當前用戶:${[security:principalName]}
CDA示例-按角色查詢(sql jndi)
詳見和標簽,控制只有administrator角色的用戶可以查詢到數據
<?xml version="1.0" encoding="utf-8"?> <CDADescriptor><!-- DataSource definition. Type controls what the datasource type is.The connection and query controls how the data is fetched. These valuesare specific to each access type--><DataSources><Connection id="1" type="sql.jndi"><Jndi>SampleData</Jndi></Connection></DataSources><!-- DataAccess object controls the query itselfAccess controls if the datasource can be seen from the outside or is tobe used from a Compound datasource only--><DataAccess id="1" connection="1" type="sql" access="public" cache="true" cacheDuration="3600"><Name>Sql Query on SampleData - Jndi</Name><Query><![CDATA[select o.YEAR_ID, o.STATUS, sum(o.TOTALPRICE) as price from orderfact owhere ${PRM_USER} like '%dministrator%'group by o.YEAR_ID, o.STATUS]]></Query><!-- All parameters are passed as string from the outside. Theirtype is defined here. If needed, a conversion pattern must be specifiedSupported types: String, Date, Integer, Numeric--><Parameters><Parameter default="${[security:principalRoles]}" name="PRM_USER" type="String"/></Parameters><!-- Columns block allow specifying name and CalculatedColumn the creation of newcolumns based on formulas--><Columns><Column idx="0"><Name>Year</Name></Column><CalculatedColumn><Name>PriceInK</Name><Formula>=[PRICE]/1000000</Formula></CalculatedColumn></Columns><!-- Settings block here overrides defaults and general settings --><Settings><Export type="csv" includeTotals="true"><Column idx="0" aggregator="None"/><Column idx="1" aggregator="Average"/></Export></Settings><!-- Output controls what is outputed and by what order. Defaults to everything --><Output indexes="1,0,2,3"/><Output id="2" indexes="0,1,3"/><Output id="3" indexes="1,0,2"/></DataAccess> </CDADescriptor>##API調用示例:
1.admin查詢:
curl 'http://10.34.11.124:8080/pentaho/plugin/cda/api/doQuery?path=/home/suzy/QueryOverRoles.cda&dataAccessId=1¶mPRM_USER=%24%7B%5Bsecurity%3AprincipalRoles%5D%7D' -H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ='結果:
{"metadata":[{"colName":"STATUS","colType":"String","colIndex":0},{"colName":"Year","colType":"Numeric","colIndex":1},{"colName":"PRICE","colType":"Numeric","colIndex":2},{"colName":"PriceInK","colType":"Numeric","colIndex":3}], "resultset":[["Shipped",2003,3573701.2500000014,3.5737012500000014],["Resolved",2003,28550.59,0.02855059],["Cancelled",2003,75132.15999999999,0.07513215999999999],["Shipped",2004,4750205.889999998,4.750205889999998],["Cancelled",2004,187195.13000000003,0.18719513000000003],["Resolved",2004,24078.610000000004,0.024078610000000004],["On Hold",2004,26260.210000000003,0.026260210000000003],["Shipped",2005,1513074.4600000002,1.5130744600000002],["Resolved",2005,98089.08000000002,0.09808908000000002],["On Hold",2005,152718.97999999995,0.15271897999999995],["Disputed",2005,72212.86,0.07221286],["In Process",2005,144729.96000000002,0.14472996000000002]], "queryInfo":{"totalRows":"12"}}2.suzy查詢:
curl 'http://10.34.11.124:8080/pentaho/plugin/cda/api/doQuery?path=/home/suzy/QueryOverRoles.cda&dataAccessId=1¶mPRM_USER=%24%7B%5Bsecurity%3AprincipalRoles%5D%7D' -H 'Authorization: Basic c3V6eTpwYXNzd29yZA=='結果:
{"metadata":[{"colName":"STATUS","colType":"String","colIndex":0},{"colName":"Year","colType":"Numeric","colIndex":1},{"colName":"PRICE","colType":"Numeric","colIndex":2},{"colName":"PriceInK","colType":"String","colIndex":3}], "resultset":[], "queryInfo":{"totalRows":"0"}}總結
以上是生活随笔為你收集整理的CDA-分角色用户查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在cmd的命令下 用Mysql中建立一个
- 下一篇: [Egret学习笔记 二]MovieCl