Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Edapt] BackwardConverter causes NP upon feature removal
[Edapt] BackwardConverter causes NP upon feature removal [message #1714342] Wed, 11 November 2015 22:36 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
I experience problems with the reconstruction of a model in case of an attribute removal. I have simply removed an attribute from my meta-model.

Now when I reconstruct a model from a prior version I get a NP exception:

java.lang.NullPointerException
	at org.eclipse.emf.ecore.impl.EClassImpl.getFeatureID(EClassImpl.java:1500)
	at org.eclipse.emf.ecore.impl.MinimalEStoreEObjectImpl.eDerivedStructuralFeatureID(MinimalEStoreEObjectImpl.java:264)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1068)
	at org.eclipse.emf.edapt.internal.migration.internal.BackwardConverter.initProperties(BackwardConverter.java:148)
	at org.eclipse.emf.edapt.internal.migration.internal.BackwardConverter.initProperties(BackwardConverter.java:117)
	at org.eclipse.emf.edapt.internal.migration.internal.BackwardConverter.convert(BackwardConverter.java:61)


And the reason is that the resolveFeature call in the code below (BackwardConverter) here does not find an attribute. And the call

eObject.eSet(targetFeature, element.get(sourceFeature));


gets executed on a null targetFeature. I have the feeling that it should be OK to find no feature in the target if it was removed for the target version.

final EStructuralFeature sourceFeature = slot.getEFeature();
			final EStructuralFeature targetFeature = resolveFeature(sourceFeature);
			if (ignore(sourceFeature)) {
				continue;
			}
			if (slot instanceof AttributeSlot) {
				if (sourceFeature.getEType() instanceof EEnum) {
					final AttributeSlot attributeSlot = (AttributeSlot) slot;
					if (sourceFeature.isMany()) {
						final EList values = (EList) eObject.eGet(targetFeature);
						for (final Object value : attributeSlot.getValues()) {
							values.add(resolveLiteral((EEnumLiteral) value));
						}
					} else {
						if (!attributeSlot.getValues().isEmpty()) {
							eObject.eSet(targetFeature,
								resolveLiteral((EEnumLiteral) attributeSlot
									.getValues().get(0)));
						}
					}
				} else {
					eObject.eSet(targetFeature, element.get(sourceFeature));
				}
			}


Could this be a bug or might I be doing something wrong?

Regards,
Thorsten
Re: [Edapt] BackwardConverter causes NP upon feature removal [message #1714388 is a reply to message #1714342] Thu, 12 November 2015 10:29 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
The above error occurs if I do not release the latest change. If I release, I get a DiagnosticException saying that the feature that I have removed is not a valid feature of the class. Which is actually true because it was removed. Does anybody have positive experience with removing features from a model?
Re: [Edapt] BackwardConverter causes NP upon feature removal [message #1714393 is a reply to message #1714388] Thu, 12 November 2015 10:55 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi Thorsten,

Try using the "Delete Feature" operation from the Edapt "Operation Browser" View. This should work.
If you are simply deleting it using the ecore editor only the metamodel can be updated correctly by Edapt. The model-instances still have values for the deleted feature, so they do not conform to the updated metamodel anymore. The Delete Feature operation also includes the required migration code for model-instances to remove the values.

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] BackwardConverter causes NP upon feature removal [message #1714417 is a reply to message #1714393] Thu, 12 November 2015 14:13 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Thanks a lot. It works.
Re: [Edapt] BackwardConverter causes NP upon feature removal [message #1714497 is a reply to message #1714417] Fri, 13 November 2015 08:45 Go to previous message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
No Message Body
Previous Topic:[EMFStore] LoginService
Next Topic:[Edapt] Flatten operations
Goto Forum:
  


Current Time: Thu Apr 25 10:22:40 GMT 2024

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

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

Back to the top