WebML provides a number of built-in operations, whose meaning is predefined in the language. Due to the orientation toward data-intensive Web applications, most predefined operations address data-management tasks; a few other built-in operations are provided, which offer services of general utility, frequently used in Web applications; they are the login and logout operations and the send-mail op- eration. The following sections describe the syntax and usage patterns of each pre- defined operation.
4.3.1
Object Creation
The first built-in operation is the create unit, which performs the creation of a new entity instance. Each create unit is characterized by the following:
A user-defined name.
Thesource entityto which the operation applies.
A set of assignments,binding the attributes of the object to be created to the parameters values coming from the input link, or to some constant values. The input of a create unit is a set of attribute values, typically coming from one input link exiting from an entry unit. These values are used by the create op- eration to construct the new object; if some attributes have no associated input value, they are set to null, with the exception of the OID, which is treated differ- ently: if no value is supplied, a new value, unique with respect to the entity in- stances, is generated by the operation. The output produced by the create operation is the set of attribute values, including the OID, of the newly created object. This output is defined only when the operation succeeds, and thus can be meaningfully associated as a link parameter only to the OK link, and not to the KO link. The default output of the create unit is the value of the OID attribute, which is assumed as the implicit link parameter of the OK link, if no parameter is specified explicitly.
The example in Figure 4.1 shows the typical usage pattern for create opera- tions, which consists of the combination of an entry unit (ArtistEntry) providing input to a create unit (CreateArtist), creating a new instance of an entity (Artist). In the example, the entry unit has two fields (FirstName, LastName), for entering the first name and the last name of an artist. The values inserted by the user are associ- ated as explicit parameters with the link from the entry unit to the create operation. These parameters are bound to the attributes of the artist object to be created by means of two assignments, represented below the source entity of the create unit. In the rendition, shown in Figure 4.1, the link exiting the entry unit is displayed as a submit button, permitting the activation of the operation. The CreateArtist oper- ation has two output links: the OK link points to the ArtistDetails data unit and is associated with the default link parameter (the OID of the new object). The KO link points back to the ArtistCreation page, to let the user retry the operation.
The complete textual description of the example of Figure 4.1 is shown on page 141. In particular, the create unit and its OK and KO links are exemplified.
EntryUnit ArtistEntry
(FirstName String, LastName String)
link toCreateUnit
(from ArtistEntry to CreateArtist;
parameters FName:FirstName, LName:LastName) CreateUnit CreateArtist
(source Artist;
FirstName:=FName, LastName:=LName) OKLink createOKlink
(from CreateArtist to ArtistDetails;) KOLink createKOlink
(from CreateArtist to ArtistCreation;) DataUnit Artist details
(Source Artist;
attribute FirstName, LastName)
4.3 Predefined Operations 141 ArtistCreation ArtistEntry CreateArtist Artist <FirstName := FName> <LastName := LName> FName:FirstName LName: LastName CreationResults Artist ArtistDetails OK KO CreationResults CREATION RESULTS FirstName: Celine LastName: Dion ArtistCreation CREATE ARTIST FirstName: LastName: Press OK to create Celine Dion OK OK KO
A special case of object creation is represented by the specialization of an ex- isting object to make it belong to a sub-entity of a generalization hierarchy. For ex- ample, an existing artist could be specialized as a jazz artist or as a pop artist, by extending him/her with the suitable attributes required by the sub-entity. How- ever, some care must be adopted in the creation of the specialized object, because the object of a sub-entity is also an object of the super-entity, and thus it must have the same OID as its corresponding super-entity object. In other words, for a JazzArtist object to be a specialization of an Artist object, the Artist and the Jazz- Artist objects must have the same OID. Therefore, a create unit for specializing ob- jects must receive as input also the OID of the super-entity object, which is needed to correctly create the new instance of the sub-entity.
Figure 4.2 shows an example of creation of a specialized object. First the user selects an existing artist, then he/she specializes the artist as a jazz artist by filling
142 Chapter Four: Content Management Model
CrateJazzArtist Artists AllArtists Artist JazzArtistEntry JazzArtistCreate JazzArtist <OID := Art> <Instrument := Instr> Artists ALL ARTISTS • Andrea Bocelli • Bruce Springsteen • Celine Dion