[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Ecore2Ecore data migration when reference's type is removed

Louis,

Comments below.

Louis Rose wrote:
Hi all,

I'm trying to use an Ecore2Ecore mapping to perform data migration as per the EMF Recipe here:

http://wiki.eclipse.org/EMF/Recipes#Recipe:_Data_Migration


I have the following Ecore model:

@namespace(uri="faultsets", prefix="faultsets")
package faultsets;

class System {
   val Tuple[*] tuples;
}

class Tuple {
  attr String name;
  val IdentifierSet[*] contents;
}

class IdentiferSet
 val Identifier[*] contents;
}

abstract class Identifier {}

class Wildcard extends Identifier {}
class NoFault extends Identifier {}
...


Which has evolved to this Ecore model:

@namespace(uri="faultsets", prefix="faultsets")
package faultsets;

class System {
  val Tuple[*] tuples;
}

class Tuple {
  attr String name;
  val Atom[*] contents;
}

abstract class Atom {}

class Wildcard extends Atom {}
class NoFault extends Atom {}
...


The contents of a tuple have been simplified. A tuple no longer contains a set of sets, just a set.
That sounds like the remove of levels of nesting in the XML. I don't think the mapping can handle that...
In addition, the Identifier class has been renamed to Atom.

The recipe described on the EMF wiki suggests constructing an Ecore2Ecore mapping (and corresponding Ecore2Xml mapping) and then processing the getEObjectToExtensionMap() in the postLoad() method of a custom ResourceHandler.

I'm not sure how to define the Ecore2Ecore mapping such that I can process the IdentifierSets for instances of the original Ecore model. When I define a mapping between Identifier and Atom, the getEObjectToExtensionMap() contains an entry for each Tuple for the contents feature, but the value is null. (I was expecting the value to contain data representing an instance of the now absent IdentifierSet EClass).
It would be easier to comment if you showed the XML...

When I don't define a mapping between Identifier and Atom, I receive the following exception when trying to load the model:


org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@945ff9 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3d648c (name: Atom) (instanceClassName: null) (abstract: false, interface: false)) (mixed: null, anyAttribute: null)' is not legal. (Before.faultsets, 5, 48)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2662)


at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2647)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:2166)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2034)

at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:134)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1813)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1023)

at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:87)

at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)



I don't fully understand the way in which the Ecore2Ecore and Ecore2Xml mappings interact with EMF to load instances of the original Ecore model, so I'm sure I'm doing something silly because of my ignorance. If anybody could shed any light on how I can proceed, I'd be very grateful.
It sounds likely that your changes are more complex than what the mapping approach can handle...

Many thanks, Louis.

----
Louis Rose
Research Student
Department of Computer Science,
University of York,
Heslington, York, YO10 5DD, United Kingdom.
+44 1904 434762
Twitter: @louismrose