Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Edapt] XML parsing issue when migrating older model(createFromString() is called on EFactoryImpl not on MyModelFactoryImpl)
[Edapt] XML parsing issue when migrating older model [message #1790176] Wed, 06 June 2018 13:41 Go to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi all,

I am currently trying to use Edapt for my project. I applied my model changes via the history and made a release. I gave it a new ns like
.../myModel.ecore/1.1
, reloaded the genmodel and re-generated the model and edit code from the genmodel.

Next I implemented the code snippet from https://www.eclipse.org/edapt/libraryexample.php, Listing 3, into my editor.

When it calls
migrator.migrateAndLoad()
it correctly detects that the model needs to be migrated and start the migration. But then the XML produces a lot of errors like

...
Caused by: java.lang.IllegalArgumentException: The value '9.24976;9.2752;9.33836;9.3642;9.38996;9.41578;9.44151;9.49413;9.51994;9.54568;9.57144;9.5973;9.62304;9.66056;9.68629;9.71203;9.7378;9.76356;9.78928;9.85162;9.87743;9.90318;9.9289;9.95463;9.98048;10.00634;10.03122;10.05705;10.09294;10.11871;10.14454;10.17027;10.196;10.22181;10.24759;10.27344;10.29921;10.32507;10.35083;10.3767;10.40248;10.42834;10.4541;10.47995;10.50581;10.53154;10.55727;10.58301;10.60878;10.63456;10.66033;10.68615;10.71192;10.73769;10.76346;10.78928;10.81505;10.84078;10.86656;10.8923;10.91803;10.9438;10.96956;10.99543;11.02119;11.047;11.07277;11.09854;11.12431;11.15007;11.17589;11.20162;11.22746;11.25329;11.27906;11.30489;11.33062;11.35639;11.38215;11.40792;11.43365;11.45937;11.48522;11.51108;11.5369;11.56264;11.58841;11.61413;11.63986;11.6656;11.69141;11.71718' is invalid. 
	at org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFactoryImpl.java:470)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1615)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1156)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2692)


These numbers should be parsed and converted to a double array. The corresponding method is implemented in
MyModelFactoryImpl
and works on the previous model. However, for the migration code it seems that
createFromString()
is called on
EFactoryImpl
only.

Can someone help on that, please?

Thank and best regards,
Gernot.


