Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Manage compatibility between model files
Manage compatibility between model files [message #422895] Thu, 18 September 2008 08:33 Go to next message
Guillaume SOLDERA is currently offline Guillaume SOLDERAFriend
Messages: 23
Registered: July 2009
Junior Member
Hi !

I work on an RCP application built from EMF/GMF.
So, I have an ecore model.

However, version after version, this model evolves.
I would like that an user can load an model created with an old version in
a new version.

Are ecore2ecore functionalities done for that ?

Thanks

Guillaume
Re: Manage compatibility between model files (ecore2ecore) [message #422914 is a reply to message #422895] Thu, 18 September 2008 15:15 Go to previous messageGo to next message
Guillaume SOLDERA is currently offline Guillaume SOLDERAFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

I found this recipe :

http://wiki.eclipse.org/EMF/Recipes#XMI.2FXML_Serialization_ Recipes

Now, I can load an old model.
However, the elements of this model have bad properties.

Every elements have 3 properties : 'Any', 'Any Attribute' and 'Mixed'.


How can I have good properties for my elements ?

Thanks

Guillaume
Re: Manage compatibility between model files (ecore2ecore) [message #422922 is a reply to message #422914] Thu, 18 September 2008 19:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Guillaume,

I'm really not sure based on your description what's going wrong. It
sounds like you are getting instances of AnyType which are used when a
proper match can't be found...


Guillaume SOLDERA wrote:
> Hi,
> I found this recipe :
> http://wiki.eclipse.org/EMF/Recipes#XMI.2FXML_Serialization_ Recipes
>
> Now, I can load an old model.
> However, the elements of this model have bad properties.
>
> Every elements have 3 properties : 'Any', 'Any Attribute' and 'Mixed'.
>
>
> How can I have good properties for my elements ?
>
> Thanks
>
> Guillaume
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Manage compatibility between model files (ecore2ecore) [message #422933 is a reply to message #422922] Fri, 19 September 2008 08:08 Go to previous messageGo to next message
Guillaume SOLDERA is currently offline Guillaume SOLDERAFriend
Messages: 23
Registered: July 2009
Junior Member
Ed,

thanks for your answer.

I try to reformulate my problem.

I have an ecore file which details a model.
I changed this model, I rename an EAttribute. So I make a new ecore file
matching with this modification.

I used ecore2ecore mapping to be able to load a file built from the old
model in editor built from the new model.

In my file built form the old model, I have an element (JOnAS) which has a
child (ejbContainer).

In the editor built from the old model, I have in 'Properties' view the
element properties when my element is focused.

In the editor built from the new model, these properties are wrong.
Instead the element properties, I have 3 properties 'Any', 'Any Attribute'
and 'Mixed'.

By example, 'Any' property has for value :

ejbContainers=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@3f45a8
(mixed: [], anyAttribute: [name=ejb])


Note that 'name' is a property of 'EJBContainer' element.


Where can this problem come from ?
From the mapping or from the code ?

Thanks

Guillaume



Ed Merks wrote:

> Guillaume,

> I'm really not sure based on your description what's going wrong. It
> sounds like you are getting instances of AnyType which are used when a
> proper match can't be found...


> Guillaume SOLDERA wrote:
>> Hi,
>> I found this recipe :
>> http://wiki.eclipse.org/EMF/Recipes#XMI.2FXML_Serialization_ Recipes
>>
>> Now, I can load an old model.
>> However, the elements of this model have bad properties.
>>
>> Every elements have 3 properties : 'Any', 'Any Attribute' and 'Mixed'.
>>
>>
>> How can I have good properties for my elements ?
>>
>> Thanks
>>
>> Guillaume
>>
Re: Manage compatibility between model files (ecore2ecore) [message #422964 is a reply to message #422933] Fri, 19 September 2008 16:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Guillaume,

Comments below.

Guillaume SOLDERA wrote:
> Ed,
>
> thanks for your answer.
>
> I try to reformulate my problem.
>
> I have an ecore file which details a model.
> I changed this model, I rename an EAttribute. So I make a new ecore
> file matching with this modification.
>
> I used ecore2ecore mapping to be able to load a file built from the
> old model in editor built from the new model.
>
> In my file built form the old model, I have an element (JOnAS) which
> has a child (ejbContainer).
>
> In the editor built from the old model, I have in 'Properties' view
> the element properties when my element is focused.
>
> In the editor built from the new model, these properties are wrong.
> Instead the element properties, I have 3 properties 'Any', 'Any
> Attribute' and 'Mixed'.
>
> By example, 'Any' property has for value :
> ejbContainers=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@3f45a8
> (mixed: [], anyAttribute: [name=ejb])
As I though, it's creating an instance of AnyType.
>
>
> Note that 'name' is a property of 'EJBContainer' element.
>
>
> Where can this problem come from ? From the mapping or from the code ?
It may well be an issue with the new model itself. For example, it
sounds like an instance of AnyType is a valid value for the feature of
the new model, but I don't understand the structure of your model that
would allow that... Is this model XML Schema-based and has wildcards?
>
> Thanks
>
> Guillaume
>
>
>
> Ed Merks wrote:
>
>> Guillaume,
>
>> I'm really not sure based on your description what's going wrong. It
>> sounds like you are getting instances of AnyType which are used when
>> a proper match can't be found...
>
>
>> Guillaume SOLDERA wrote:
>>> Hi,
>>> I found this recipe :
>>> http://wiki.eclipse.org/EMF/Recipes#XMI.2FXML_Serialization_ Recipes
>>>
>>> Now, I can load an old model.
>>> However, the elements of this model have bad properties.
>>>
>>> Every elements have 3 properties : 'Any', 'Any Attribute' and 'Mixed'.
>>>
>>>
>>> How can I have good properties for my elements ?
>>>
>>> Thanks
>>>
>>> Guillaume
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Manage compatibility between model files (ecore2ecore) [message #423060 is a reply to message #422964] Mon, 22 September 2008 14:00 Go to previous messageGo to next message
Guillaume SOLDERA is currently offline Guillaume SOLDERAFriend
Messages: 23
Registered: July 2009
Junior Member
Ed,

Thanks for your answers.
I try with a very simple model.
I create my model ecore (model.ecore) in a new EMF project (called
SimpleModel):
This is the model :


<?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="simpleModel"
    nsURI="http:///test/1.0.0/simpleModel" nsPrefix="simpleModel">
  <eClassifiers xsi:type="ecore:EClass" name="Domain">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="domainName" 
lowerBound="1"
        eType="ecore:EDataType 
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>




I generated 'Model' code, 'Edit' code and 'Editor' code matching with this
ecore file.


Then I created an other EMF project (called SimpleModel2).
In this project, I created an ecore file (model_new.ecore). This ecore
file is the same except for the attribute name ('domainName' changed into
'nom')


<?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="simpleModel"
    nsURI="http:///test/1.0.1/simpleModel" nsPrefix="simpleModel">
  <eClassifiers xsi:type="ecore:EClass" name="Domain">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="nom" 
lowerBound="1" eType="ecore:EDataType 
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>



I generated the 'Model' code, 'Edit' code and 'Editor' code.
In my SimpleModel2 project, I copy/paste 'model.ecore'.
From this file, I created the ecore2ecore file and mapped all elements


<?xml version="1.0" encoding="UTF-8"?>
<ecore2ecore:Ecore2EcoreMappingRoot xmi:version="2.0" 
xmlns:xmi="http://www.omg.org/XMI" 
xmlns:ecore2ecore="http://www.eclipse.org/emf/2004/Ecore2Ecore" 
topToBottom="true">
  <nested>
    <nested>
      <nested>
        <inputs href="model.ecore#//Domain/domainName/@eGenericType"/>
        <outputs href="model_new.ecore#//Domain/nom/@eGenericType"/>
      </nested>
      <inputs href="model.ecore#//Domain/domainName"/>
      <outputs href="model_new.ecore#//Domain/nom"/>
    </nested>
    <inputs href="model.ecore#//Domain"/>
    <outputs href="model_new.ecore#//Domain"/>
  </nested>
  <inputs href="model.ecore#/"/>
  <outputs href="model_new.ecore#/"/>
</ecore2ecore:Ecore2EcoreMappingRoot>



Then I created the 'ecore2xml' file :


?xml version="1.0" encoding="UTF-8"?>
<ecore2xml:XMLMap 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:ecore2xml="http://www.eclipse.org/emf/2005/Ecore2XML">
  <ecoreToXMLInfo>
    <key xsi:type="ecore:EPackage" href="model_new.ecore#/"/>
    <value name="simpleModel" 
targetNamespace="http:///test/1.0.0/simpleModel"/>
  </ecoreToXMLInfo>
  <ecoreToXMLInfo>
    <key xsi:type="ecore:EClass" href="model_new.ecore#//Domain"/>
    <value name="Domain" targetNamespace="http:///test/1.0.0/simpleModel"/>
  </ecoreToXMLInfo>
  <ecoreToXMLInfo>
    <key xsi:type="ecore:EAttribute" href="model_new.ecore#//Domain/nom"/>
    <value name="domainName"/>
  </ecoreToXMLInfo>
</ecore2xml:XMLMap>




Then I added an 'org.eclipse.emf.ecore.extension_parser' :

<extension
        point="org.eclipse.emf.ecore.extension_parser">
     <parser
           class="simpleModel.impl.ModelResourceFactoryImpl"
           type="simplemodel">
     </parser>
  </extension>



'ModelResourceFactoryImpl' extends 'XMIResourceFactoryImp' and is written
from the recipe :

http://wiki.eclipse.org/EMF/Recipes#XMI.2FXML_Serialization_ Recipes


I created a file with the 'old' application and I put a name for
'domainName' attribute.

When I load this file in the 'new' application, 'Domain' element has 3
properties 'Any', 'AnyAttribute' and 'Mixed'.

'AnyAttribute' has for value : "domainName=nomDuDomaine" ('nomDuDomaine'
is the name that I put as value in 'old' application).

And 'Domain' has a child : "domainName='nomDuDomaine'"
When I click on this child, in 'Properties' View, I have a property
'Value' and an associated value 'nomDuDomaine'.

I would like have one element : 'Domain'. And when I click on this
element, I would like have in 'Properties' View a property 'nom' (the new
name of this attribute) and a value 'nomDuDomaine'.



Is there something that I do not (or wrong) ?

Thanks

Guillaume
Re: Manage compatibility between model files (ecore2ecore) [message #423065 is a reply to message #423060] Mon, 22 September 2008 15:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Guillaume,

Could you export the projects involved to an archive (zip or jar) so
that I could import them and reproduce your problem? I'm traveling
today, so I won't be able to look at them until tomorrow.


Guillaume SOLDERA wrote:
> Ed,
>
> Thanks for your answers.
> I try with a very simple model.
> I create my model ecore (model.ecore) in a new EMF project (called
> SimpleModel): This is the model :
>
>
>
> <?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="simpleModel"
>    nsURI="http:///test/1.0.0/simpleModel" nsPrefix="simpleModel">
>  <eClassifiers xsi:type="ecore:EClass" name="Domain">
>    <eStructuralFeatures xsi:type="ecore:EAttribute" name="domainName" 
> lowerBound="1"
>        eType="ecore:EDataType 
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>  </eClassifiers>
> </ecore:EPackage>
>
> 

>
>
> I generated 'Model' code, 'Edit' code and 'Editor' code matching with
> this ecore file.
>
>
> Then I created an other EMF project (called SimpleModel2). In this
> project, I created an ecore file (model_new.ecore). This ecore file is
> the same except for the attribute name ('domainName' changed into 'nom')
>
>
>
> <?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="simpleModel"
>    nsURI="http:///test/1.0.1/simpleModel" nsPrefix="simpleModel">
>  <eClassifiers xsi:type="ecore:EClass" name="Domain">
>    <eStructuralFeatures xsi:type="ecore:EAttribute" name="nom" 
> lowerBound="1" eType="ecore:EDataType 
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>  </eClassifiers>
> </ecore:EPackage>
>
> 

>
> I generated the 'Model' code, 'Edit' code and 'Editor' code.
> In my SimpleModel2 project, I copy/paste 'model.ecore'.
> From this file, I created the ecore2ecore file and mapped all elements
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore2ecore:Ecore2EcoreMappingRoot xmi:version="2.0" 
> xmlns:xmi="http://www.omg.org/XMI" 
> xmlns:ecore2ecore="http://www.eclipse.org/emf/2004/Ecore2Ecore" 
> topToBottom="true">
>  <nested>
>    <nested>
>      <nested>
>        <inputs href="model.ecore#//Domain/domainName/@eGenericType"/>
>        <outputs href="model_new.ecore#//Domain/nom/@eGenericType"/>
>      </nested>
>      <inputs href="model.ecore#//Domain/domainName"/>
>      <outputs href="model_new.ecore#//Domain/nom"/>
>    </nested>
>    <inputs href="model.ecore#//Domain"/>
>    <outputs href="model_new.ecore#//Domain"/>
>  </nested>
>  <inputs href="model.ecore#/"/>
>  <outputs href="model_new.ecore#/"/>
> </ecore2ecore:Ecore2EcoreMappingRoot>
>
> 

>
> Then I created the 'ecore2xml' file :
>
>
> ?xml version="1.0" encoding="UTF-8"?>
> <ecore2xml:XMLMap 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:ecore2xml="http://www.eclipse.org/emf/2005/Ecore2XML">
>  <ecoreToXMLInfo>
>    <key xsi:type="ecore:EPackage" href="model_new.ecore#/"/>
>    <value name="simpleModel" 
> targetNamespace="http:///test/1.0.0/simpleModel"/>
>  </ecoreToXMLInfo>
>  <ecoreToXMLInfo>
>    <key xsi:type="ecore:EClass" href="model_new.ecore#//Domain"/>
>    <value name="Domain" 
> targetNamespace="http:///test/1.0.0/simpleModel"/>
>  </ecoreToXMLInfo>
>  <ecoreToXMLInfo>
>    <key xsi:type="ecore:EAttribute" href="model_new.ecore#//Domain/nom"/>
>    <value name="domainName"/>
>  </ecoreToXMLInfo>
> </ecore2xml:XMLMap>
>
> 

>
>
> Then I added an 'org.eclipse.emf.ecore.extension_parser' :
>
> <extension
>        point="org.eclipse.emf.ecore.extension_parser">
>     <parser
>           class="simpleModel.impl.ModelResourceFactoryImpl"
>           type="simplemodel">
>     </parser>
>  </extension>
>
> 

>
> 'ModelResourceFactoryImpl' extends 'XMIResourceFactoryImp' and is
> written from the recipe :
> http://wiki.eclipse.org/EMF/Recipes#XMI.2FXML_Serialization_ Recipes
>
>
> I created a file with the 'old' application and I put a name for
> 'domainName' attribute.
>
> When I load this file in the 'new' application, 'Domain' element has 3
> properties 'Any', 'AnyAttribute' and 'Mixed'.
> 'AnyAttribute' has for value : "domainName=nomDuDomaine"
> ('nomDuDomaine' is the name that I put as value in 'old' application).
>
> And 'Domain' has a child : "domainName='nomDuDomaine'"
> When I click on this child, in 'Properties' View, I have a property
> 'Value' and an associated value 'nomDuDomaine'.
>
> I would like have one element : 'Domain'. And when I click on this
> element, I would like have in 'Properties' View a property 'nom' (the
> new name of this attribute) and a value 'nomDuDomaine'.
>
>
>
> Is there something that I do not (or wrong) ?
>
> Thanks
>
> Guillaume
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Overriding operations
Next Topic:CDO make table DB bug
Goto Forum:
  


Current Time: Thu Apr 18 13:29:48 GMT 2024

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

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

Back to the top