Download Automated transformations from ECA rules to Jess
Transcript
6. Use case: Pete and Mary In this chapter we present a use case that shows how the transformation process works. In order to get this process working, we combine the transformation specifications from Chapter 5 and Appendix C, and import them in the ADT environment. In this way we have obtained a prototype transformation application, ready to transform input models. We present how an ECA-DL rule can be transformed to a Jess rule by presenting a use case. This use case uses the same example used throughout this thesis, involving Pete and Mary: When Mary enters the room, and Pete is already there, act surprised. 6.1. ECA-DL model In ECA-DL, the example from this use case is written as follows: Upon EnterTrue(inRoom(Mary)) When inRoom(Pete) Do actSurprised() Transforming this ECA-DL rule to its corresponding model requires mapping the separate parts of the rule to elements in the ECA-DL metamodel. We thus map the Upon part to the ConditionClause, EnterTrue to Transition, Mary to Expression, etc. This step is done by hand. In XMI, the language the tools use to represent models, the ECA-DL model looks as follows: <?xml version="1.0" encoding="ISO-8859-1"?> <Rule xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="MMECADL"> <eventclause> <compoundtransition> <transition type="EnterTrue"> <expression value="inRoom"> <expression value="Mary"/> </expression> </transition> </compoundtransition> </eventclause> <conditionclause> <expression value="inRoom"> <expression value="Pete"/> </expression> </conditionclause> <actionclause> <function name="actSurprised" value="" /> </actionclause> </Rule> This XMI code shows the different parts of the ECA-DL rule, as well as their relations to the metamodel. From the element “Rule” in the ECA-DL metamodel we follow the reference 44