Re: [Edapt] XML parsing issue when migrating older model [message #1790320 is a reply to message #1790176] Fri, 08 June 2018 11:10 Go to previous messageGo to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

I meanwhile found the documentation on how to deal with Custom EDataTypes (https://www.eclipse.org/edapt/customdatatypes.php).

I added the org.eclipse.emf.edapt.factories extension point to my plugin.xml. However, I am not able to add a factory to it. Right-click on the extension doesn't show the "New" menu to add a factory:

index.php/fa/33048/0/

Of course, I can add it to the plugin.xml via the text editor, but it doesn't change anything (i.e. factory is obviously not registered).
Also, clicking the link to the extension point schema causes an error message like: "extension point schema cannot be found".

Do I miss something?

Thanks and regards,
Gernot.





Re: [Edapt] XML parsing issue when migrating older model [message #1790462 is a reply to message #1790320] Mon, 11 June 2018 12:07 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 83
Registered: December 2013
Member

Hi,

Regarding the schema not found. This was a misconfiguration on Edapt side and I created the following bug to track this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=535758

This fix is now available in http://download.eclipse.org/edapt/p2/nightly

The factory feature was released with Edapt 1.2, so if you are using an older version in your runtime, please update Edapt.

Besides that, registering the factory using the text editor should actually work. I just updated https://www.eclipse.org/edapt/customdatatypes.php again to also set a value for useWildcards in Listing 1. So adding this explicitly might help.
If not, you can set breakpoints in org.eclipse.emf.edapt.internal.migration.internal.FactoryHelper to debug this. Here #readExtensionPoint() and #overrideFactory(EPackage) are especially interesting.

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] XML parsing issue when migrating older model [message #1790591 is a reply to message #1790462] Wed, 13 June 2018 10:19 Go to previous messageGo to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

Thanks for the update on this.

I meanwhile updated my edapt integration to 1.4.0. The extension is available now and I am able to register a factory.

When I re-run my project the IllegalArgumentException does not appear anymore. I therefore assume that the correct factory is used now.

However, I still remain with a FeatureNotFoundException that I already reported in my other post: [Edapt] Feature not found when migrating.

Thanks,
Gernot.
Re: [Edapt] XML parsing issue when migrating older model [message #1790913 is a reply to message #1790591] Wed, 20 June 2018 07:30 Go to previous messageGo to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

The parsing of my custom EDataType is still not running without exceptions.

I created a new class ModelFactoryImpl that extends EFactoryImpl and registered it as an Edapt factory at org.eclipse.emf.edapt.factories. The nsURI is set to the extension model's nsURI with the old version number (1.0). Wildcards=false.

In this model factory I have overwritten the createFromString() method. Whenever the eDataType equals a custom data type it triggers the proper conversion, otherwise it delegates to super.createFromString(). Interestingly, the eDataType.getClassifierID() does not match to the constants defined in the ModelPackage interface. In my case I have to add 28 to the ID, probably because the IDs 0-27 are defined in the base model. Do I have to reference the base model somewhere in my custom model factory?

However, the conversion of custom data type works. But then it throws a violation on the 'validContaiment' constrain. The affected classes are added to the model via a FeatureMap which is configured by extended meta data in the ecore model. When resource.load(options) in ResourceUtils is called the options map is empty. I guess it needs the EXTENDED_META_DATA=true option here to load the featureMap configuration. How can I add load options here?

I also tried to register the usual model factory as a second factory under the new model nsURI (version 1.1) but the validation error persists.

I appreciate any hint.
Thanks,
Gernot.
Re: [Edapt] XML parsing issue when migrating older model [message #1790998 is a reply to message #1790913] Thu, 21 June 2018 08:45 Go to previous messageGo to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

I was able to nail the problem down:

Actually, the load options will not stay empty. There will be a merge with the default load options which contain the EXTENDED_META_DATA=true flag. So this was not the problem.

The validation fails when it checks classes that are contained via a feature map in the ecore model. The containment check is done in the MigrationValidator.validate_validContainment() method:

index.php/fa/33193/0/

My model looks like this:

index.php/fa/33194/0/

The classes TestA, TestB, TestC have BaseTest as super type. The class TestRun has a bi-directional relation to BaseTest but no containment. The BaseTest - or better - the respective Test* classes are contained by class Experiment via a feature map.

When the valid containment check runs, i.e. TestA is passed as the instance. In line 278 the call instance.getReferences() returns all references from other classes to the TestA instance. Using the debugger I can see that all references from TestRun to TestA are returned. However, none of these is a containment.

Unfortunately, the (containment) reference from Experiment to TestA is not returned. Thus, since TestA is also not directly contained by a resource (lines 284-290) the method finally returns valid=false.

Obviously, the references from feature maps are not considered in this containment check. Bug or feature?

Thanks for your help.

Best regards,
Gernot.




Re: [Edapt] XML parsing issue when migrating older model [message #1791143 is a reply to message #1790998] Mon, 25 June 2018 06:50 Go to previous message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 83
Registered: December 2013
Member

Hi,

Please have a look at http://www.eclipse.org/edapt/customdatatypes.php last paragrah/Listing2:
Switching against the IDs does not work, because at this point we have dynamic instances of the Ecores. The IDs of those in-memory Ecores are not guaranteed to be the same as in the generated code.
Therefore, we suggest to switch against the Name of the EDataType (if required you can also inspect the Datatypes' EPackage). This is safer than to check against 28.

Regarding Feature Maps. Unfortunately those are currently not supported by Edapt: https://www.eclipse.org/forums/index.php/t/366636/
We are happy to accept a contribution for adding this feature or alternatively you can hire us to do it for you :)

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:[EEF] Trouble getting custom properties view to update model
Next Topic:[EMFForms] Get label + control from view model elements as SWT control?
Goto Forum:
  


Current Time: Sat Nov 17 07:33:29 GMT 2018

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

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

Back to the top