Getting started with the Data Model Unit

by Mario Bruno
8,951 views Published on Oct 24, 2011
Applies to: 5.1 or higher
Table of contents

Introduction

The Data Model Unit is available starting from the WebRatio 5.1 version. It's an hybrid unit, which means that it can be placed in every View (SiteView, ModuleView, ServiceView).It permits to retrieve information about entities and relationship of the Data Model. This information usually are used to create a custom query using the Query Unit.

 

Here is the list of the retrieved Data Model information:

  • the available entity identifiers and labels
  • the reachable entities identifiers and labels navigating the relationship roles outgoing of an entity
  • the attributes identifiers and labels of an entity
  • the available condition predicates values and labels
  • the available aggregate functions
  • the available sorting criteria values and labels
  • the available condition boolean operators

It's possible to define the Entities whose Data Model information must be shown through the Entity element. To do this right click on the unit and choose the Add Entity command. Each Entity element has the following properties:

  • Entity. The entity from which attributes and relationships must be retrieved.
  • Attributes. The list of attributes to show.
  • Hide Roles. If checked all outgoing relationship roles are not shown.

For each Entity it's possible to define the relationship roles of the entity to show through the Relationshipt Role element. To do this right click on the unit and choose the Add Relationship role command. Each Relationship Role element has the following properties:

  • Name. The relationship role name.
  • Rel. Role. The relationship role used to retrieve the reachable entities to show.

The Data Model Unit provides two Input Parameters that allows to complement the information retrieved using the configuration of the unit (in terms of Entity and Relationship Role elements) with the information belonging to these parameters.

  • Entity Id . The entity id whose attributes and relationships must be shown in addition of the "standard" ones.
  • Attributes Identifiers. The attributes identifiers to transform into the relative parent entity identifiers.
  • Entity Identifiers. The identifiers of all the Data Model Entities, or the reachable Entities from the input Entity.
  • Entity Labels. The labels of all the Data Model entities, or the reachable Entities from the input Entity.
  • Attributes Identifiers. The attributes identifiers of the input Entity.
  • Attributes Labels. The attributes labels of the input Entity.
  • Predicates Values. The condition predicates values. This list is standard and contains all the available predicates values that have to be used in the custom query.

   "beginsWith", "beginsWithIgnoreCase", "contains", 

   "containsIgnoreCase", "endsWith", "endsWithIgnoreCase", "eq", "eqIgnoreCase", "gt", 

   "gteq", "notNull", "null", "lt", "lteq", "notBeginsWith",

   "notBeginsWithIgnoreCase", "notContains", "notContainsIgnoreCase", "notEndsWith", 

   "notEndsWithIgnoreCase", "neq", "neqIgnoreCase"

  • Predicates Labels. The condition predicates labels. This list is standard and contains all the available predicates names that can be used to shown to the user in order to let him select one of them.

   "Begins With", "Begins With (Ignore Case)", "Contains",

   "Contains (Ignore Case)", "Ends With", "Ends With (Ignore Case)", "Equal", "Equal (Ignore Case)", "Greater Than",

   "Greater or Equal", "Is Not Null", "Is Null", "Less Than", "Less or Equal", "Not Begins With",

   "Not Begins With (Ignore Case)", "Not Contains", "Not Contains (Ignore Case)", "Not Ends With",

   "Not Ends With (Ignore Case)", "Not Equal", "Not Equal (Ignore Case)"

  • Aggregate Functions. The aggregate functions. This list is standard.

   "avg", "count", "max", "min", "sum"
  • Sort Criteria Values. The sort criteria values. This list is standard.

  "asc", "desc"

  • Sort Criteria Labels. The sort criteria labels. This list is standard.

  "Ascending", "Descending"

  • Boolean Operators. The list of available condition boolean operators. This list is standard.

  "and", "or"

  • Relative Attributes Identifiers. The relative attributes identifiers.

Working with the Data Model Unit

Suppose you want to show in a selection field the list of the main Data Model entities. First of all you have to know the structure of the Data Model. In this example we consider to have the following entities.

 

 

 

 

 

Let's see how to model a page in which the user can choose one of the Data Model entities. The result can be something like the image on the right.

 

  1. Add a page to the Site View.
  2. Add an Entry unit with a selection field named "Entity".
  3. Add two slots to the "Entity" selection field. The "id" slot which is only an output slot and the "name" slot which is both label and output.
  4. Add a Data Model Unit and name it "Entities List". Add two Entities to the unit, the "Category" and the "Product" entities. Choose the "name" attribute as the attributes to load.
  5. Connect the Data Model Unit and the Entry Unit with a transport link. Double click on the link and in the opening Coupling dialog couple the "id" slot with the "Entity Ids" output parameter and the "name" slot with the "Entity Labels" output parameter.

 

You can now generate the project and see the final result.