Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Edapt doesn't do specialize reference type while ecore migration changes(Edapt doesn't do specialize reference type while ecore migration changes)
Edapt doesn't do specialize reference type while ecore migration changes [message #1802396] Fri, 08 February 2019 06:00 Go to next message
Arun Kumar is currently offline Arun KumarFriend
Messages: 14
Registered: January 2016
Junior Member
I am new to custom edapt migration operation and trying to adapt the edapt migration for below ecore model changes.

I have attribute in one of the Eclass which has the reference to eclass "mapElementClass". Now, my ecore change is that, I made mapElementClass as abstract and created two more sub-class named "mapElementSubClass1" and "mapElementSubClass2" respectively.

I am trying to migrate this model changes with custom migration, and I am performing
  instance.migrate("ecoreName.mapElementSubClass1"); 
. After migration performing, in my file, nothing got changed , when I load the file, attribute is vanishing since it still points to abstract class. Hence, I add to manually make below manual changes on that reference element to make it work properly.
  
xsi:type="com.xxx.yyy.zzz.mapElementSubClass1"   



How to make this migration correct? Even, I tried to create 'specialize reference type ' via edapt operation and still it is not working.

MetaModel changes:
  <eClassifiers xsi:type="ecore:EClass" name="MappingObjectClass" eSuperTypes="#//SomeClass">
....
    <eStructuralFeatures xsi:type="ecore:EReference" name="attrElement" lowerBound="1"
        eType="#//mapElementClass"/>
  </eClassifiers>

== Added two sub-type class. This is the model changes == 
<eClassifiers xsi:type="ecore:EClass" name="mapElementSubClass1" eSuperTypes="#//mapElementClass">
.... <some attribute definition>
  </eClassifiers>

<eClassifiers xsi:type="ecore:EClass" name="mapElementSubClass2" eSuperTypes="#//mapElementClass">
.... <some attribute definition>
  </eClassifiers>



I might be doing something wrong here. I get struck at this point and any help would be appreciated.
Re: Edapt doesn't do specialize reference type while ecore migration changes [message #1802405 is a reply to message #1802396] Fri, 08 February 2019 10:39 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi,

If I understand you correctly you want to map all existing mapElementClass-instances in the existing model to mapElementSubClass1? So you don't need to decide whether they should become mapElementSubClass1 or mapElementSubClass2?

So the easiest way starting from your old model is:
Create mapElementSubClass1 and mapElementSubClass2 as subclasses of mapElementClass using the "Create Class" operation from the operation browser.
Now select mapElementClass in and chose the "Make Class Abstract"-Operation and chose mapElementSubClass1 as a subclass in the parameters tab. This will replace existing instances with elements of the chosen subclass.

Cheers,
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Edapt doesn't do specialize reference type while ecore migration changes [message #1802511 is a reply to message #1802405] Mon, 11 February 2019 09:12 Go to previous messageGo to next message
Arun Kumar is currently offline Arun KumarFriend
Messages: 14
Registered: January 2016
Junior Member
Thanks Johannes. I was looking for this operation "Now select mapElementClass in and chose the "Make Class Abstract"-Operation and chose mapElementSubClass1 as a subclass in the parameters tab. This will replace existing instances with elements of the chosen subclass. "

I wasn't aware of that operation as I usually let edpat to track the changes of ecore. Thanks a lot. It worked what I expected.

Just for curiosity to know , What if I want to make decision between two subclass ? I tried custom migration and it didn't work out since the content are not available on same file and I have only proxy element to it
Re: Edapt doesn't do specialize reference type while ecore migration changes [message #1802575 is a reply to message #1802511] Tue, 12 February 2019 08:49 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 111
Registered: September 2016
Senior Member
Hi,

Johannes is currently out of office, he will get back to you next week.

best regards,
Jonas


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Edapt doesn't do specialize reference type while ecore migration changes [message #1802868 is a reply to message #1802511] Mon, 18 February 2019 11:01 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi,

Actually a custom migration should work as follows.

Create the Subclasses as above. Instead of using the Make-Abstract-Operation, make the class abstract in the ecore editor. Then in the history, right click to recorded change -> Edapt -> Attach Custom Migration to Changes.
In the custom migration in migrateAfter (i.e, the MapElementClass is abstract now) use the Instance#migrate method after identifying which EClass to use.

public class MyCustomMigration extends CustomMigration {

	@Override
	public void migrateAfter(Model model, Metamodel metamodel) throws MigrationException {
		model.getAllInstances("packageName.MapElementClass")// get all old instances
			.forEach(i -> i.migrate(findOutWhichSubClassToUse(i, metamodel)));
	}

	private EClass findOutWhichSubClassToUse(Instance i, Metamodel metamodel) {
		// decide which subclass to use
		return metamodel.getEClass("packageName.MapElementSubClass1"); //$NON-NLS-1$
	}
}


Cheers,
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Edapt doesn't do specialize reference type while ecore migration changes [message #1803349 is a reply to message #1802868] Wed, 27 February 2019 09:20 Go to previous message
Arun Kumar is currently offline Arun KumarFriend
Messages: 14
Registered: January 2016
Junior Member
Thanks Johannes.

Custom migration worked when I have content present in same file. But, It didn't get succeed when I have content spread out in different files and having proxy to the reference container. I am not sure what I am missing.

Since, I am pointing to same sub-class , Edapt operation worked like champ irrespective of content in same/different file. Thanks for your help.

[Updated on: Wed, 27 February 2019 09:21]

Report message to a moderator

Previous Topic:[EDAPT] Edapt in a Spring application
Next Topic:Unable to update the URI fragment of proxy element on Edapt Migration
Goto Forum:
  


Current Time: Fri Mar 29 10:38:43 GMT 2024

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

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

Back to the top