Atoms Editor Screen

 

Atoms Editor lets you enter the RuleLab.Net basic primitives – Atoms – that Facts and Rules can be built upon. Atoms utilize XML References to provide a bridge between the RuleLab.Net and your application data. By entering an Atom you are associating a RuleLab.Net’s alias with a set of XML References (the References point to your application fields). Unlike a Fact, no data is contained in an Atom definition. An Atom serves two purposes:

  • it :is a template for entering Facts
  • it is a variable that receives data values at runtime.

 

Atoms, not XML References, make up Rule Conditions and Actions. At BRE runtime, Atoms get related to data. Data can be assigned to Atoms in one of 2 ways:

  • by passing data values into the BRE via the Application XML document
  • by executing Actions when Rules fire

 

For example, if we wanted to create a “Deposit” Atom that receives its value depending on the field values of a “Travel Package” atom them we would define the following two Atoms:

 

Travel Package:

                Hotel                      (XML Reference to /customer/reservation/hotel - “yes” or “no”)

                Cruise                   (XML Reference to /customer/reservation/cruise -  “yes” or “no”)

 

Deposit                                  (XML Reference to /customer/reservation/deposit)

 

In order to set the “Deposit” Atom, we could define a Rule which implies that “If Customer package includes both Hotel and Cruise then request a Deposit of $500 otherwise request a Deposit of $300”.

 

Let’s assume that an application sends the BRE an XML data document containing the following nodes

/customer/reservation/hotel set to “yes” and

/customer/reservation/cruise set to “no”

 

At BRE runtime, the Rule would relate the “Travel Package” Atom to the supplied data, fire and set the “Deposit” atom to $500. Now that the “Deposit’ Atom has data, it can satisfy other Rules – the ones with Conditions involving the “Deposit” (“Total Calculation” etc).

 

 

We could also use the “Travel Package” Atom to instantiate a Fact such as “Full Package”:

Hotel=yes

Cruise=yes

If we gave this Fact a narrative description of “Customer package includes both Hotel and Cruise” then we could utilize it in the Rule as specified above. At runtime, this Rule compares the “Travel Package” Atom’s data against the “Full Package” Fact data.

 

Atoms can be single-reference and multi-reference. Single-reference Atoms only contain one XML reference (the “Deposit” Atom is a good example). They can be defined by simply checking the corresponding box in the XML Reference Editor. Multi-reference Atoms contain several References (for example, the “Travel Package” Atom). The Atoms Editor lets you enter multi-reference Atoms. Although you’d normally make single-reference Atoms in the References Editor, you can create new single-reference Atoms here as well.

 

The Atom Editor screen consists of 2 sections: the Atoms and the available XML References. The Atoms section has an Alias text box and a Reference list. Each row corresponds to a single Atom. To create/update an Atom, click an Atom row. Atom alias can be any globally unique name. To select Atom’s XML References, highlight the one you want in the Reference pane and click the arrow button. Note that if a Reference is already used in this Atom, it will gray out when you click the Atom row.

 

When you are adding loop References to an Atom, the first one you add will determine the loop container for the Atom. All loop References in an Atom must belong to the same loop therefore you will not be able to select References from different loops. If, however, a Reference loop is changed after an Atom is built, you will need to resolve a potential loop conflict. For more information see “Changing References”.

 

A multi-reference Atom is considered overwritable if all its References are marked as overwritable.

 

Always run the Validate function upon entering and changing the Atoms.

 

In order to save Atoms into an XML document and store them in the database click the Save button. You can switch between the tabs of the current project as much as you wish before you Save but if you forget to save changes, unlike Rules, the Atom changes cannot be recovered.

 

Changing Atoms

 

When an Atom file is loaded, the Editor renders the ones in use by Rules or Facts in a blue color. You cannot change their aliases but you can move them around and alter their References. Note, however, that changing them may affect the instantiated Facts. For more information on how to keep your Facts in sync with Atom changes see “Changing Atoms and Facts” in the Facts Editor specification. To find out where a “blue” Atom is used, click it and click the “Used Where?” button. The RuleLab.Net will scan the loaded Facts and Rules and display a message at the top of the screen showing your Rules and/or Facts where this Atom is utilized.

 

Since RuleLab.Net allows multiple Facts and Rules files per single Atoms file, it is possible to delete Atoms that are in use in files not currently loaded. Should this happen, when those files are loaded as part of a project, the Editor will notify you of unresolved Atom names. Please follow each error message to correct the problem. It is best to utilize this check early, when you modify your Atoms file rather than wait till this issue errors out in BRE. RuleLab.Net administrator should be aware of all usages of the Atoms file and take action timely. 

 

Database Connectivity

 

Optionally, you can enter SQL commands for accessing your database at runtime. Each atom can take up to 3 commands. To enter them, click the “SQL” link below the Atom name. Using these commands, the BRE will move data between your application XML and the database. For more information see Database Access.