Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Model Migration(References of models are not migrated within model migration)
Model Migration [message #1250862] Wed, 19 February 2014 17:22 Go to next message
Bhushan Patil is currently offline Bhushan PatilFriend
Messages: 10
Registered: February 2014
Junior Member
Hi,

I have one project in which there are two models- Model A and Model B.
Model A is referring Model B.(Example- Model A uses segment "TEST" which is present in Model B.)
Then I transformed these models from one form to another form using model to model transformation. And those got transformed successfully.(Model A and Model B are migrated from one form to another form.)
However,
(Model A uses segment "TEST" from Model B) - references of segment "TEST" (which is present in Model B) is not updated in Model A after transformation.
So, do I need to do something additional to resolve this issue?
Please suggest.

Thanks in advance.
Re: Model Migration [message #1250917 is a reply to message #1250862] Wed, 19 February 2014 18:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Bhushan,

Comments below.

On 19/02/2014 7:07 PM, Bhushan Patil wrote:
> Hi,
>
> I have one project in which there are two models- Model A and Model B.
> Model A is referring Model B.(Example- Model A uses segment "TEST"
> which is present in Model B.)
What do you mean bu uses segment "TEST"?
> Then I transformed these models from one form to another form using
> model to model transformation. And those got transformed
> successfully.(Model A and Model B are migrated from one form to
> another form.)
And serialized somehow...
> However,
> (Model A uses segment "TEST" from Model B) - references of segment
> "TEST" (which is present in Model B) is not updated in Model A after
> transformation.
The URI references you see in the serialization always reflect the URI
of the referenced resource at the time the serialization was produced.
> So, do I need to do something additional to resolve this issue?
It's not clear what the issue is, but if you're serializing the
transformed resources to a new location, be sure to change the URI of
both resources before saving either.
> Please suggest.
>
> Thanks in advance.
Re: Model Migration [message #1251527 is a reply to message #1250917] Thu, 20 February 2014 10:05 Go to previous messageGo to next message
Bhushan Patil is currently offline Bhushan PatilFriend
Messages: 10
Registered: February 2014
Junior Member
Hi Ed,

Thanks for your reply.
What do you mean by uses segment "TEST"?
--> I mean - Model A refers to element "TEST" which is present in Model B.
The issue is -
When Model A and Model B are transformed from one form to another form, the location of element "TEST" in Model B gets changed.
But Model A still refers to OLD location of element "TEST" (which is not available in Model B after transformation.)
Please suggest - what should do I need to do to resolve this issue?

Thanks.
Re: Model Migration [message #1251579 is a reply to message #1251527] Thu, 20 February 2014 11:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Bhushan,

Comment below.

On 20/02/2014 11:05 AM, Bhushan Patil wrote:
> Hi Ed,
>
> Thanks for your reply.
> What do you mean by uses segment "TEST"?
> --> I mean - Model A refers to element "TEST" which is present in
> Model B.
> The issue is - When Model A and Model B are transformed from one form
> to another form, the location of element "TEST" in Model B gets changed.
> But Model A still refers to OLD location of element "TEST" (which is
> not available in Model B after transformation.)
What does model A refer to in memory at the time it's serialized?
> Please suggest - what should do I need to do to resolve this issue?
It's a question of what A is referring to at the time it's serialized
and what the URI of the referenced resource is at that time. But I can
know nothing about that from what you've said.
>
> Thanks.
Re: Model Migration [message #1252653 is a reply to message #1251579] Fri, 21 February 2014 12:59 Go to previous messageGo to next message
Bhushan Patil is currently offline Bhushan PatilFriend
Messages: 10
Registered: February 2014
Junior Member
Hi Ed,

I have two models - Model-A and Model-B with specific meta-models structure. Model-A contain one element ElementTypeA and Model-B contains another element ElementTypeB.
ElementTypeB has some attributes one of which (is of type ElementTypeA) "refer" to ElementTypeA. This means Model-B is referring Model-A.
If I open Model-B using text editor then I can see this relationship (relative href is used for referencing)

Now my meta-model has got changed. So I have transformed Model-A and Model-B from OLD meta-models structure to NEW meta-models structure using model to model transformation (QVTo).

My assumption is if I open both these models and invoke a QVTo (models passed as inout params) to perform "model-migration" EMF should appropriately take care of reference changes.

Following code will give better idea of how I am opening models.

// open Model-A using resourceset

private EList<EObject> getResourceObjects(final IFile file) {
ResourceSet resourceSet = new ResourceSetImpl();
URI resourceUri = URI.createPlatformResourceURI(file.getFullPath()
.toString(), false);
return resourceSet.getResource(resourceUri.trimFragment(), true)
.getContents();
}

// open Model-B using resourceset

same as above just pass path of Model-B

// perform transformation

transformation UpdateModels(inout model:ModelAorB);

// save Model-B and Model-A one after the other

ResourceSet resourceSet = new ResourceSetImpl();
for (EObject eObj : outObjects) {
Resource targetResource = resourceSet
.createResource(file.getFullPath());
targetResource.getContents().add(eObj);
}

List<Resource> resList = resourceSet.getResources();

for (Resource res : resList){
res.save(Collections.EMPTY_MAP);
}

But in reality this is not working and references are not getting resolved properly. So when I open Model-B and expect that it is referring to Model-A appropriate element - its not the case. Sad
Re: Model Migration [message #1252834 is a reply to message #1252653] Fri, 21 February 2014 16:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Bhushan,

Comments below.

On 21/02/2014 1:59 PM, Bhushan Patil wrote:
> Hi Ed,
>
> I have two models - Model-A and Model-B with specific meta-models
> structure. Model-A contain one element ElementTypeA and Model-B
> contains another element ElementTypeB. ElementTypeB has some
> attributes one of which (is of type ElementTypeA) "refer" to
> ElementTypeA. This means Model-B is referring Model-A.
> If I open Model-B using text editor then I can see this relationship
> (relative href is used for referencing)
>
> Now my meta-model has got changed. So I have transformed Model-A and
> Model-B from OLD meta-models structure to NEW meta-models structure
> using model to model transformation (QVTo).
So you transformed tw
>
> My assumption is if I open both these models and invoke a QVTo (models
> passed as inout params) to perform "model-migration" EMF should
> appropriately take care of reference changes.
>
> Following code will give better idea of how I am opening models.
>
> // open Model-A using resourceset
>
> private EList<EObject> getResourceObjects(final IFile file) {
> ResourceSet resourceSet = new ResourceSetImpl();
> URI resourceUri = URI.createPlatformResourceURI(file.getFullPath()
> toString(), false);
> return resourceSet.getResource(resourceUri.trimFragment(), true)
> getContents();
> }
>
> // open Model-B using resourceset
>
> same as above just pass path of Model-B
But not using the same resource set. That seems like a bad idea,
especially if you plan to transform both A and B.
>
> // perform transformation
>
> transformation UpdateModels(inout model:ModelAorB);
So A and B are in different resource sets so model B will be referring
to a different copy of A than the one you are transforming.
>
> // save Model-B and Model-A one after the other
>
> ResourceSet resourceSet = new ResourceSetImpl();
> for (EObject eObj : outObjects) { Resource targetResource = resourceSet
> createResource(file.getFullPath());
> targetResource.getContents().add(eObj);
You're creating more than one resource with the same URI?
> }
>
> List<Resource> resList = resourceSet.getResources();
>
> for (Resource res : resList){
> res.save(Collections.EMPTY_MAP);
> }
>
> But in reality this is not working and references are not getting
> resolved properly.
No doubt because the transformed B refers to the untransformed A that's
in B's resource set.
> So when I open Model-B and expect that it is referring to Model-A
> appropriate element - its not the case. :(
If you used the debugger wisely, you'd have noticed that B is referring
to a different A than the one you transformed.
Previous Topic:[CDO] disable commit info.
Next Topic:EMF Compare FeatureNotFoundException
Goto Forum:
  


Current Time: Thu Dec 12 23:07:03 GMT 2019

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

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

Back to the top