<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Automatic Generation of Consistency-Preserving Edit Operations for MDE Tools</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Michaela Rindt</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Timo Kehrer</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Udo Kelter</string-name>
          <email>kelterg@informatik.uni-siegen.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Software Engineering Group University of Siegen</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>Many tools for Model-Driven Engineering (MDE) which are based on the widespread Eclipse Modelling Framework (EMF) [4] are developed for single tasks like e.g., generating, editing, refactoring, merging, patching or viewing of models. Thus, models are oftentimes exchanged in a series of tools. In such a tool chain, a gra cal model editor or viewer usually sets the degree of well-formedness of a model in order to visualize it. Well-formedness rules are typically de ned in the meta-models, yet not all tools take them into account. As a result, a model can become unprocessable for other tools. This leads to the requirement, that all tools should be based on a common de nition of minimum consistency. An obvious solution for this challenge is to use a common library of consistency-preserving edit operations (CPEOs) for models. However, typical meta-models lead to a large number of CPEOs. Manually specifying and implementing such a high number of CPEOs is hardly feasible and prone to error. This paper presents a new meta-tool which generates a complete set of CPEOs for a given meta-model. We have successfully integrated the generated CPEOs in several developer tools. The video http://youtu.be/w31AcMOd83Y demonstrates our meta-tool in the context of one of our developer tools.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Model-Driven Engineering (MDE) must be supported by tools which can edit or
refactor (e.g., [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]), generate (e.g., [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]), patch or merge models (e.g., [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]). These
tools are typically based upon the Eclipse Modeling Framework (EMF) [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], in
which a model is represented as an Abstract Syntax Graph (ASG). Frameworks
such as EMF provide basic API methods to edit the ASG of a model, e.g.
creating, deleting or updating single objects or attributes. However, editing ASGs
with such low-level operations can violate consistency constraints on the ASG
de ned in a meta-model. The resulting inconsistent ASGs cannot be processed
and graphically visualized by most MDE tools. In order to solve this problem, all
model editing tools should use a common library of consistency-preserving edit
operations (CPEOs). These CPEOs must be tailored to the relevant meta-model
and its constraints. Unfortunately, complete sets of CPEOs can be quite large for
comprehensive meta-models such as the UML [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] meta-model. Obviously, the
manual implementation of a large number of CPEOs, e.g., as code or executable
transformations, is not only tedious, but also very error-prone.
      </p>
      <p>The main contribution of this paper is a meta-tool called SERGe (SiDi Edit
Rule Generator) which generates a complete set of executable CPEOs for a given
meta-model. The generated sets of CPEOs can be integrated by tool developers
into an MDE environment as illustrated in Figure 1. In this example, a model
generator integrates the functionality of SERGe to initially generate a set of
CPEOs. Afterwards, the model generator algorithm can execute these CPEOs
to generate models. Moreover, the generated CPEOs comprise a common library
which can be reused by further tools, e.g., a model refactor tool.</p>
      <p>
        The generation process for a set of
CPEOs is fully automated and meta-model
independent. SERGe is based on EMF. The
generated CPEOs use EMF Henshin [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] as
the transformation language and require the
Henshin interpreter as the execution
platform. Henshin transformation rules are
inplace transformations and can contain model
patterns to be found and preserved, deleted Fig. 1. Deployment Diagram
showor created and also to be forbidden or re- ing SERGe and CPEO integration
quired. Some consistency criteria are already
enforced by EMF, e.g., type conformance,
guaranteeing at most one container for each model element or a consistent
handling of opposite references. With CPEOs generated by SERGe we can extend
this list by (a) the preservation of multiplicity constraints and (b) the prevention
of containment hierarchy cycles. The generated CPEO sets are complete in the
sense that any change between two consistent models can be expressed using
these CPEOs. These types of consistency constraints are su cient to be able to
graphically display models. We are not aware of an existing model editor which
is usable in combination with other EMF based MDE tools and which enforces
stronger consistency constraints. There can be more advanced constraints (i.e.,
OCL Constraints) inside a meta-model. However, they are typically not enforced
by model editors and thus are not covered with SERGe so far.
      </p>
      <p>
        SERGe provides a variety of optional con guration settings to tailor the
generation process, e.g., whether to generate CPEOs for supertypes instead of for
each subtype. The former will decrease the number of generated CPEOs
heavily. One can also enable or disable the kinds of CPEOs (create, move, etc.)
that should be generated. These are just a few con gurations that are possible.
SERGe has already been used extensively in di erent research projects, e.g., the
SMG (SiDi Model Generator) [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], SiLift [
        <xref ref-type="bibr" rid="ref10 ref6">6, 10</xref>
        ] for di erence recognition
