Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ecore2ecore: can i control the mapping?(how to control mapping between 3 or more ecores)
ecore2ecore: can i control the mapping? [message #492588] Tue, 20 October 2009 22:11 Go to next message
peter barry is currently offline peter barryFriend
Messages: 6
Registered: October 2009
Junior Member
Hi,

I have been looking at ecore2ecore and how i could use it to migrate my ecores.
I have been successful using the recipe to migrate between 2 ecores for example a simple name change of an attribute.

my problem/issue is around the following requirement i would like to have in our products migration strategy ...

When we release version 2 of our tool we can define a migration of model v1 to model v2.
When we release version 3 of our tool I would like to define a migration of model v2 to model v3.

therefore if tool version 3 opens model v1 i would like it to go through the model v1 to model v2 migration and then send the result of this through the model v2 to model v3 migration

this reduces combinations of migration between versions and we only need to test the final migration as the other migrations would have been tested in previous version releases.

also an extra requirement is that when i migrate from v1 to v3 i need to migrate the v3 to v1 and compare the two v1 models. If they are the same then i can continue with the migrated v1 project.

so my question is - can ecore2ecore allow this? I have been looking at the resource loading code and i dont think it does but I could def be wrong Smile

another question also - if my model uses hrefs etc to link to objects in diff resources are there any problems in ecore2ecore with migrating these different resources also?

I have been thinking of usin xslt etc to transform the xmi but thats not exactly at the model level.
also looking into qvt - but i think this is in incubation so i'm not sure if our product can depend on it.

anyway a lot of text there!
thanks in advance!
-peter
Re: ecore2ecore: can i control the mapping? [message #492628 is a reply to message #492588] Wed, 21 October 2009 07:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Peter,

Comments below.


peter barry wrote:
> Hi,
>
> I have been looking at ecore2ecore and how i could use it to migrate
> my ecores.
> I have been successful using the recipe to migrate between 2 ecores
> for example a simple name change of an attribute.
>
> my problem/issue is around the following requirement i would like to
> have in our products migration strategy ...
>
> When we release version 2 of our tool we can define a migration of
> model v1 to model v2.
> When we release version 3 of our tool I would like to define a
> migration of model v2 to model v3.
>
> therefore if tool version 3 opens model v1 i would like it to go
> through the model v1 to model v2 migration and then send the result of
> this through the model v2 to model v3 migration
>
> this reduces combinations of migration between versions and we only
> need to test the final migration as the other migrations would have
> been tested in previous version releases.
That makes sense, though it sounds less efficient.
>
> also an extra requirement is that when i migrate from v1 to v3 i need
> to migrate the v3 to v1 and compare the two v1 models. If they are the
> same then i can continue with the migrated v1 project.
You're trying to ensure it's a non-lossy transformation...
>
> so my question is - can ecore2ecore allow this? I have been looking at
> the resource loading code and i dont think it does but I could def be
> wrong :)
Certainly it's not set up to behave this way "out of the box". A
serialization is read in, and the mapping is used to determine what
ultimately should be built. You'd need to change it to apply a chain of
mappings instead.
>
> another question also - if my model uses hrefs etc to link to objects
> in diff resources are there any problems in ecore2ecore with migrating
> these different resources also?
It's important that the URIs for those references continue to resolve
properly, e.g., if you use IDs, the IDs have to be the same in each version.
>
> I have been thinking of usin xslt etc to transform the xmi but thats
> not exactly at the model level.
> also looking into qvt - but i think this is in incubation so i'm not
> sure if our product can depend on it.
I think QVT is pretty solid at this point. ATL has also been around a
great many years and is well used.
>
> anyway a lot of text there!
Of course you'd be best off to make only binary compatible changes from
release to release so that no migration is involved. That's what we've
done with Ecore; we even added generics without breaking the older
serialization format (and ensured that when you don't use generics, we
still produce the older serialization format).
> thanks in advance!
> -peter


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ecore2ecore: can i control the mapping? [message #492650 is a reply to message #492628] Wed, 21 October 2009 09:10 Go to previous messageGo to next message
peter barry is currently offline peter barryFriend
Messages: 6
Registered: October 2009
Junior Member
hi ed, thanks for your reply

your comments

"Of course you'd be best off to make only binary compatible changes from
release to release so that no migration is involved. That's what we've
done with Ecore; we even added generics without breaking the older
serialization format (and ensured that when you don't use generics, we
still produce the older serialization format)."

correct me if i am wrong but is this what you mean -

if a model needs to change then keep legacy data in the new version of the model so that older model data can still be serialised? does the nsUri of the new model then stay the same as the old model so that there are no difficulties in finding the correct package for the old model?

when you mention what you've done for ecore, do you mean that when you released the new version of ecore (emf?) you handled the model changes such that models using an older version of emf would still work with the new version of emf?

can you explain a bit more on how you managed this, or even point me to the relevant code in the emf code base?

thanks again!
-peter
Re: ecore2ecore: can i control the mapping? [message #492656 is a reply to message #492650] Wed, 21 October 2009 09:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050304020701000104090204
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Peter,

Comments below.

peter barry wrote:
> hi ed, thanks for your reply
>
> your comments
>
> "Of course you'd be best off to make only binary compatible changes from
> release to release so that no migration is involved. That's what we've
> done with Ecore; we even added generics without breaking the older
> serialization format (and ensured that when you don't use generics, we
> still produce the older serialization format)."
>
> correct me if i am wrong but is this what you mean -
> if a model needs to change then keep legacy data in the new version of
> the model so that older model data can still be serialised?
Yes.
> does the nsUri of the new model then stay the same as the old model so
> that there are no difficulties in finding the correct package for the
> old model?
Yes, that's what we've done.
>
> when you mention what you've done for ecore, do you mean that when you
> released the new version of ecore (emf?) you handled the model changes
> such that models using an older version of emf would still work with
> the new version of emf?
Exactly. We added a lot of stuff in EMF 2.3 to support Java-style
generics without breaking the serialization. E.g., all the containment
references eGenericAbc where added to augment eAbc references. Reading
the old references automatically populates the newer containment
references and the serialization relies on unsettable feature behavior
to insure that the older features are serialized when no actual use if
made of generics. So generally the idea is don't ever remove anything
from your model. Only deprecate them and ensure that setting such
feature's values automatically migrates the data. You might make such a
feature transient so it's never saved again.
>
> can you explain a bit more on how you managed this, or even point me
> to the relevant code in the emf code base?
Have a look at the getters and setters in ETypedElementImpl for eType
and eGenericType.

This option is useful too:

/**
* This options allows you to record unknown features during
deserialization/loading.
* The default is <code>Boolean.FALSE</code> unless set to
<code>Boolean.TRUE</code> explicitly.
* The unknown features and their values can be accessed via
getEObjectToExtensionMap().
* @see #getEObjectToExtensionMap()
*/
String OPTION_RECORD_UNKNOWN_FEATURE = "RECORD_UNKNOWN_FEATURE";

It can even allow your v1 software to read v3 versions of the model and
have it write back out the v3 data on save...
>
> thanks again!
> -peter

--------------050304020701000104090204
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Peter,<br>
<br>
Comments below.<br>
<br>
peter barry wrote:
<blockquote cite="mid:hbmj70$cmc$1@build.eclipse.org" type="cite">hi
ed, thanks for your reply
<br>
<br>
your comments
<br>
<br>
"Of course you'd be best off to make only binary compatible changes
from
<br>
release to release so that no migration is involved. That's what we've
<br>
done with Ecore; we even added generics without breaking the older
<br>
serialization format (and ensured that when you don't use generics, we
<br>
still produce the older serialization format)."
<br>
<br>
correct me if i am wrong but is this what you mean - <br>
if a model needs to change then keep legacy data in the new version of
the model so that older model data can still be serialised? </blockquote>
Yes.<br>
<blockquote cite="mid:hbmj70$cmc$1@build.eclipse.org" type="cite">does
the nsUri of the new model then stay the same as the old model so that
there are no difficulties in finding the correct package for the old
model?
<br>
</blockquote>
Yes, that's what we've done. <br>
<blockquote cite="mid:hbmj70$cmc$1@build.eclipse.org" type="cite"><br>
when you mention what you've done for ecore, do you mean that when you
released the new version of ecore (emf?) you handled the model changes
such that models using an older version of emf would still work with
the new version of emf?
<br>
</blockquote>
Exactly.  We added a lot of stuff in EMF 2.3 to support Java-style
generics without breaking the serialization.  E.g., all the containment
references eGenericAbc where added to augment eAbc references.  Reading
the old references automatically populates the newer containment
references and the serialization relies on unsettable feature behavior
to insure that the older features are serialized when no actual use if
made of generics.   So generally the idea is don't ever remove anything
from your model.  Only deprecate them and ensure that setting such
feature's values automatically migrates the data.  You might make such
a feature transient so it's never saved again. <br>
<blockquote cite="mid:hbmj70$cmc$1@build.eclipse.org" type="cite"><br>
can you explain a bit more on how you managed this, or even point me to
the relevant code in the emf code base?
<br>
</blockquote>
Have a look at the getters and setters in ETypedElementImpl for eType
and eGenericType.<br>
<br>
This option is useful too:<br>
<blockquote>  /**<br>
   * This options allows you to record unknown features during
deserialization/loading.<br>
   * The default is &lt;code&gt;Boolean.FALSE&lt;/code&gt; unless set
to &lt;code&gt;Boolean.TRUE&lt;/code&gt; explicitly. <br>
   * The unknown features and their values can be accessed via
getEObjectToExtensionMap().<br>
   * @see #getEObjectToExtensionMap()  <br>
   */<br>
  String OPTION_RECORD_UNKNOWN_FEATURE = "RECORD_UNKNOWN_FEATURE";<br>
</blockquote>
It can even allow your v1 software to read v3 versions of the model and
have it write back out the v3 data on save...<br>
<blockquote cite="mid:hbmj70$cmc$1@build.eclipse.org" type="cite"><br>
thanks again!
<br>
-peter
<br>
</blockquote>
</body>
</html>

--------------050304020701000104090204--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ecore2ecore: can i control the mapping? [message #492686 is a reply to message #492656] Wed, 21 October 2009 12:03 Go to previous messageGo to next message
peter barry is currently offline peter barryFriend
Messages: 6
Registered: October 2009
Junior Member
hi ed,

what was the main reason for you to decide on this approach?
when you look at the literature on migrating ecores it generally mentions that you should bear in mind the future migration of the model, therefore naming the nsURI appropriately.

for you was it the need to make your customers move to 2.3 etc as painless as possible or were there other reasons?

thanks for your help
-peter
Re: ecore2ecore: can i control the mapping? [message #492688 is a reply to message #492686] Wed, 21 October 2009 12:08 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Peter,

Comments below.

peter barry wrote:
> hi ed,
>
> what was the main reason for you to decide on this approach?
It seemed by far the least disruptive to the clients and to the other
tools downstream from Ecore.
> when you look at the literature on migrating ecores it generally
> mentions that you should bear in mind the future migration of the
> model, therefore naming the nsURI appropriately.
We did include a year in the nsUR so we could change it in the future.
>
> for you was it the need to make your customers move to 2.3 etc as
> painless as possible or were there other reasons?
Yes people complain a lot when there's a little bit of pain. I
considered a major accomplishment that I was able to add generics to
Ecore without anyone at IBM complaining about being adversely impacted,
i.e., needing to lift a finger...
>
> thanks for your help
> -peter


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Eopposite
Next Topic:Alternative to emf?
Goto Forum:
  


Current Time: Wed Apr 24 17:35:35 GMT 2024

Powered by FUDForum. Page generated in 0.03687 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top