Rule Builder > Business Query Language Reference > Customizing the Business Query Language |
Customizing the Business Query Language |
PREVIOUS |
The BQL does not include a way to return all rules descending from a named package. For example, given the package structure below:
it is not possible to return Rule in standard BQL when conducting a search on MidPackage.
However, you can customize the BQL by extending it as shown in the following example:
import ilog.rules.repository.model.IlrModelElement;
public class MyQueryTools
{
public static boolean hasAncestor(
IlrModelElement element, String ancestorName)
{
while(element != null) {
if(element.getName().equals(ancestorName)) {
return true;
}
element = (IlrModelElement) element.getContainer();
}
return false;
}
}
MyQueryTools
to the User Java Classpath.
ilog.rules.repository.brm.IlrBrmDefaultRule
. In the Property Sheet of the virtual function, set alternate
to it has {0} as ancestor
, set returnType
to boolean
, and set translation
to MyQueryTools.hasAncestor({this}, {0})
. Add an argument of type String
to the virtual function.
<select a condition>
to it has < String > as ancestor
. Then set <String >
to the name of the package in which you want to look for rules. In Code View, the when
part of the query rule should contain the following lines:
ilrBrmDefaultRule: IlrBrmDefaultRule(!isTemplate());
evaluate((MyQueryTools.hasAncestor(ilrBrmDefaultRule, "{package-name}")));
Customer Support | Copyright © 1987-2004 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS |