Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Using Epsilon for model refinement/update
Using Epsilon for model refinement/update [message #926720] Fri, 28 September 2012 19:10 Go to next message
David Rees is currently offline David Rees
Messages: 47
Registered: September 2012
Member
I'm looking for a starting point to research the best way to use Epsilon for refining/updating models (and to verify Epsilon is the right tool in general). I would like to use it to transform between two very similar metamodels. One is Ecore from an XSD file and the 2nd is the Ecore I have manually cleaned up a bit around things like references ( I hope to eventually automate the metamodel transformation as well). Since the changes follow a semi-consistent pattern I want to just describe how they change rather than mapping all the ways they are the same.

For example, in XSL I would use something like this and just add rules for the changes.
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>


ATL 2010 calls this "Refining Mode" - http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#ATL_Refining_Mode.

For Epsilon, ETL seems the best choice, but I haven't found a concrete example of model refinement. I found the old thread pasted below that talks about using the "CommonEmfMetamodel transformation strategy" with ETL, but I can't find any additional information on it and the examples link in the thread is broken.

As long as we are discussing alternatives, do let me know if there is a better Epsilon choice than ETL. From what I can tell ETL is the right choice because: EWL is for manual changes, EOL might be an option according to the EWL chapter but ETL matching feels closer to what I need, and Flock actually seems interesting but I think its Type-focus might not be right for my use case.

Thanks,
dave

Dimitrios Kolovos wrote on Sun, 29 April 2007 11:57
Hi Laurent,

A transformation strategy can be attached to an ETL transformation (via
the Transformation Strategy tab or the respective API if you are running
from Java) to define how the transformation will handle input elements
for which the user has not specified an explicit transformation rule.

For example, the CommonEmfMetamodel transformation strategy, works very
similarly to the ATL "refine" mode: for each element of the source model
for which no transformation rule has been specified, it creates a copy
of the element in the target model. In case you need your transformation
to do something "slightly" different than the strategy you can also use
the "auto" keyword. You can find a working example of all these in the
OORefinement example available at:
http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.gmt /epsilon/examples/OORefinement/OORefinement.zip

ETL also provides an extension point which you can use to implement
custom transformation strategies (if you need more information about
this feature please let me know).

Cheers,
Dimitrios

Laurent Merlet wrote:
> Hi all,
>
> I'am trying to understand what is the aim of "transformations
> strategies"...
> I have already read the transformation strategies section of the online
> doc, but i don't see exactly what it consists of.
> Is it only for using ETL in Java ?
>
> If someone can explain it to me, I would be grateful.
>
> Best regards,
>
> Laurent MERLET
Re: Using Epsilon for model refinement/update [message #926728 is a reply to message #926720] Fri, 28 September 2012 19:20 Go to previous messageGo to next message
David Rees is currently offline David Rees
Messages: 47
Registered: September 2012
Member
Actually, if it helps here is a very simplified example before metamodel, before model and after metamodel. You will note I am essentially turning semantic key attributes (favoriteSiblingNref, favoriteChildNref) into refs (favoriteSibling, favoriteChild). The attribute transformation pattern is very similar across the entire metmodel, but do note at the model level it does depend on the class and the instance in question. For example favoriteSiblingNref is the name of a sibling of that Child instance (the name is only unique to the Parent document fragment). And favoriteChildNref is the name of one of that Parent's children.

Thanks,
dave

before metamodel
package relativefragment;
class Child {
  attr type.String[1] name;
  attr type.String[1] favoriteSiblingNref;
}
class Parent {
  attr type.String[1] name;
  attr type.String[1] favoriteChildNref;
  !resolve val Child[*] children;
}
class Root {
  !resolve val Parent[*] parents;
}


after metamodel
package relativefragmenthigh;;
class Child {
  attr type.String[1] name;
  ref Child[1] favoriteSibling;
}
class Parent {
  attr type.String[1] name;
  ref Child[1] favoriteChild;
  !resolve val Child[*] children;
}
class Root {
  !resolve val Parent[*] parents;
}


before model
<relativefragment:Root>
  <parents>
    <name>Glyn</name>
    <favoriteChildNref>Matt</favoriteChildNref>
    <children>
      <name>Matt</name>
      <favoriteSiblingNref>Dave</favoriteSiblingNref>
    </children>
    <children>
      <name>Dave</name>
      <favoriteSiblingNref>Matt</favoriteSiblingNref>
    </children>
  </parents>
  <parents>
    <name>Marriam</name>
    <favoriteChildNref>Matt</favoriteChildNref>
    <children>
      <name>Susie</name>
      <favoriteSiblingNref>Matt</favoriteSiblingNref>
    </children>
    <children>
      <name>Matt</name>
      <favoriteSiblingNref>Susie</favoriteSiblingNref>
    </children>
  </parents>
</relativefragment:Root>

Re: Using Epsilon for model refinement/update [message #927343 is a reply to message #926728] Sat, 29 September 2012 10:54 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 304
Registered: January 2010
Senior Member
If the source and target metamodels are quite similar, you may want to try out Flock instead. It's a specialized model transformation language for this particular case (model migration).

Please have a look at Chapter 10 of the Epsilon book. This particular example may also be useful:

http://www.eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.flock.petrinets
Re: Using Epsilon for model refinement/update [message #929559 is a reply to message #927343] Mon, 01 October 2012 11:07 Go to previous messageGo to next message
David Rees is currently offline David Rees
Messages: 47
Registered: September 2012
Member
Antonio Garcia-Dominguez wrote on Sat, 29 September 2012 10:54
If the source and target metamodels are quite similar, you may want to try out Flock instead. It's a specialized model transformation language for this particular case (model migration).

Please have a look at Chapter 10 of the Epsilon book. This particular example may also be useful:

http://www.eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.flock.petrinets


Thanks for the tip and link. I looked at it some more and it does seem like a good candidate. I specifically like how it supports multiple migration rules for the same type. For my specific case everything is so feature-specific I haven't decided if its the best fit or not, but I plan to try it out. It seems I can do a rule at Object with a guard for the features I am looking for. I just haven't decided if writing straight Java (or OML) against the Ecore APIs might be cleaner for my specific case. We will see :)...
Re: Using Epsilon for model refinement/update [message #938870 is a reply to message #929559] Wed, 10 October 2012 04:24 Go to previous message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 151
Registered: October 2009
Senior Member

David,

As Antonio mentioned Flock might be the right choice for your case. In the broader sense ETL is the transformation language in the Epsilon suite, and strictly speaking a model refinement is a model transformation. In general model transformations are seen as a process in which a set of transformation rules are applied to an input model and as a result you get an output model. However, and ETL in particular supports this, your input and output models can be the same model, i.e., you are not creating a new model but modifying or refining it. Or you can create a new output model, but at the same time modify your input model.

I know this is not a solution per se, but just wanted to let you know that there is much you can do with ETL.

Regards,


Horacio Hoyos Rodriguez
EngD Student
University Of York
Previous Topic:Unable to run an EGL file based on a UML model
Next Topic:[EGL] Can't get the type name of an operation
Goto Forum:
  


Current Time: Tue Jul 29 20:56:40 EDT 2014

Powered by FUDForum. Page generated in 0.01975 seconds