Creating entity loaders

The entity loader editor provides access to the BOM vocabulary. You define the entities from your solution BOM project that you want to load by writing a set of constructs. Once defined, an entity with a specific entity ID can only be loaded once.

Before you begin

Before you create entity loaders, you must create a test client project.

About this task

In an entity loader, you can define test entities for a solution. The entity loader syntax is controlled by the Intellirule editor, and the syntax is based on the business rules language. Specific language constructs are available to use variables and to modify an entity.

All the entities in an entity loader (.eldr) must be defined by using the load <entity> construct. Entities can be specified in no particular order.

Procedure

  1. Create an entity loader file:
    1. In the solution map, click Create entity loader.
    2. In the Entity Loader wizard, select a test client project in your workspace and enter a name for your entity loader file.
    3. Click Finish.
    The .eldr file is saved in the Entity Loader folder in the test client project. The file opens in the editor.
  2. Open the Text editor of the .eldr file.
  3. Press Space or Ctrl+Space to view the available constructs.
  4. Double-click a construct to insert it in the definition.
    To define a variable that identifies the customer as Jane, enter the following line: define 'the customer' as the customer identified by "Jane" ;. You can then use this variable to refer to the customer in the load construct. For example:
    define 'the customer' as a new customer where the customer id is "Jane" ;
    
    load 'the customer' ; 
  5. Optional: Add concepts that are related to an entity. In the following example, a new customer, Jane, is identified by id, first name, and last name.
    define 'Jane' as a new customer where 
       the customer id is "jane@example.com",
       the first name is "Jane" , 
       the last name is "Doe" ;
    
    load Jane ;
  6. Add a load construct for each entity you want to include in your loader. The entity can refer to a variable name or a new entity of a specific type.

    You can use variables in an load construct. In the following example, the where clause is followed by the variable vehicle number, and a moving geometry is set to track the location of the delivery van for 2 days:

    load a new delivery van where  
       the vehicle number is "12347" ,
       the location is a new moving geometry tracked for 2 days ; 
  7. Optional: Use the add construct to add new objects with specific values. In the following example, the product orange is added to the items in Janes Cart:
    define 'Janes Cart' as a new shopping cart where 
       the customer is Jane , 
       the shopping cart id is "123456789" ; 
    
    add the product identified by 'orange' to the products of 'Janes Cart' ; 
    
    load 'Janes Cart' ; 
  8. Check that all of the entities have a corresponding load construct, and each define, add, and load construct ends with a semi-colon (;).
  9. Save the file.

Example

Loading entities
In the following example, all three entities are loaded before the orange is added to Jane's shopping cart:
define 'Jane' as a new customer where 
	the customer id is "jane@example.com",
	the first name is "Jane" , 
	the last name is "Doe" ;
		
define 'Janes Cart' as a new shopping cart where 
	the customer is Jane , 
	the shopping cart id is "123456789" ; 
 
load Jane ; 

define 'orange' as "ORANGE";

load a new product where 
	the id is 'orange' , 
	the description is "An orange" ;

add the product identified by 'orange' to the products of 'Janes Cart' ; 

load 'Janes Cart' ; 
Loading entities with relationships
In the following BMD, the relationship between E1 and E2 is defined:
an E1 is a business entity identified by an e1.
an E1 has an abc.
an E2 is a business entity identified by an e2.
an E2 has an xyz.
an E2 is related to some E1s. 
The following entity loader checks the relationship between E1 and E2:
define e1Instance as a new e1 where the e1 is "e1Id", 
   the abc is "ABCVal" ;
add the e2 identified by "e2Id" to the E1s of e1Instance ;
load e1Instance ;
load a new E2 instance where the e2 is "e2Id", the xyz is "XYZVal" ;