skip to main content
Corticon Studio: Rule Modeling Guide : Writing Rules to access external data : Enabling Database Access for Rules using root-level Entities
 

Try Corticon Now

Enabling Database Access for Rules using root-level Entities

Since database access for rules using root-level terms is disabled by default, we need to know how to enable it for those circumstances when we do want it. We call this “extending” a root-level entity to the database. To illustrate, we’ll use a simple rule based on the Cargo project's Vocabulary, Cargo.ecore.
The process of connecting this particular Vocabulary to an external database is discussed in detail in the EDC tutorials. While the mechanics of this connection may not be of much interest (or importance) to a rule modeler, we do need to be comfortable with Studio Test behavior when connected to an external database in order to focus on what extending to a database really means to our rule expressions.
Figure 201. Sample Rulesheet
The Rulesheet shown above simply adds up (sums) the collection (you may want to review the Collections chapter for a refresher on this operator or collections in general) of Cargo weights associated with a FlightPlan (load.weight) and compares this to the maxCargoWeight of the root-level Aircraft. Our intention is to perform this comparison for every available Aircraft, so we have used the root-level Aircraft in our Conditional expression. Any Aircraft whose maxCargoWeight is inadequate will be identified with a posted Violation message.
* Testing the Rulesheet with Database Access disabled
* Testing the Rulesheet with Database Access enabled
* Optimizing Aggregations that Extend to Database