Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Edapt] Migrate programmatically - Incorrect strategy?
[Edapt] Migrate programmatically - Incorrect strategy? [message #1012887] |
Fri, 22 February 2013 11:39 |
Kirsten M. Z. Messages: 132 Registered: July 2010 |
Senior Member |
|
|
Hi there and thanks for your efforts on Edapt so far.
Edapt is exactly what is needed in our project. However, we are not able to get everything working well right now. I have to mention that Edapt (UI) does not run on Juno/Kepler. Some error messages, missing buttons etc. Therefore, we cannot use Edapt as expected and it is hard to learn how Edapt works.
However, this is not the actual problematic spot. We need to migrate programmatically, so we started investigating the code anyway. Due to the lack of advanced documentation and examples, it was hard to get the first steps working. A very simple use case (renaming of an attribute) worked. A slightly more difficult case does not work (deletion of an attribute and creation of a new attribute). The console output:
Migrate...
Release 1
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
...done
Exception in thread "main" java.lang.IllegalArgumentException: The feature 'name' is not a valid changeable feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenSet(BasicEObjectImpl.java:1145)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1075)
at org.eclipse.emf.edapt.migration.BackwardConverter.initProperties(BackwardConverter.java:145)
at org.eclipse.emf.edapt.migration.BackwardConverter.initProperties(BackwardConverter.java:109)
at org.eclipse.emf.edapt.migration.BackwardConverter.convert(BackwardConverter.java:54)
at org.eclipse.emf.edapt.migration.Persistency.saveModel(Persistency.java:109)
at org.eclipse.emf.edapt.migration.execution.Migrator.migrateAndSave(Migrator.java:162)
at MinimalExample.main(MinimalExample.java:66)
Ok, I don't think that the problem is Edapt. I really think that the Problem is our code or the arrangement of our files. The solution is probably very easy. However, we have no idea how Edapt is expected to work. Before I post all the code of a minimal example and required files, here the arrangement:
****************************************
AClassInstance.xmi ---- meta ----> MyLibraryOld.ecore
MyLibrary.ecore (copy of "MyLibraryOld.ecore") ---- refactor ----> MyLibrary.ecore + MyLibrary.hist (the Edapt history of changes)
AClassInstance.xmi ---- migration using the history ----> AClassInstance.xmi ***crash***
****************************************
All the code and the files we got so far. I will also try attaching them.
public class MinimalExample {
/**
* @param args
*/
public static void main(String[] args) {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(HistoryPackage.eNS_URI,
HistoryPackage.eINSTANCE);
Resource resource = resourceSet.getResource(
URI.createFileURI("T:\\AClassInstance.xmi"), true);
Resource resourceHistory = resourceSet.getResource(
URI.createFileURI("T:\\MyLibrary.hist"), true);
History history = (History) resourceHistory.getContents().get(0);
Migrator mig = new Migrator(history, new ClassLoaderFacade(Thread
.currentThread().getContextClassLoader()));
// mig.setLevel(ValidationLevel.HISTORY);
mig.setLevel(ValidationLevel.NONE);
List<URI> uris = new ArrayList<URI>();
uris.add(resource.getURI());
LibraryExtractor libex = new LibraryExtractor();
Library lib = libex.extractLibrary(BaseLibrary.class);
OperationRegistry.getInstance()
.registerLibrary(lib.getImplementation());
try {
mig.migrateAndSave(uris, history.getFirstRelease(), history
.getLastRelease(), new PrintStreamProgressMonitor(
System.out));
} catch (MigrationException e) {
e.printStackTrace();
}
}
}
AClassInstance.xmi
<?xml version="1.0" encoding="ASCII"?>
<ml:AClass xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ml="http://www.example.org/MyLibrary"
xsi:schemaLocation="http://www.example.org/MyLibrary MyLibraryOld.ecore"
name="Simple Name"/>
MyLibraryOld.ecore
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="MyLibrary" nsURI="http://www.example.org/MyLibrary" nsPrefix="ml">
<eClassifiers xsi:type="ecore:EClass" name="AClass">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
MyLibrary.ecore
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="MyLibrary" nsURI="http://www.example.org/MyLibrary" nsPrefix="ml">
<eAnnotations source="http://www.eclipse.org/edapt">
<details key="historyURI" value="MyLibrary.hist"/>
</eAnnotations>
<eClassifiers xsi:type="ecore:EClass" name="AClass">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="AnotherProp" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="0"/>
</eClassifiers>
</ecore:EPackage>
MyLibrary.hist
<?xml version="1.0" encoding="ASCII"?>
<history:History xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:history="http://www.eclipse.org/emf/edapt/history/0.3">
<releases date="2013-02-22T12:04:33.758+0100" label="Initial">
<changes xsi:type="history:CompositeChange">
<changes xsi:type="history:Create">
<element href="MyLibrary.ecore#/"/>
<changes xsi:type="history:Set" featureName="name" dataValue="MyLibrary">
<element href="MyLibrary.ecore#/"/>
</changes>
<changes xsi:type="history:Set" featureName="nsURI" dataValue="http://www.example.org/MyLibrary">
<element href="MyLibrary.ecore#/"/>
</changes>
<changes xsi:type="history:Set" featureName="nsPrefix" dataValue="ml">
<element href="MyLibrary.ecore#/"/>
</changes>
</changes>
<changes xsi:type="history:Create" referenceName="eAnnotations">
<target href="MyLibrary.ecore#/"/>
<element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%"/>
<changes xsi:type="history:Set" featureName="source" dataValue="http://www.eclipse.org/edapt">
<element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%"/>
</changes>
</changes>
<changes xsi:type="history:Create" referenceName="details">
<target href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%"/>
<element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%/@details.0"/>
<changes xsi:type="history:Set" featureName="key" dataValue="historyURI">
<element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%/@details.0"/>
</changes>
<changes xsi:type="history:Set" featureName="value" dataValue="MyLibrary.hist">
<element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%/@details.0"/>
</changes>
</changes>
<changes xsi:type="history:Create" referenceName="eClassifiers">
<target href="MyLibrary.ecore#/"/>
<element href="MyLibrary.ecore#//AClass"/>
<changes xsi:type="history:Set" featureName="name" dataValue="AClass">
<element href="MyLibrary.ecore#//AClass"/>
</changes>
</changes>
<changes xsi:type="history:Create" referenceName="eStructuralFeatures" element="//@releases.1/@changes.0/@element">
<target href="MyLibrary.ecore#//AClass"/>
<changes xsi:type="history:Set" element="//@releases.1/@changes.0/@element" featureName="name" dataValue="name"/>
<changes xsi:type="history:Set" element="//@releases.1/@changes.0/@element" featureName="lowerBound" dataValue="1" oldDataValue="0"/>
<changes xsi:type="history:Set" element="//@releases.1/@changes.0/@element" featureName="eType">
<referenceValue href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</changes>
</changes>
</changes>
</releases>
<releases>
<changes xsi:type="history:Delete" referenceName="eStructuralFeatures">
<target href="MyLibrary.ecore#//AClass"/>
<element xsi:type="ecore:EAttribute" name="name" lowerBound="1">
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</element>
</changes>
<changes xsi:type="history:Create" referenceName="eStructuralFeatures">
<target href="MyLibrary.ecore#//AClass"/>
<element href="MyLibrary.ecore#//AClass/AnotherProp"/>
</changes>
<changes xsi:type="history:Set" featureName="name" dataValue="AnotherProp">
<element href="MyLibrary.ecore#//AClass/AnotherProp"/>
</changes>
<changes xsi:type="history:Set" featureName="eType">
<element href="MyLibrary.ecore#//AClass/AnotherProp"/>
<referenceValue href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</changes>
<changes xsi:type="history:Set" featureName="defaultValueLiteral" dataValue="">
<element href="MyLibrary.ecore#//AClass/AnotherProp"/>
</changes>
<changes xsi:type="history:Set" featureName="defaultValueLiteral" dataValue="0" oldDataValue="">
<element href="MyLibrary.ecore#//AClass/AnotherProp"/>
</changes>
<changes xsi:type="history:Set" featureName="lowerBound" dataValue="1" oldDataValue="0">
<element href="MyLibrary.ecore#//AClass/AnotherProp"/>
</changes>
</releases>
</history:History>
[Updated on: Fri, 22 February 2013 11:39] Report message to a moderator
|
|
|
Re: [Edapt] Migrate programmatically - Incorrect strategy? [message #1014694 is a reply to message #1012887] |
Tue, 26 February 2013 09:44 |
Maximilian Koegel Messages: 253 Registered: July 2009 |
Senior Member |
|
|
Hi Kirsten,
thank you for reporting your issue with Edapt!
I am not sure if this causes the problem, but did you try to obtain the
migrator with the code from the tutorial:
http://www.eclipse.org/edapt/libraryexample.php#migrator
Cheers,
Maximilian
Am 22.02.2013 12:39, schrieb Kirsten M. Z.:
> Hi there and thanks for your efforts on Edapt so far.
>
> Edapt is exactly what is needed in our project. However, we are not able to get everything working well right now. I have to mention that Edapt (UI) does not run on Juno/Kepler. Some error messages, missing buttons etc. Therefore, we cannot use Edapt as expected and it is hard to learn how Edapt works.
>
> However, this is not the actual problematic spot. We need to migrate programmatically, so we started investigating the code anyway. Due to the lack of advanced documentation and examples, it was hard to get the first steps working. A very simple use case (renaming of an attribute) worked. A slightly more difficult case does not work (deletion of an attribute and creation of a new attribute). The console output:
>
> Migrate...
> Release 1
> Step 1
> Step 2
> Step 3
> Step 4
> Step 5
> Step 6
> Step 7
> ..done
> Exception in thread "main" java.lang.IllegalArgumentException: The feature 'name' is not a valid changeable feature
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenSet(BasicEObjectImpl.java:1145)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1075)
> at org.eclipse.emf.edapt.migration.BackwardConverter.initProperties(BackwardConverter.java:145)
> at org.eclipse.emf.edapt.migration.BackwardConverter.initProperties(BackwardConverter.java:109)
> at org.eclipse.emf.edapt.migration.BackwardConverter.convert(BackwardConverter.java:54)
> at org.eclipse.emf.edapt.migration.Persistency.saveModel(Persistency.java:109)
> at org.eclipse.emf.edapt.migration.execution.Migrator.migrateAndSave(Migrator.java:162)
> at MinimalExample.main(MinimalExample.java:66)
>
> Ok, I don't think that the problem is Edapt. I really think that the Problem is our code or the arrangement of our files. The solution is probably very easy. However, we have no idea how Edapt is expected to work. Before I post all the code of a minimal example and required files, here the arrangement:
>
> ****************************************
>
> AClassInstance.xmi ---- meta ----> MyLibraryOld.ecore
>
> MyLibrary.ecore (copy of "MyLibraryOld.ecore") ---- refactor ----> MyLibrary.ecore + MyLibrary.hist (the Edapt history of changes)
>
> AClassInstance.xmi ---- migration using the history ----> AClassInstance.xmi ***crash***
>
> ****************************************
>
> All the code and the files we got so far. I will also try attaching them.
>
>
> public class MinimalExample {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
> new XMIResourceFactoryImpl());
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(HistoryPackage.eNS_URI,
> HistoryPackage.eINSTANCE);
>
> Resource resource = resourceSet.getResource(
> URI.createFileURI("T:\\AClassInstance.xmi"), true);
> Resource resourceHistory = resourceSet.getResource(
> URI.createFileURI("T:\\MyLibrary.hist"), true);
>
> History history = (History) resourceHistory.getContents().get(0);
>
> Migrator mig = new Migrator(history, new ClassLoaderFacade(Thread
> .currentThread().getContextClassLoader()));
> // mig.setLevel(ValidationLevel.HISTORY);
> mig.setLevel(ValidationLevel.NONE);
>
> List<URI> uris = new ArrayList<URI>();
> uris.add(resource.getURI());
>
> LibraryExtractor libex = new LibraryExtractor();
> Library lib = libex.extractLibrary(BaseLibrary.class);
>
> OperationRegistry.getInstance()
> .registerLibrary(lib.getImplementation());
>
> try {
> mig.migrateAndSave(uris, history.getFirstRelease(), history
> .getLastRelease(), new PrintStreamProgressMonitor(
> System.out));
> } catch (MigrationException e) {
> e.printStackTrace();
> }
>
> }
> }
>
> AClassInstance.xmi
>
> <?xml version="1.0" encoding="ASCII"?>
> <ml:AClass xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ml="http://www.example.org/MyLibrary"
> xsi:schemaLocation="http://www.example.org/MyLibrary MyLibraryOld.ecore"
> name="Simple Name"/>
>
> MyLibraryOld.ecore
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="MyLibrary" nsURI="http://www.example.org/MyLibrary" nsPrefix="ml">
> <eClassifiers xsi:type="ecore:EClass" name="AClass">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1">
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
> MyLibrary.ecore
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="MyLibrary" nsURI="http://www.example.org/MyLibrary" nsPrefix="ml">
> <eAnnotations source="http://www.eclipse.org/edapt">
> <details key="historyURI" value="MyLibrary.hist"/>
> </eAnnotations>
> <eClassifiers xsi:type="ecore:EClass" name="AClass">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="AnotherProp" lowerBound="1"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="0"/>
> </eClassifiers>
> </ecore:EPackage>
>
> MyLibrary.hist
>
> <?xml version="1.0" encoding="ASCII"?>
> <history:History xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:history="http://www.eclipse.org/emf/edapt/history/0.3">
> <releases date="2013-02-22T12:04:33.758+0100" label="Initial">
> <changes xsi:type="history:CompositeChange">
> <changes xsi:type="history:Create">
> <element href="MyLibrary.ecore#/"/>
> <changes xsi:type="history:Set" featureName="name" dataValue="MyLibrary">
> <element href="MyLibrary.ecore#/"/>
> </changes>
> <changes xsi:type="history:Set" featureName="nsURI" dataValue="http://www.example.org/MyLibrary">
> <element href="MyLibrary.ecore#/"/>
> </changes>
> <changes xsi:type="history:Set" featureName="nsPrefix" dataValue="ml">
> <element href="MyLibrary.ecore#/"/>
> </changes>
> </changes>
> <changes xsi:type="history:Create" referenceName="eAnnotations">
> <target href="MyLibrary.ecore#/"/>
> <element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%"/>
> <changes xsi:type="history:Set" featureName="source" dataValue="http://www.eclipse.org/edapt">
> <element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%"/>
> </changes>
> </changes>
> <changes xsi:type="history:Create" referenceName="details">
> <target href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%"/>
> <element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%/@details.0"/>
> <changes xsi:type="history:Set" featureName="key" dataValue="historyURI">
> <element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%/@details.0"/>
> </changes>
> <changes xsi:type="history:Set" featureName="value" dataValue="MyLibrary.hist">
> <element href="MyLibrary.ecore#//%http:%2F%2Fwww.eclipse.org%2Fedapt%/@details.0"/>
> </changes>
> </changes>
> <changes xsi:type="history:Create" referenceName="eClassifiers">
> <target href="MyLibrary.ecore#/"/>
> <element href="MyLibrary.ecore#//AClass"/>
> <changes xsi:type="history:Set" featureName="name" dataValue="AClass">
> <element href="MyLibrary.ecore#//AClass"/>
> </changes>
> </changes>
> <changes xsi:type="history:Create" referenceName="eStructuralFeatures" element="//@releases.1/@changes.0/@element">
> <target href="MyLibrary.ecore#//AClass"/>
> <changes xsi:type="history:Set" element="//@releases.1/@changes.0/@element" featureName="name" dataValue="name"/>
> <changes xsi:type="history:Set" element="//@releases.1/@changes.0/@element" featureName="lowerBound" dataValue="1" oldDataValue="0"/>
> <changes xsi:type="history:Set" element="//@releases.1/@changes.0/@element" featureName="eType">
> <referenceValue href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </changes>
> </changes>
> </changes>
> </releases>
> <releases>
> <changes xsi:type="history:Delete" referenceName="eStructuralFeatures">
> <target href="MyLibrary.ecore#//AClass"/>
> <element xsi:type="ecore:EAttribute" name="name" lowerBound="1">
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </element>
> </changes>
> <changes xsi:type="history:Create" referenceName="eStructuralFeatures">
> <target href="MyLibrary.ecore#//AClass"/>
> <element href="MyLibrary.ecore#//AClass/AnotherProp"/>
> </changes>
> <changes xsi:type="history:Set" featureName="name" dataValue="AnotherProp">
> <element href="MyLibrary.ecore#//AClass/AnotherProp"/>
> </changes>
> <changes xsi:type="history:Set" featureName="eType">
> <element href="MyLibrary.ecore#//AClass/AnotherProp"/>
> <referenceValue href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
> </changes>
> <changes xsi:type="history:Set" featureName="defaultValueLiteral" dataValue="">
> <element href="MyLibrary.ecore#//AClass/AnotherProp"/>
> </changes>
> <changes xsi:type="history:Set" featureName="defaultValueLiteral" dataValue="0" oldDataValue="">
> <element href="MyLibrary.ecore#//AClass/AnotherProp"/>
> </changes>
> <changes xsi:type="history:Set" featureName="lowerBound" dataValue="1" oldDataValue="0">
> <element href="MyLibrary.ecore#//AClass/AnotherProp"/>
> </changes>
> </releases>
> </history:History>
>
--
Maximilian Kögel
Get Professional Eclipse Support: http://eclipsesource.com/munich
|
|
| | | |
Re: [Edapt] Migrate programmatically - Incorrect strategy? [message #1016191 is a reply to message #1015963] |
Tue, 05 March 2013 12:29 |
Maximilian Koegel Messages: 253 Registered: July 2009 |
Senior Member |
|
|
Hi,
yes, that´s true, it is the easiest way to evolve, but in general you
can also provide the migrator with manual information of source and
target version for migration. This information could be stored somewhere
else.
Cheers,
Maximilian
Am 04.03.2013 13:33, schrieb Kirsten M. Z.:
> Oh, and there was another important issue in my strategy... sorry, that
> I forgot that in my previous post:
>
> - If the meta model evolves, also the namespace (NS URI) has to be
> changed, e.g. "http://xxx/v1" => "http://xxx/v2". I found this in an
> example, but there are not too much hints about that requirement!
--
Maximilian Kögel
Get Professional Eclipse Support: http://eclipsesource.com/munich
|
|
| | |
Re: [Edapt] Migrate programmatically - Incorrect strategy? [message #1692911 is a reply to message #1043261] |
Mon, 20 April 2015 14:27 |
Jaafar Bouayad Messages: 4 Registered: April 2015 |
Junior Member |
|
|
Hi.
I am using Edapt to programmatically migrate a model after a very simple modification on a very simple metamodel (1 class with 1 attribute to which I add an other attribute).
Unfortunately, I can't get it to work so I replicated Kirsten's minimal example which is very similar to mine but still got the same NullPointerException, which is the following :
java.lang.NullPointerException
at org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor$EcoreReconstructorSwitch.caseCreate(EcoreForwardReconstructor.java:124)
at org.eclipse.emf.edapt.spi.history.util.HistorySwitch.doSwitch(HistorySwitch.java:218)
at org.eclipse.emf.edapt.spi.history.util.HistorySwitch.doSwitch(HistorySwitch.java:104)
at org.eclipse.emf.edapt.spi.history.util.HistorySwitch.doSwitch(HistorySwitch.java:90)
at org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor.startChange(EcoreForwardReconstructor.java:71)
at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:97)
at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:102)
at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:78)
at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:57)
at org.eclipse.emf.edapt.history.reconstruction.CompositeReconstructorBase.reconstruct(CompositeReconstructorBase.java:74)
at org.eclipse.emf.edapt.migration.execution.Migrator.migrate(Migrator.java:244)
at org.eclipse.emf.edapt.migration.execution.Migrator.migrateAndLoad(Migrator.java:196)
at MinimalExample.main(MinimalExample.java:89)
There might be an internal mechanic I did not get my head around. Should I register my migrator with the MigratorRegistry ? Are there library/operation implementations I need to register ? I tried many things without any success.
Here is my code :
// create resource factory
XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"*", resourceFactory);
// create resource set
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(HistoryPackage.eNS_URI,
HistoryPackage.eINSTANCE);
// register initial metamodel
URI initial_metamodel_uri = URI
.createFileURI("initial_situation/me.ecore");
Resource initial_metamodel_resource = resourceSet.getResource(
initial_metamodel_uri, true);
EPackage initial_metamodel = (EPackage) initial_metamodel_resource
.getContents().get(0);
Registry.INSTANCE.put(initial_metamodel.getNsURI(),
initial_metamodel);
// register final metamodel
URI final_metamodel_uri = URI
.createFileURI("final_situation/me.ecore");
Resource metamodel_resource = resourceSet.getResource(
final_metamodel_uri, true);
EPackage final_metamodel = (EPackage) metamodel_resource
.getContents().get(0);
Registry.INSTANCE.put(final_metamodel.getNsURI(), final_metamodel);
// get models uri
URI model_uri = URI.createFileURI("final_situation/Me.xmi");
List<URI> models_uri = Collections.singletonList(model_uri);
// get history
URI history_uri = URI.createFileURI("final_situation/me.history");
Resource history_resource = resourceSet.getResource(history_uri,
true);
History history = (History) history_resource.getContents().get(0);
// extract library
LibraryExtractor library_extractor = new LibraryExtractor();
Library library = library_extractor
.extractLibrary(BaseLibrary.class);
Class library_implementation = library.getImplementation();
OperationRegistry.getInstance().registerLibrary(
library_implementation);
// create migrator
ClassLoaderFacade clf = new ClassLoaderFacade(Thread
.currentThread().getContextClassLoader());
Migrator migrator = new Migrator(history, clf);
migrator.setLevel(ValidationLevel.RELEASE);
// execute migration
NullProgressMonitor monitor = new NullProgressMonitor();
Release initial_release = history.getFirstRelease();
Release final_release = history.getLatestRelease();
ResourceSet migrator_resourceSet = migrator.migrateAndLoad(
models_uri, initial_release, final_release, monitor);
Is there an official "MinimalExample" ? Anything would help.
Cheers,
Jaafar
|
|
| | |
Goto Forum:
Current Time: Fri Mar 29 00:01:05 GMT 2024
Powered by FUDForum. Page generated in 0.05765 seconds
|