| Samples > Rule Studio Business Rule Management Extensions > How to Execute a Query on a Rule Project |
How to Execute a Query on a Rule Project |
PREVIOUS NEXT |
This sample shows how to execute a query on your business rules using the query API. It takes as input a query and a target project which contains the rules. The input query can be supplied in one of the following ways:
Key features include:
This sample extends the Rule Studio API, and the required sample plug-ins are delivered as pre-deployed. If you have not already done so, you must install the samples extension site in Eclipse before running the sample.
To install the plug-in samples extension site:
<InstallDir>/studio/samples/eclipse.
To check that the Query Execution Sample feature is enabled:
loanvalidation-rules project.
C:\ILOG\JRules\studio\samples\eclipse and check that Query Execution Sample 1.0.0. is listed.
To import the queryexecution sample:
ILOG Rule Studio Samples and Tutorials then click Next.
brmanagement > queryexecution.
loanvalidation-rules. The target sample rule project. This project contains rules on which the query will be executed.
queryexecution-application. A Java project including an Ant build file (build.xml) which contains different Ant tasks that will be used in order to demonstrate different execution scenarios. Notice that the project includes a zip file containing a query, which will be used in one of the sample scenarios
queryexecution-queries-container. A rule project containing a query that will be executed. You need to be in the Rule Perspective to run this sample.
To switch to the Rule perspective:
To run the sample:
Ant Build > queryexecution-application.
[echo] executing query on loanvalidation-rules project with arguments:
zip:querycontainer.zip/queries-container/queries/completeness/
documentation scope: true
[java] Arguments : project='loanvalidation-rules' query='querycontainer.zip/
queries-container/queries/completeness/documentation' mode='zip' scope='true'
[echo] executing query on loanvalidation-rules project with arguments:
path:queryexecution-queries-container/queries/completeness/documentation scope: true
[java] Arguments : project='loanvalidation-rules' query='queryexecution
-queries-container/queries/completeness/documentation' mode='path' scope='true'
[echo] executing query on loanvalidation-rules project with arguments:
text:Find all business rules such that the documentation of each business
rule is empty scope: true
[java] Arguments : project='loanvalidation-rules' query='Find all
business rules such that the documentation of each business rule is empty'
mode='text' scope='true'
To display the source code of the queryexecution Eclipse plug-in:
External Plug-ins and Fragments and click Next.
ilog.rules.studio.samples.queryexecution plug-in (be careful not to select ilog.rules.studio.samples.queryexecution.source), then click Add.
ilog.rules.studio.samples.queryexecution > src-queryexecution folder.
The query is executed using the class ilog.rules.studio.samples.queryexecution.Query. This class is defined in the eclipse plug-in description file as an extension for org.eclipse.core.runtime.applications and implements org.eclipse.core.runtime.IPlatformRunnable.
It is executed from within the build.xml file as an Eclipse headless application by using:
ilog.rules.studio.samples.queryexecution.headless.application
Notice that the real query execution is delegated to the ilog.rules.studio.samples.queryexecution.helper.Model class.
This application expects the following mandatory parameters (see the supplied build.xml file for a full list of parameters):
Query object:
targetproject=The name of the rule project (for example: loanvalidation-rules)
query="path:path/to/a/query/object/in/the/eclipse/workspace"
scope=true if the query's scope is local to the query's project or false if it encompasses the project's dependencies.
targetproject=The name of the rule project. For example: loanvalidation-rules
query=a BQL query. For example: "text:Find all business rules such that the documentation of each business rule is empty"
scope=true if the query's scope is local to the query's project or false if it encompasses the project's dependencies.
To define the application flow in Query.java:
path: mode is used, check if the query exists in the workspace and initialize a query service from it.
text: or zip: mode is used, initialize a query service from the query string.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |