Delete Unit

From WebRatio WebML Wiki

Jump to: navigation, search


Contents

Introduction

The Delete Unit

The Delete Unit is an Operation Unit and it's used to remove instances of an Entity. When the Delete Unit is activated it physically removes one or more rows of the physical table related to the selected Entity.

Properties

The Properties View of the Delete Unit
  • Id: The unique key automatically assigned by WebRatio to identify the Unit (e.g. dlu11).
  • Name: A meaningful name for the Unit, used as label (e.g. Delete employee).
  • Entity: The Data Model Entity on which the Unit is based (e.g. employee).
  • Home: A flag stating that the Delete Unit must be executed as the first operation when the user enters in the related Site View.
  • Default: A flag stating that the Delete Unit must be executed as the first operation when the user enters the Area containing the Unit.
  • Landmark: A flag stating that the link shown in the corresponding Landmark menu that will activate the Unit. If the operation or the operation chain has no outgoing link, the final target page will be the last page visited.
  • Protected: A flag stating that the access to the Delete Unit is granted only to users belonging to groups entitled to access to it.
  • Secure: A flag stating that all the links that can activate the Delete Unit are implemented using the Secure HTTP protocol, instead of the HTTP protocol.
  • Custom Descriptor: A flag stating that the Unit uses a Custom Descriptor.
  • Custom URL Name: The Custom URL Name of the Unit. It is possible to define a custom name that will be used as URL to reach the Delete Unit, instead of the standard Id (used by default). The custom URL name must not contain whitespaces, non-ascii characters or other special characters like /, ?.


Configuration

The Context Menu of the Delete Unit

A Delete Unit can be configured through a context menu that can be reached right clicking on the Unit either in the Work Area or in the Outline View. The context menu contains the following options:

  • Add Link: Adds an outgoing link to the Unit which can be used to transport information and eventually to activate different actions (such as adding new content to the page, reaching another page with new content, activating operation chains).
  • Add OK Link: Adds an outgoing OK Link to the Unit. The OK Link is activated when the Unit performs its operation correctly and can be used to transport information. Moreover, the OK Link will cause the execution of its target element (opens a target page or activates other Operation Units).
  • Add KO Link: Adds an outgoing KO Link to the Unit. The KO Link is activated when the Unit isn't able to perform its operation correctly and can be used to transport information. Moreover, the KO Link will cause the execution of its target element (opens a target page or activates other Operation Units).
  • Add Property: Adds a custom property to the Unit. A Property is composed by Name and Value and permits to mark the element for different purposes.
  • Add Key Condition: Adds a Key Condition to the Unit.
  • Add Attributes Conditions: Adds an Attributes Condition to the Unit.
  • Add Relationship Role Condition: Adds a Relationship Role Condition to the Unit.
  • Add Cascade Delete Role: Adds a Cascade Delete Role Condition to the Unit. This Condition behaves like a Relationship Role Condition but instead of filtering the shown instances, it defines the Relationship Role on which perform a cascade delete.


Input and Output

The Input and the Output of the Unit are accessible through the Parameters Coupling window of incoming and outgoing Links respectively.

Input

Input configuration of the Delete Unit

The input of the Delete Unit consists of all the Conditions defined on the Unit. To access the input parameters, open the Parameters Coupling dialog with a double click or by selecting the "Coupling" property on an incoming link to the Delete Unit. Here all the Conditions are listed.


Output

The Delete Unit does not provide output parameters. The Parameters Coupling dialog for outgoing Links might be used only for static values or for Passing parameters.

Examples

The purpose of this section is to show the usage of the Delete Unit through examples. This example is based on the Data Model shown in the following image.

The Data Model used in the example
This Data Model consists of two Entities : "Company" and "Employee".

The "Company" entity has many attributes, such as "Name", "E-mail", "Nationality", and so on.

The "Employee" entity has attributes such as "Name", "Surname", "Email", "Role" and so on.

An Employee belongs to one Company while, obviously, a Company has many Employees. This is represented with the 1:N Relationship "Company_Employee".

Example 1: Delete employees

Our goal is to give the possibility to the user to delete employees from the application. The user will be able to select the employees from the list and delete their data. In order to accomplish this example, it is necessary to go through the following steps:

  1. Add a Page to the Site View: select the "Page" icon from the palette, and place it on the Site View. Change the page name (setting "Delete Employees") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
  2. Add a Power Index Unit to the page: select the Power Index Unit icon from the palette and place it inside the page. Change the "Name" property in "Employee List".
  3. Set the Entity on which the Power Index Unit is based: click on the "Edit" button next to the "Entity" property in the Properties View. Then choose the "Employee" Entity from the opened dialog pane.
  4. Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the "name", "surname", "hire date" and "company" attributes from the opened dialog.
  5. Define the sort criteria of the Power Index Unit: click on the "Edit" button next to the "Default Sort Attributes" property, then choose the "surname" attribute and the "ascending" sort criteria. Since the Power Index Unit is dinamically sortable, set the "Sortable" property to true and the "Sort History Size" property to 1.
  6. Define the division of the Employee List in pages: select the Power Index Unit, set the "Block Factor" property to "10" and the "Block Window" property to "10".
  7. Add a Delete Unit: select the Delete Unit icon from the palette and place it inside the Web Model. Change the "Name" property in "Delete Employees".
  8. Set the Entity on which the Delete Unit is based: click on the "Edit" button next to the "Entity" property in the Properties View. Then choose the "Employee" Entity from the opened dialog pane.
  9. Draw a normal link between the "Employee List" Power Index Unit and the "Delete Employees" Delete Unit: select the Link button from the palette and click on the "Employee List" Power Index Unit (the Source of the Link) and then on the "Delete Employees" Delete Unit (the Target of the Link). Set the Name property of the newly created Link to "Delete" and the Type property to "normal".
  10. Define the parameters coupling: open the Parameters Coupling window of the newly created link in order to define the coupling between the output parameters of the source Unit and the input parameters of the target Unit.In the Parameters Coupling dialog, couple the "oid" Attribute of the Power Index Unit with the automatically created Key Condition of the Delete Unit.
  11. Draw an OK link between the "Delete Employees" Delete Unit and the "Delete Employees" Page: select the Link button from the palette and click on the "Delete Employees" Delete Unit (the Source of the OK Link) and then on the "Delete Employees" Page (the Target of the OK Link). Set the Name property of the newly created OK Link to "Employee deleted".
  12. Generate the Web application: click on "Generate Full Web Project" on the WebRatio Menu Bar. Once the generation process has completed, it is possible to start the application server and test the Web application.
The Web Model of the example
The Properties View of the Power Index Unit
The Properties View of the Delete Unit
The Parameters Coupling window
The generated Web application

Possible Enhancement

Our goal is to give the possibility to the user to delete more than one employee data at once. The user to select all the employees he wants to delete and delete all their data in a single operation. In order to accomplish this example, it is necessary to go through the following steps:

  1. Enable the Power Index Unit for multiple selection: click on the "Checkable" property checkbox in order to enable it.
  2. Draw a normal link between the "Employee List" Power Index Unit and the "Delete Employees" Delete Unit: select the Link button from the palette and click on the "Employee List" Power Index Unit (the Source of the Link) and then on the "Delete Employees" Delete Unit (the Target of the Link). Set the Name property of the newly created Link to "Delete Selected" and the Type property to "normal".
  3. Define the parameters coupling: open the Parameters Coupling window of the newly created link in order to define the coupling between the output parameters of the source Unit and the input parameters of the target Unit.In the Parameters Coupling dialog, couple the "Checked oid" Attribute Condition of the Power Index Unit with the automatically created Key Condition of the Delete Unit.
  4. Generate the Web application: click on "Generate Full Web Project" on the WebRatio Menu Bar. Once the generation process has completed, it is possible to start the application server and test the Web application.
The Web Model of the example
The Properties View of the Power Index Unit
The Parameters Coupling window of the "Delete Selected" Link
The generated Web application



Related articles:
Category Difficulty Refers
Context Parameters Web Model Beginner Get Unit
Set Unit
Reset Unit
Create Unit Web Model Beginner Create Unit
Create a "Hello world" application Web Model Beginner Site View
WebML
WebRatio
Create a "Simple data centric" web application Web Model Beginner Site View
WebML
WebRatio
Custom Locations and Master pages Web Model Beginner Master Page
Custom Location
… further results












Did you find this article useful? Please rate it!

Rating: 0.0/5 (0 votes cast)

Personal tools