Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Model-to-text transformation

As a warm-up exercise, modify this M2T transformation in Epsilon’s online playground so that it generates a table with task names as column headers and person names as row headers, as shown below.

Inverted table

Problem

While the callcentre2java model-to-text transformation discussed in the M2T lecture works fine for models that end with call redirections, it crashes for models that end with statements.

A model that crashes the transformation

Preparation

  • Clone this Github repository
  • Run the Epsilon Eclipse distribution
  • Import only the following projects from the repository/zip file
    • ac.uk.york.callcentre
    • ac.uk.york.callcentre.edit
    • ac.uk.york.callcentre.editor
    • ac.uk.york.callcentre.validation
    • ac.uk.york.callcentre.design
  • Make sure that all imported projects are under the H: or C: drives
  • You can double-check their location by right-clicking on them in Eclipse and selecting the Properties menu item
  • Run a nested Eclipse instance by right-clicking on one of the projects above within Eclipse and selecting Run as -> Eclipse Application
  • In the nested Eclipse instance import only the following projects from the repository/zip file
    • ac.uk.york.callcentre.m2t
    • acmebank.model
    • acmebank.application
  • Run the callcentre2java.egx EGX M2T transformation against the acmebank.callcentre model so that it generates code under the acmebank.application project
    • Create a new EGL Generator run configuration (like you did for EOL and EVL in previous practicals)
    • Set its source to callcentre2java.egx
    • Set the Files should be generated in directory to the acmebank.application project
  • Run the generated AcmeBank.java class
    • Optional: implement the validation logic for PINs as shown in the M2T lecture

Fix the M2T transformation

  • Add a Thank you for calling Acme Bank statement to your model, and a transition to it as shown in the problem description
    • Don’t forget to give the new statement a name in the Properties view!
  • Re-run the M2T transformation and notice how it crashes with a runtime exception (Called feature 'to' on undefined object)
  • Exercise #1: Modify the source code of the M2T transformation to fix the problem

Extend the M2T transformation

  • In the current version of the generated code, a user needs to enter the number of the transition they wish to take at decision points
    • e.g. 1 for yes, 2 for no in Are you an existing customer?
  • Exercise #2: Modify the M2T transformation so that the code produced accepts both the number and the text of the transition
    • e.g. 1 or "yes" for yes, 2 or "no" for no in Are you an existing customer?

HTML generation

  • So far, you have been modifying the existing callcentre2java.egx M2T transformation
  • Exercise #3: write a new M2T transformation that transforms a call centre model into a set of HTML pages
    • One HTML page for each step
    • Hyperlinks in the generated pages to represent transitions

Generated HTML page

Solutions

Model solutions for the exercises are available in this ZIP file.