• No se han encontrado resultados

In order to support access to instances ofDomain Types, IAML uses the Iterator design pattern [118] discussed earlier in Section4.6.2as the structural basis for data access in the language. In particular, all data access is provided through aDomain Iterator, which has explicit references to a source of data (Domain Source) and a data schema (Domain Type). This structure is implemented according to the UML class diagram illustrated in Figure5.2229.

In order to access data, theDomain Iteratorcontains a singleDomain Instance, representing the current instance of theDomain Type of that iterator. This instance is subsequently composed of a number ofDomain Feature Instances, each representing the current value instance of each Domain Featurewithin the specifiedDomain Type. As the iterator is evaluated, accessed and navigated, these instances are populated with the values from the currentinstance pointerof the current result set. The instance data within a particularDomain Iteratorcan be reloaded from the specifiedDomain Source by calling the reload operation within that iterator. A full semantic description of the behaviour of instances, iterators, their properties and operations is provided later in SectionI.38.

Instances ofDomain Iteratorsare stored and accessible according to thecontaining scope of the iterator itself in an identical fashion to thecontaining scope ofValueinstances, discussed earlier in

28“Each entity is defined as the specialisation of at most one super-entity.” [51, pg. 66]

29Within the implementation of IAML, theselectreference of aDomain Iteratoris implemented as theSelect Edge model element. Similarly, theschemareference of aDomain Sourceis implemented as theSchema Edgemodel element.

5.6 Domain Modelling 117

Section5.5.3. For example, multipleSessionscan access the sameDomain Sourceusing the same Domain Iterator, but as each session is unique, each session has a unique view over the domain source.

Domain Iterator Query

To access data from a particular data source, a parameterised query30must be provided to select which data should be retrieved. If no query is provided, then the iterator will simply return all available instances of that type. AnDomain Iteratorquery is provided as a single text string, but this does not prevent language extensions from using alternative query definition methods such as graphical queries or filters. For example, the query “name = :name” will select instances of aDomain Typewhere the Domain Attributenamednamematches the value of the incomingParameternamedname.

One important aspect of SQL is that it only provides a limited range of SQL functions, and these functions may not be provided by particular relational database implementations [186]. Each database vendor also independently defines their own functions, and many common functions – such asMATCH, which may be used to search against text patterns – are not defined in SQL99. Consequently, platform- independent database access must be done through database abstraction layers, such as Propel or PDO for PHP [207,274].

IAML therefore defines its own query functions which are then translated into the function specific for a particular database. These query functions are discussed later in the documentation ofDomain Iteratorin SectionI.38.

Domain Source

ADomain Sourcedefines the source of a particularDomain Type. In particular, it defines where the data is stored; for example, if it is stored within a database, a file, or stored remotely (for example, an RSS feed). Clients using aDomain Iteratordo not need to know where the source data is stored or accessed, or how it is saved.

Figure 5.23 illustrates a partial model used to define the Edit Event page of Ticketiaml. This Domain Iterator will select a single instance of an Event Domain Type as specified through the Domain Sourceconnected to the iterator. This iterator uses a specificquery, “id = :id” in order to select a specificEvent, and this value is provided as aQueryto the iterator from an existingValue.

RSS Feeds

By default, aDomain Source is assumed to be a local database on the same server as the web ap- plication. IAML also supports the use of an external RSS feed as the source of theDomain Type, as specified through thetypeattribute of the source. Such a feed will be will be cached locally and periodically updated31. The feed can be manually updated using the reloadoperation, or it will be updated automatically after a specified number of seconds (thecacheattribute).

Through model completion, a schema provided by an RSS domain source will automatically in- clude the schema of RSS [290] as itsDomain Type. For example, theDomain Typewill include the attributes title,link, description, and so on; however, these attributes will only be populated at runtime if the particular RSS feed provides them. It is up to the developer to keep these attributes

30ADomain Iteratoronly accepts parameterised statements in order to improve the security of the modelled web appli- cations, as described earlier in Section5.2.2.

31The use of an RSS feed as aDomain Sourceof data must not be confused withprovidingan RSS feed through an RSS-typedFrame, as discussed later in Section5.13.4.

5.6 Domain Modelling 119

... >Session: ’Manager Session’> Frame: ’Edit Event’

!"#$%#"&' ( )

Figure 5.23: Ticketiaml: Selecting an instance of theEvent Domain Typethrough aDomain Iteratorconnected to aDomain Source

synchronised with other attributes in the schema, for example by usingSync Wires. This schema is included automatically using the model completion framework32.

Failure Handler Rules

By associating anECA Ruleas afailure handlerto aDomain Iterator, the failure handler will be used to capture exceptions or problems during the evaluation of the iterator, preventing the exception from otherwise crashing the application. This rule is specified as a failure handler by defining thenameof the rule to “fail”.

If an error occurs during the operation of aDomain Iterator– for example, the current instance pointeris requested to go out of bounds, or theDomain Sourceis no longer available – then thefailure handlerwill be executed, according to the semantics ofECA Rule(Section5.4.3). If the iterator does not have a failure handler defined, then the failure handler semantics of the containingScopeare used instead as discussed later in Section5.11.3.

Documento similar