Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Edapt] Can't migrate model after referenced model is migrated?
[Edapt] Can't migrate model after referenced model is migrated? [message #1757503] Sun, 19 March 2017 18:58 Go to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 10
Registered: March 2017
Junior Member
I have multiple models generated from the same ecore metamodel and the models reference each other

Example:
mymodel.ecore ---> mymodel1, mymodel2
mymodel2 references mymodel1

When using Edapt to migrate the models. If I migrate mymodel1 before attempting to migrate mymodel2 then mymodel2 migration fails with the following errors (only the first line of the trace provided for readability):

org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri '{model uri}/1.9' not found. (platform:/resource/aa/{model 2}, 2, 241)

org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'Package' is not found or is abstract. (platform:/resource/aa/{model 2}, 2, 241)

I've found that if I migrate mymodel2 first then it will work and mymodel1 will also be migrated correctly as a side effect.

The problem is that since I have multiple models that reference mymodel1 after migrating mymodel2 all subsequent migrations fail. I can work around this issue by replacing mymodel1 with an older version before I migrate each model that references it but this becomes really annoying and not a good experience to the customers who have their own models that reference the mymodel1 we provide.

Is there a recommended method for handling this situation?

I did a forum search but couldn't find anything that seemed to answer my question. I'm fairly new to Edapt and EMF so any help would be appreciated.
Re: [Edapt] Can't migrate model after referenced model is migrated? [message #1757919 is a reply to message #1757503] Tue, 21 March 2017 20:15 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 70
Registered: December 2013
Member
Hi,
Unfortunately this is a conceptional problem, for which I see only two options:
a) Migrate all files you have at the same time. The Migrator offers you the possibility to hand in multiple URIs for this purpose. If this is not possible, you have to go with
b) Establishing a process for keeping the old models for the migration process in your business code. It is hard to give advice here, but you can use the ReleaseUtils namespace URI methods to find out the version of the source models and then trigger the migration after copying the correct mymodel1 version. I know that this is not nice, but as soon as only a part of your models are migrated and they have links between each other, it is an invalid state.
Regards
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] Can't migrate model after referenced model is migrated? [message #1758740 is a reply to message #1757919] Sat, 01 April 2017 14:34 Go to previous messageGo to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 10
Registered: March 2017
Junior Member
Thanks for your reply! Sorry it took me so long to respond. I am now trying to get back to this.

It seems like I'll have to go with option b. We control model1 but there are models that reference model1 that exist outside of our control so we wouldn't be able migrate all models at the same time. Let me see if I understand your suggestion properly:

If I have a folder structure like this:

+ base_models
++ model1 v1

+ derived_models
++ model2 v1 --> base_models\model1 v1
++ model3 v1 --> base_models\model1 v1


Currently, when I migrate model2 from v1 to v2 I end up with:

+ base_models
++ model1 v2

+ derived_models
++ model2 v2 --> base_models\model1 v2
++ model3 v1 --> base_models\model1 v1

Then when I try to migrate model3, it can't find base_models/model1 v1 and migration fails.


If I had something like:

+ old_models
++ model1 v1

+ base_models
++ model1 v1

+ derived_models
++ model2 v1 --> base_models\model1 v1
++ model3 v1 --> base_models\model1 v1

When I migrate model2 from v1 to v2 I end up with:

+ old_models
++ model1 v1

+ base_models
++ model1 v2

+ derived_models
++ model2 v2 --> base_models\model1 v2
++ model3 v1 --> base_models\model1 v1

Then when I try to migrate model3, I can see that model3 depends on model1 v1 and copy model1 v1 from old_models into base_models before performing the migration of model3?

Is that right?

Not as clean as I'd like but only because I'd constantly be migrating model1. However, I can see where model1 and model2 would need to migrate at the same time since there may be changes to model1 that occur during migration that affects model2.

Keeping the old models around doesn't sound like too big of a deal. If size becomes an issue, I think all I need to do is really keep version 1 around since the migrator can migrate from v1 to any other version at the cost of migration time. I think I've shown that all I need is a version of model1 that is equal to or less than the version model2 depends on to have migration work.

I think this is probably my best bet.

I think I'm also going to try to prompt the user to migrate all models they have at the same time to reduce the number of "do you want to migrate" prompts and reduce the number of times I need to copy over the old model(s).

[Updated on: Sat, 01 April 2017 14:35]

Report message to a moderator

Re: [Edapt] Can't migrate model after referenced model is migrated? [message #1758747 is a reply to message #1758740] Sat, 01 April 2017 16:12 Go to previous messageGo to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 10
Registered: March 2017
Junior Member
How can a list of all the referenced models before I perform the migration?

I tried loading the resource and then using EcoreUtil.resolveAll but that failed; which makes sense because the metamodel has changed so the existing model can't be opened.

I need to know what models are being referenced so I can copy over the correct older versions. Also, I would like to show the user a list of the referenced models that will also be migrated if they continue.

[Updated on: Sat, 01 April 2017 16:20]

Report message to a moderator

Re: [Edapt] Can't migrate model after referenced model is migrated? [message #1758928 is a reply to message #1758747] Tue, 04 April 2017 16:49 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 70
Registered: December 2013
Member
Hi,

the idea is to use the migrator.migrateAndLoad method. This will give you a resource set. If the file passed to the migrator references other files, they will be migrated and there will be dedicated resources for the referenced files in the resource set. Also the URIs of these resources point to original files.

So after migrating you may loop over all resources in the set, look at the URI, and save them at a new location as required. You don't need to find out before the migration.

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] Can't migrate model after referenced model is migrated? [message #1770913 is a reply to message #1758928] Fri, 18 August 2017 17:10 Go to previous messageGo to next message
Bestoon Jaff is currently offline Bestoon JaffFriend
Messages: 7
Registered: August 2017
Junior Member
Hi Johannes Faltermeier,

I'm new to EMF and EDapt, and I'm struggling with using EDapt to automate ecore model migrations. I followed the library tutorial provided by the people who currently maintain EDapt project, but I found it difficult to understand the Migrator Section of that tutorial. Now I know how to create a history and record all the modifications I want to perform on the original metamodel using the existing reusable operations, but I don't know how to register the history using the migration extension point and how and where to add the history plugin?

Could you please guide me to use EDapt successfully? As I'm totally novice to EDapt, any help is much appreciated.


Thanks for your reply,

Bestoon Jaff
Re: [Edapt] Can't migrate model after referenced model is migrated? [message #1774360 is a reply to message #1770913] Fri, 13 October 2017 09:31 Go to previous message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 70
Registered: December 2013
Member
See https://www.eclipse.org/forums/index.php?t=msg&th=368118&goto=1770952&#msg_1770952 ff. for an answer. Please post questions only once.

Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:Path through an EMF graph
Next Topic:[Edapt] Strange behavior in Classifiers ID
Goto Forum:
  


Current Time: Mon Jan 22 12:45:55 GMT 2018

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

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