怎样让新建的Answer必须对某个字段进行过滤?

考虑如下的需求,当用户在使用Answer做即席查询的时候,怎么让他必须对某一个字段加过滤条件呢?
比如时间,如果不加则不让该请求执行,并同时给出一个提示信息。


下面我就以10G官方的SH demo为例,阐述实现步骤:

11G实现方法类似,具体请参见文末链接。

BIEE本身是提供了该功能的,我们需要做的就是使用javascript去实现一个validateAnalysisCriteria方法,并把我们的验证逻辑
添加进去即可!

默认情况下,该方法始终返回true,即通过验证(执行请求)。如果该方法返回false或者一条消息,则不执行该请求,同时在弹出的窗口中显示返回的消息!


1、新建一个QueryBlock.xml文件,将其放到 {OracleBI}\web\msgdb\custom mes sages目录(如果没有该目录请手工创建)下
  1. <?xml version=”1.0″ encoding=”utf-8″?>
  2. <WebMessageTables xmlns:sawm=”com.siebel.analytics.web.messageSystem”>
  3. <WebMessageTable system=”QueryBlocking” table=”Messages”>
  4. <WebMessage name=”kuiCriteriaBlockingScript” translate=”no”>
  5. <HTML>
  6. <script language=”javascript” src=”fmap:myblocking.js”/>
  7. </HTML>
  8. </WebMessage>
  9. </WebMessageTable>
  10. </WebMessageTables>
复制代码
注意:放在customMessages下意味着该文件是与语言无关的,如果想和具体语言相关,请将该文件放到{OracleBI}\web\msgdb\目录对应的语言文件夹下,如中文:l_zh


2、创建myblocking.js 代码如下:
  1. function validateAnalysisCriteria(analysisXml)
  2. {
  3. // Create the helper object
  4. var tValidator = new CriteriaValidator(analysisXml);
  5. // Validation Logic
  6. if (tValidator.getSubjectArea() != "SH") // 只对SH主题域进行验证
  7. return true;
  8. if(!tValidator.tableExists("Calendar"))//只有当引用了Calendar表中的任意字段才进行验证
  9. return true;
  10. //如果引用了Calendar表的任意字段,则必须对Calendar Month Desc字段做过滤
  11. if (!tValidator.filterExists("Calendar","Calendar Month Desc"))
  12. return "Please filter the Calendar Month Desc.";
  13. //获取过滤值的个数
  14. var n = tValidator.filterCount("Calendar","Calendar Month Desc");
  15. //只能指定一个值
  16. if (n!=1)
  17. return "Please select 1 and only one Month";
  18. return true;
  19. }
复制代码
将该脚本拷贝至{OracleBI}/web/app/res/b_mozilla 和{OracleBI}/oc4j_bi/j2ee/home/applications/analytics/analytics/res/b_mozilla
两个目录下( 注,官方文档中关于此目录描述有误 )

重启OBPIS和OC4J。


下面来测试一下吧!


Case 1 ,不选任何时间维上的字段,比如只选Prod Category,同时不设置过滤器
结果:正常执行

Case 2,选时间维上的任意字段,同时不设置过滤器
结果:提示“Please filter the Calendar Month Desc” 
如下图所示:
12.png 

Case 3:在Case 2的基础上,添加Calendar Month Desc过滤器,同时指定两个值
结果:提示“Please select 1 and only one Month ”
如下图所示:
34.png 

Case4:在Case 3的基础上,将过滤值只指定为一个。
结果:执行成功


