Implementing a Modeling LanguageImplementing a Modeling LanguageImplementing a Modeling LanguageRonald Quirchmayrhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=1087122014-04-11T10:46:06Z2014-04-09T11:26:41ZThis scenario illustrates the realization of a modeling language. More precisely we will build a modeling tool for the modeling language <em>Entity Relationship (ER) Model</em>. It is shown how to inherit classes and relation classes from the ADOxx Meta Model and how to add/configure attributes. <br /><br />The scenario consisits of two parts. Part I discusses some conceptual aspects of the implementation of a modeling language with ADOxx. In particular we show how to map the generic ADOxx Meta2Model to a concrete modeling language, namely the ER language. Part II provides a step-by-step hands-on guide for the realization of an ER meta model with ADOxx.<br /><br /><span style="font-size: 18px"></span><span style="font-size: 18px">(I) Conceptualization</span><br /><ul style="list-style: disc inside;"><li>Question: how to map the generic ADOxx Meta2Model to a concrete modeling language (ER modeling language)?</li></ul style="list-style: disc inside;"><img src="http://www.adoxx.org/live/documents/10157/108537/01_Mapping_M2M_to_ER_MM.png/88d9d77b-bad0-4ea0-a8f8-81963430df39?t=1397042848178" /><br /><ul style="list-style: disc inside;"><li>Answer: (1) consider what classes and relation classes are needed in order to represent the main constructs of a given language definition. (2) think of appropriate super classes (provided by the ADOxx Operationalizable Meta Model) for new classes. Account for the definition/configuration of (new) attributes so that your meta model describes the full syntax and semantics of the modeling language. (3) define an intuitive graphical notation for the classes and relation classes in order to simplify the modeling.</li></ul style="list-style: disc inside;">The following figure illustrates the above mentioned considerations:<br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/02_conceptualizing_a_MM.png/8e44b3d7-d6ad-4bc1-ba00-5e6fd08fa1dd?t=1397048369520" /><br /><br />In the following we depict the way starting from the ADOxx Meta2Model to the ADOxx Operationalizable Meta Model (which provides e.g. several different super classes with predefined attributes) to the concrete Meta Model representing the ER modeling language:<br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/03_ER_MM.png/1a8ce52a-e835-49a7-93f4-43d29d6607f1?t=1397048671153" /><br /><span style="font-size: 18px"><br />(II) Hands-On</span><br /><br /><strong>1) Define model type:</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/04_define_MT.png/525207ba-cfd8-45ae-acf8-d0309aab8924?t=1397049438180" /><br /><ul style="list-style: disc inside;"><li>Select <em>ADOxx 1.3 Dynamic Experimentation Librar</em>y.</li><li>Click <em>Library attributes...</em></li><li>Go to <em>Add-on</em> chapter.</li><li>Define the model type in the Modi text field, enter: </li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>MODELTYPE “ER-Diagram”</div><strong><br />2) Create a new (abstract) class, inherited from __D-construct__:<br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/05_define_abstract_class.png/9dffa452-69d4-4a52-b397-a00d30fc8459?t=1397050162957" /><br /></strong><ul style="list-style: disc inside;"><li>Select <em>ADOxx 1.3 Dynamic Experimentation Librar</em>y.</li><li>Click <em>Class hierachy...</em></li><li>Click <em>View </em>and select <em>Metamodel </em>and <em>Class hierachy</em>.</li><li>Select super class <em>__D-construct__</em>.</li><li>Click <em>New </em>--> <em>New class...</em></li><li>Name new class <em>_ER-construct_</em> (here we apply the name convention for abstract classes: class name starts and ends with an underscore sign)</li></ul style="list-style: disc inside;"><strong>3) Make the class _ER-construct_ abstract (effect: class can not be instantiated in the Modelling Toolkit):<br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/06_make_class_abstract.png/e9f6a96b-8c79-4dd2-839d-8fddce017f3b?t=1397050935413" /><br /></strong><ul style="list-style: disc inside;"><li>Unfold the class <em>_ER-Construct_</em> in order to see all its attributes.</li><li>Double click the attribute <em>ClassAbstract </em>and check <em>ClassAbstract</em>.</li></ul style="list-style: disc inside;"><strong>4) Create new classes named Entity and Relation, inhereted from _ER-construct_</strong><ul style="list-style: disc inside;"><li>runs analogously to step 2) </li></ul style="list-style: disc inside;"><strong>5) Create new class named Attribute, inhereted from __D-construct__</strong><ul style="list-style: disc inside;"><li>runs analogously to step 2) </li></ul style="list-style: disc inside;"><strong>6) Configure GraphRep of Class Entity:</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/07_GraphRep_Entity.png/6821f6e2-b8e9-4ec8-ae97-93c3d4e12ff8?t=1397051820537" /><br /><ul style="list-style: disc inside;"><li>Unfold class <em>Entity</em></li><li>Double click attribute <em>GraphRep (Metamodel)</em></li><li>Click <em>Dialog </em>button</li><li>Enter the following LEO code:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>GRAPHREP<br /><span class="code-lines">2</span>PEN w:0.05cm<br /><span class="code-lines">3</span>RECTANGLE x:-2cm y:-.5cm w:4cm h:1cm<br /><span class="code-lines">4</span>ATTR "Name" x:0cm y:0cm w:c:3.5cm h:c:1cm line-break:rigorous<br /></div><strong></strong><ul style="list-style: disc inside;"><li>Click <em>View </em>in order to view the GraphRep</li><li>Click <em>Apply</em></li></ul style="list-style: disc inside;"><strong>7) Configure GraphRep of Class Relation:<br /></strong><ul style="list-style: disc inside;"><li>runs analogously to step 6), use the following LEO code: </li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>GRAPHREP<br /><span class="code-lines">2</span>PEN w:0.05cm<br /><span class="code-lines">3</span>FILL color:white<br /><span class="code-lines">4</span>POLYGON 4 x1:-1.9cm y2:1.6cm x3:1.9cm y4:-1.6cm<br /><span class="code-lines">5</span>ATTR "Name" w:c:2.5cm h:c:0.8cm line-break:rigorous<br /></div><br /><strong>8) Configure GraphRep of Class Attribute:</strong><ul style="list-style: disc inside;"><li>runs analogously to step 6), use the following LEO code: </li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines"> 1</span>GRAPHREP<br /><span class="code-lines"> 2</span>PEN w:0.05cm<br /><span class="code-lines"> 3</span>ELLIPSE x:0.00cm y:0.00cm rx:3.00cm ry:0.80cm<br /><span class="code-lines"> 4</span>ATTR "Name" y:-0.2cm w:c:2.8cm h:t<br /><span class="code-lines"> 5</span># Advanced Attribute Dependent Graphical Notation<br /><span class="code-lines"> 6</span>AVAL k:"key"<br /><span class="code-lines"> 7</span>IF ( k = "1")<br /><span class="code-lines"> 8</span>{<br /><span class="code-lines"> 9</span> LINE x1:-1.7cm y1:-0.5cm x2:-1.7cm y2:0.5cm<br /><span class="code-lines">10</span> LINE x1:-1.5cm y1:-0.6cm x2:-1.5cm y2:0.6cm<br /><span class="code-lines">11</span>}<br /></div><br />Note that the GraphRep of class <em>Attribute </em>depends on the value of the attribute <em>key</em>; we add this attribute to class <em>Attribute </em>in the next step.<br /><br /><strong>9) Add new attribute (Integer) to class Attribute:</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/08_new_attr.png/17939565-cf45-4a1a-b649-2d8d4e8bac57?t=1397052651273" /><br /><ul style="list-style: disc inside;"><li>Select class <em>Attribute</em></li><li>Click <em>New </em>--> <em>New attribute...</em></li><li>Enter attribute name: <em>key</em></li><li>Select type: <em>Integer</em></li></ul style="list-style: disc inside;"><strong>10) Add new attribute (Enumeration) to class Attribute</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/09_enumeration.png/cf26cfbe-9b0b-490a-9d7e-0575213f2091?t=1397053201487" /><br /><ul style="list-style: disc inside;"><li>Similar to step 8): attribute name: <em>datatype</em>, type: <em>Enumeration</em></li><li>Add the items <em>String, Integer, Float </em>to the value range and apply </li></ul style="list-style: disc inside;"><strong>11) Configure AttrRep (Metamodel) attribute of class Attribute</strong><br /><ul style="list-style: disc inside;"><li>Double click <em>AttrRep (Metamodel)</em></li><li>Set <em>Standard value</em>:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>NOTEBOOK<br /><span class="code-lines">2</span>CHAPTER "Description"<br /><span class="code-lines">3</span>ATTR "Name"<br /><span class="code-lines">4</span>ATTR "key" ctrltype:check<br /><span class="code-lines">5</span>ATTR "datatype" ctrltype:dropdown<br /></div><br /><strong>12) Incude classes to model type ER-Diagram</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/10_incl_classes_to_mt.png/c3714037-ca1d-49ab-a899-a12c6c22133e?t=1397053751080" /><br /><ul style="list-style: disc inside;"><li>Go to the <em>Modi </em>attribute in the <em>Library attributes</em> (c.f. step 1) )</li><li>Add the following lines in order to include the classes <em>Entity, Relation, Attribute</em> in the model type <em>ER-Diagram</em>:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>INCL "Entity"<br /><span class="code-lines">2</span>INCL "Relation"<br /><span class="code-lines">3</span>INCL "Attribute"<br /></div><br /><strong>13) Create relation class "has"</strong><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/11_rel_class.png/629517a7-4ea5-4e7c-952a-c42cafe6aa36?t=1397054365910" /><br /><ul style="list-style: disc inside;"><li>Select <em>ADOxx 1.3 Dynamic Experimentation Librar</em>y.</li><li>Click <em>Class hierachy...</em></li><li><em></em>Double click folder <em>Relation classes</em></li><li>Click <em>New </em>--> <em>New relationclass...</em></li><li>Enter name: <em>has</em>, from-class: <em>_ER-construct_</em>, to-class: <em>Attribute</em></li><li>Include relation class <em>has </em>to model type <em>ER-Diagram</em>:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>INCL "has"</div><br /><strong>14) Configure GraphRep of relation class "has"</strong><ul style="list-style: disc inside;"><li>Use the following LEO code:</li></ul style="list-style: disc inside;"><div class="code"><span class="code-lines">1</span>GRAPHREP<br /><span class="code-lines">2</span>EDGE<br /><span class="code-lines">3</span>START<br /><span class="code-lines">4</span>FILL color:black<br /><span class="code-lines">5</span>ELLIPSE x:-.1cm y:0cm rx:.1cm ry:.1cm<br /></div><br /><br /><strong>15) Create relation class "relates"</strong><br /><ul style="list-style: disc inside;"><li>Runs analogously to step 13)</li><li>name: <em>relates</em>, from-class: <em>Entity</em>, to-class: <em>Relation</em></li></ul style="list-style: disc inside;"><span style="font-size: 18px">Result:</span><br /><br /><img src="http://www.adoxx.org/live/documents/10157/108537/12_result.png/0d1fd1b6-e01a-45d5-8cb3-602df0262e07?t=1397057193353" />Ronald Quirchmayr2014-04-09T11:26:41Z