Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Now, that we've written all transformation rules, the data from the legacy system is in good shape for our model—we can start with populating it. To extract data from the knowledge session, we'll use Drools queries.
Query
Drools query looks like a normal rule without the then part. It can be executed directly from a stateful knowledge session for example, session.getQueryResults("getAllCustomers") or by using QueryCommand. It returns a QueryResults object that can contain multiple QueryResultsRow objects. Every QueryResultsRow instance represents one match of the query. Individual objects/facts can be retrieved from QueryResultsRow. Drools queries are a convenient way of retrieving objects/facts from the knowledge session that match conditions specified by the query. Queries can be parameterized. In a KnowledgeBase, all of the queries share the same namespace.