Using Parameter objects, you can now add parameters to a query at execution time. This operation requires installation of the Facility Explorer plug-in.
Note that for simplicity, this example starts from the original repository.
To create a parameter-based query proceed as follows:
-
Click Reopen Repository on the File menu to reload the repository and then open the Facility Explorer.
-
Open the Query Editor and click the
button in the Query Editor to add a new query. The query is added to the Facility Explorer as a package with a single rule query as shown in Figure 17.26.
-
Figure 17.26 Query Package with Rule Query
-
Rename the rule query package to, for example, "p query" either in the Property Sheet or in the Facility Explorer. Rename the rule query to something more meaningful, for example, Priority Parameter.
-
Right-click the p query package and then click Add Parameter on the shortcut menu, as shown in Figure 17.27.
- You can also click Add Parameter on the Project menu.
-
Figure 17.27 Adding a Parameter
-
In the Property Sheet pane set the parameter type to
java.lang.String
and its name to ThePriority
as shown in Figure 17.28.
-
Figure 17.28 Setting the Parameter Properties
-
Now right-click the rule query to open the Facility Editor and write the following rule query (using the <select an item> token):
For each business rule
Such that priority is ThePriority
Do
Insert as query result
Your rule query should look like Figure 17.29.
Figure 17.29 Parameter Query Example
-
Click the Query Editor tab to open it and display a table containing all the parameter information of the current query. Set the value of
ThePriority
to "high" as shown in Figure 17.30.
-
Figure 17.30 Query Editor Displaying Parameter Information
-
Click the
button to execute the rule query. The results show four rules found, as shown in Figure 17.31.
-
Figure 17.31 Parameter Query Results
See Also
Introduction to Ruleset Parameters
|