between models and patching of models, and others [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Further possible use-cases
can be tools for merging, refactoring or checking of models. More information
and an example set of CPEOs can be found at the SERGe project website [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
      </p>
    </sec>
    <sec id="sec-2">
      <title>Consistency-preserving Edit Operations (CPEOs)</title>
      <p>The easiest way to modify the Abstract Syntax Graph (ASG) of a model is to use
basic graph operations e.g., creating or deleting single model objects. However,
basic ASG operations do not consider well-formedness rules (e.g., multiplicity
constraints) as de ned by the meta-model. Hence, they can lead to inconsistent
ASGs, which cannot be processed by other tools.</p>
      <p>As an example, we use simpli ed state machines with a meta-model as shown
in Figure 2(a). A StateMachine object must have at least one child object of type
Region, s. the multiplicity constraint of [1:: ] of the containment reference region.
A basic ASG operation which creates only a single StateMachine object violates
this constraint. A CPEO on the other hand will create a StateMachine object
together with a contained, mandatory child object of type Region.</p>
      <p>
        A CPEO usually comprises several basic ASG operations, but at least those
which are required to implement a consistency-preserving editing behavior.
Figure 2(b) shows the CPEO mentioned above as an EMF Henshin [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
transformation rule named 'createStatemachineInModel'. Another example is provided
in Figure 2(d). The example CPEO rule has a few input and output
parameters: e.g., Selected is a placeholder for an input model object which de nes the
context for the transformation application. Figure 2(d) depicts the changing of
an old targeted State object to a new target State in the context of a
Transition. This operation contains two ASG operations, notably the deletion of an
old reference target and the creation of a new reference target.
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Generation of CPEOs</title>
      <p>Prior to the generation phase, the meta-model is analyzed to identify the
relationships between classi ers. This is done by considering incoming references of
each classi er and the complete inheritance hierarchy. The source of a reference
can either be a parent context or a neighbor context. This depends on the
nature of a reference which is either containment in the rst or non-containment
in the latter case. Analogously, the target of a reference can either be
identied as a 'child' or a 'neighbor'. Naturally, opposite references (e.g., region and
stateMachine in the example) have to be considered together. Otherwise invalid
CPEOs could be generated. An invalid operation would be the change of the
reference target stateMachine without also changing its opposite, namely the
containment reference region</p>
      <p>Multiplicities of a reference (i.e., the upper bound (ub) and lower bound (lb))
are classi ed by one or more of the invariant groups shown in Figure 2(c). The
meta-model analysis categorizes each relationship by considering each
multiplicity invariant, which can be found on a reference. It determines if a target of a
reference needs mandatory objects. This is the case if the reference
multiplicity is classi ed as required. In a relationship between model elements, there can
also exist optional objects. This is the case if the reference is attached with a
many multiplicity classi cation. Naturally, these classi cations can both apply
(a) simple state machine meta-model
(b) CPEO 'createStateMachineInModel'
classi cation invariant group (lb ub)
required lb &gt; 0
bounded ub &lt; 1</p>
      <p>xed lb = ub
many (ub lb &gt;= 1) _ (ub = 1)
(c) multiplicity invariant classi
cation
(d) CPEO 'changeTransitionTargetToState'
to one reference, e.g., for [1:: ] (see Figure 2(a)). This identi cation allows the
generation algorithm to decide if a CPEO for the creation of an object may be
generated or if this creation may only happen in the context of another CPEO.</p>
      <p>During the generation phase every classi er in the given meta-model is
visited. By means of the previously analyzed relationships and attributes of each
considered classi er, SERGe determines which CPEO kinds will be generated
for which classi er, reference or attribute. The starting point for each
decision is the nature of a reference (i.e., being containment or noncontainment ). 1
The following CPEO kinds can be generated depending on the occurring
multiplicity invariants: creation/deletion of elements, adding/removing neighbors,
setting/unsetting/changing of single neighbors or (default) attribute values
or moving of children between di erent contexts. Mandatory children and
neighbors of elements are integrated recursively inside a CPEO.</p>
      <p>
        The generated CPEOs can also contain precondition checks to avoid falling
below required multiplicities or exceeding bounded multiplicities. This is realized
with Henshin Positive Application Conditions (PAC) and Negative Application
Conditions (NAC).
1 We assume attributes can be handled equally to non-containment references.
There are several approaches to generate executable edit operations for models
beyond basic ASG edit operations. The closest approaches to ours are [
        <xref ref-type="bibr" rid="ref1 ref3">1, 3</xref>
        ].
      </p>
      <p>
        Ehrig and Taenzer [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] address the problem to generate correct instances of
a given meta-model. In such a context, only edit operations which create model
elements are needed. Edit operations which delete or modify models are not
provided. The problem that mandatory components cannot be simply deleted, but
only be replaced, is not addressed here. The generated sets of edit operations
are thus not complete in our sense. Moreover, the nal result of the instance
generation process must conform to the meta-model; here intermediate and
inconsistent states can occur and need to be repaired afterwards. Our CPEOs on
the other hand never produce inconsistent intermediate states when applied; i.e.,
CPEOs preserve the consistency by-construction.
      </p>
      <p>
        Alanen and Porres [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] proposes to rst convert a model into a string
representation, then edit the model using a syntax-directed editor, and nally to convert
it back to an ASG-based representation. Although basic consistency constraints
can be preserved this way, this process is not very convenient, especially in the
case of visual models.
      </p>
      <p>To our best knowledge, the coverage of consistency constraints, con
gurability and completeness of the generated sets is not met by any other existing
meta-tool to generate edit operations.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Alanen</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ;
          <string-name>
            <surname>Porres</surname>
            ,
            <given-names>I.:</given-names>
          </string-name>
          <article-title>A relation between context-free grammars and meta object facility metamodels</article-title>
          ;
          <source>Technical Report 606</source>
          , TUCS Turku Center for Computer Science; 2003
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Arendt</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ;
          <string-name>
            <surname>Taentzer</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          :
          <article-title>A tool environment for quality assurance based on the Eclipse Modeling Framework</article-title>
          ; p.
          <fpage>141</fpage>
          -
          <lpage>184</lpage>
          <source>in: Automated Software Engineering</source>
          <volume>20</volume>
          (
          <issue>2</issue>
          );
          <fpage>2013</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Ehrig</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ; Kuster,
          <string-name>
            <given-names>J.M.</given-names>
            ;
            <surname>Taentzer</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          ;
          <article-title>Generating instance models from meta models</article-title>
          ; p.
          <fpage>479</fpage>
          -
          <lpage>500</lpage>
          <source>in: Software and Systems Modeling</source>
          <volume>8</volume>
          (
          <issue>4</issue>
          );
          <fpage>2009</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. EMF: Eclipse Modeling Framework;
          <year>2014</year>
          ; http://www.eclipse.org/emf;
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>EMF</given-names>
            <surname>Henshin</surname>
          </string-name>
          ;
          <year>2014</year>
          ; http://www.eclipse.org/modeling/emft/henshin/
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Kehrer</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ;
          <string-name>
            <surname>Kelter</surname>
            ,
            <given-names>U.</given-names>
          </string-name>
          ; Taentzer,
          <string-name>
            <surname>G.</surname>
          </string-name>
          :
          <article-title>Consistency-Preserving Edit Scripts in Model Versioning</article-title>
          ; p.
          <fpage>191</fpage>
          -
          <lpage>201</lpage>
          <source>in: Proc. 28th IEEE/ACM Intl. Conf. Automated Software Engineering (ASE</source>
          <year>2013</year>
          )
          <article-title>; 2013</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Kehrer</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ;
          <string-name>
            <surname>Rindt</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ;
          <string-name>
            <surname>Pietsch</surname>
            ,
            <given-names>P</given-names>
          </string-name>
          ; Kelter,
          <string-name>
            <surname>U.</surname>
          </string-name>
          :
          <article-title>Generating Edit Operations for Pro led</article-title>
          UML Models; p.
          <fpage>30</fpage>
          -
          <lpage>39</lpage>
          <source>in: Proc. Models and Evolution (ME</source>
          <year>2013</year>
          )
          <article-title>; 2013</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Pietsch</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ; Shariat Yazdi, H.; Kelter,
          <string-name>
            <surname>U.</surname>
          </string-name>
          :
          <source>Generating Realistic Test Models for Model Processing Tools</source>
          ; p.
          <fpage>620</fpage>
          -
          <lpage>623</lpage>
          <source>in: Proc. 26th IEEE &amp; ACM Inter. Conf. Automated Software Engineering (ASE</source>
          <year>2011</year>
          )
          <article-title>; ACM; 2011</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. SERGe; Project Page;
          <year>2014</year>
          ; http://pi.informatik.uni-siegen.de/Projekte/- SERGe.php
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>10. SiLift project website; http://pi.informatik.uni-siegen.de/Projekte/SiLift</mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11. Uni ed Modeling
          <source>Language: Superstructure, Version 2.4</source>
          .1; OMG, Doc. formal/2011-08-05;
          <fpage>2011</fpage>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>