Establishing relationships 
The gadget spec URL could not be found


In this section, we will implement the relationships for orders data models. But before we can do that, we must understand the relationships that have to be created. 

How will the data be updated in "CustomerOrders" and "ProductOrders"?

As per our design, a form will be used to create an order. The form must provide the functionality to filter products by category, choose the product in required colour and size, and then enter the quantity. Also, it must allow multiple products to be ordered.

In traditional application development, to implement the above functionality, we have to write queries against category table to validate the product category or provide a list for category selection. Similarly, queries will have to be written against product tables to fetch/validate product description, product colour, size and price. Additionally, business rules will have to be written to determine the total amount based on the quantity, price and items ordered.

In OrangeScape paradigm, this will be achieved by establishing relationships between data models. Data models in OrangeScape are a "Network of objects". In a network, any object can be accessed from any level through these relationships. Hence, the links needed not be established during the run-time, as in the case with traditional development method. The business rules are built in the data models which are automatically executed by the rule engine.

Now, let's get started with establishing the required relationships for the orders data models. 


 
Connect as reference, but with criteria: "Product" and "ProductOrders" data models
 
How do we provide a list box for product description?

The easiest way to achieve this is by creating a reference look-up for product description in ProductOrders data model. But if we were to do that, then we will have to somehow validate whether the product selected by the user belongs to the category selected by the user.

Is it possible to filter the product description data that is displayed in the list box when a reference look-up is created?

The "Connect" option provides two ways to achieve this.
  • Constrain data based on (e.g. category selected by the user), OR
  • Filter data based on criteria (e.g. category selected by the user)
We will use the "filter based on criteria" option to provide a list box for product description. Follow the directions below.


Select the "ProductDescription" public cell.
   
Click on the "Connect" icon. Select the "Reference Cell" option.


"Reference Cell Connection Wizard" will be displayed.
   
Select "Product" model from the list of data models.
   
Select "ProductDescription" as the display cell.
   
Click on the "Create" button.
   















Click on the "+" add criteria button. Option to enter the criteria will be displayed.

Select "CategoryCode" from the "Product" drop down list.

Select "Cell" from the dropdown list. The "Value" option can be selected when the values are to be hardcoded.

Select "CategoryDescription" from the "ProductOrders" dropdown list.

Why match "CategoryCode" from "Product" data model against "CategoryDescription" from "ProductOrders" data model?

Click here to learn more.
   
Click on the "OK" button to create the product description list based on the category selected.



 Connect as reference, but with criteria: "ProductColour" and "ProductOrders" data models 

The list of available colours must be displayed for the product selected. To achieve this, reference look-up relationship, with criteria to filter colour based on product selected, must be established between "ProductColour" and "ProductOrders" data model. Follow the directions given below.

Select the "Colour" public cell.
   
Click on the "Connect" icon.
   
Select the "Reference Cell" option.

"Reference Cell Connection Wizard" will be displayed.
   
Select "ProductColour" model from the list of data models.
   
Select "ProductColour" as the display cell.
   
Click on the "Create" button.
   













Click on the "+" add criteria button. Option to enter the criteria will be displayed.

Select "ProductCode" from the "ProductColour" drop down list. 

Select "Cell" from the dropdown list.

Select "ProductDescription" from the "ProductOrders" dropdown list.

Why match "ProductCode" from "ProductColour" data model against "ProductDescription" from "ProductOrders" data model?

Click here to learn more.
   
Click on the "OK" button to list the available colours based on the product selected.



 
Connect as reference, but with criteria: "ProductSize" and "ProductOrders" data models

The available sizes must be displayed for the product-colour combination selected. To achieve this, reference look-up relationship, with criteria to filter size based on product & colour selected, must be established between "ProductSize" and "ProductOrders" data model. Follow the directions given below.

Select the "Size" public cell.
   
Click on the "Connect" icon.
   
Select the "Reference Cell" option.

"Reference Cell Connection Wizard" will be displayed.
   
Select "ProductSize" model from the list of data models.
   
Select "ProductSize" as the display cell.
   
Click on the "Create" button.
   













Click on the "+" add criteria button. Option to enter the criteria will be displayed.

Select "ProductCode" from the "ProductSize" drop down list. 

Select "Cell" from the dropdown list.

Select "Colour" from the "ProductOrders" dropdown list.

Why match "ProductCode" from "ProductSize" data model against "ProductColour" from "ProductOrders" data model?

Click here to learn more.
   
Click on the "OK" button to list the available sizes based on the product & colour selected.