附相关函数: 18.5.4 Validation Helper Functions
Validation Helper Function
Description
CriteriaValidator.getSubjectArea()
Returns the name of the subject area referenced by the analysis. It generally is used in a switch statement within the function before doing other validation. If the analysis is a set-based criteria, then it returns null.
CriteriaValidator.tableExists(sTable)
Returns True if the specified folder (table) has been added to the analysis by the content designer, and False if the folder was not added.
CriteriaValidator.columnExists(sTable, sColumn)
Returns True if the specified column has been added to the analysis by the content designer, and False if the column was not added.
CriteriaValidator.dependentColumnExists(sCheckTable, sCheckColumn, sDependentTable, sDependentColumn)
Checks to ensure that the dependentColumn exists if the checkColumn is present. It returns True if either the checkColumn is not present, or the checkColumn and the dependent column are present. If checkColumn and dependentColumn are null, then the folders are validated. If any column from checkTable is present, then a column from dependentTable must be present.
CriteriaValidator.filterExists(sFilterTable, sFilterColumn)
Returns True if a filter exists on the specified column, and False if no filter is present.
CriteriaValidator.dependentFilterExists(sCheckTable, sCheckColumn, sFilterTable, sFilterColumn)
Checks to ensure that the dependentFilter exists if the checkColumn is present in the projection list. It returns True if either the checkColumn is not present, or the checkColumn and the dependent filter are present.
CriteriaValidator.filterCount(sFilterTable, sFilterColumn)
Returns the number of filter values that are specified for the given logical column. If the filter value is "equals," "null," "notNull," or "in," then it returns the number of values chosen. If the column is not used in a filter, then it returns zero. If the column is prompted with no default, then it returns -1. For all other filter operators (such as "greater than," "begins with," and so on) it returns 999, because the number of values cannot be determined.






参考资料:
10G: 
Presentation Services Administration Guide   之Blocking Requests in Answers on page 56
11G:
System Administrator's Guide  之  18.5.2 Blocking Analyses Based on Criteria
参考资源链接:[NDIS Filter Drivers深度解析:封包拦截与过滤技术](https://wenku.youkuaiyun.com/doc/836ocdsroy?utm_source=wenku_answer2doc_content) NDIS Filter Drivers是网络驱动程序接口标准(NDIS)的一部分,它允许开发者在Windows操作系统中实现网络数据包的拦截和过滤功能。要实现这一功能,首先需要熟悉NDIS Filter Drivers的工作原理及其与网络栈的交互方式。以下是一些关键步骤和概念的详细说明: 1. **理解NDIS Filter Drivers的角色和功能**:NDIS Filter Drivers位于协议驱动和微型端口驱动之间,能够捕获、修改或过滤流入和流出的网络数据包。开发者可以通过编写中间层驱动程序来实现特定的网络策略,例如安全监控或网络性能优化。 2. **开发Filter Driver**:编写Filter Driver涉及到使用NDIS提供的API来注册驱动程序、处理数据包、响应OID请求、处理PnP事件等。初始化FilterDriver时,需要注册回调函数并设置初始状态。在FilterDriver的生命周期中,需要管理FilterModule的不同状态,并能够执行附加、分离、重启和暂停操作。 3. **数据包的发送与接收**:Filter Module负责管理缓冲区,处理数据包的发送和接收。在处理数据时,可以执行过滤规则来决定哪些数据包需要进一步处理,哪些需要拦截或丢弃。 4. **配置Filter Driver**:通过配置信息,可以设置Filter Driver的行为,包括定义过滤规则和绑定关系。配置通常在INF文件中指定,该文件也用于指导驱动程序的安装过程。 5. **处理OID请求和PnP事件**:Filter Driver需要能够处理OID请求以获取或设置网络设备的参数,并响应PnP事件通知,如设备添加、移除或状态变化。 了解了上述概念之后,就可以开始使用《NDIS Filter Drivers深度解析:封包拦截与过滤技术》这本书来深入学习每个步骤的具体实现方法。这本书详细讲解了如何通过NDIS Filter Drivers进行封包拦截和过滤,从初始化驱动到数据包的发送接收,再到配置信息的处理,为开发者提供了全面的指导。 在完成NDIS Filter Drivers的开发和部署后,如果想要进一步优化或扩展你的网络过滤解决方案,可以参考书中的高级主题,如NET_BUFFER结构和网络数据结构的深入讨论,这些内容将帮助你构建更加强大和灵活的网络过滤系统。 参考资源链接:[NDIS Filter Drivers深度解析:封包拦截与过滤技术](https://wenku.youkuaiyun.com/doc/836ocdsroy?utm_source=wenku_answer2doc_content)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值