Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem with ExtendedMetaData
Problem with ExtendedMetaData [message #1015092] Wed, 27 February 2013 07:43 Go to next message
Patrik Nandorf is currently offline Patrik Nandorf
Messages: 9
Registered: January 2013
Location: Sweden
Junior Member
I've a problem with EMF and ExtendedMetaData.


I tried with a really small ecore model where 'A' contains 'B's through a reference 'attr'. I change the name of this reference to 'attribute' using an ExtendedMetaData anotation.

<ecore:EPackage xmi:version="2.0" xmlns:xmi="htxp://www.omg.org/XMI" xmlns:xsi="htxp://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="htxp://www.eclipse.org/emf/2002/Ecore" name="a" nsURI="a" nsPrefix="a">
  <eAnnotations source="htxp:///org/eclipse/emf/ecore/util/ExtendedMetaData">
    <details key="qualified" value="false"/>
  </eAnnotations>
  <eClassifiers xsi:type="ecore:EClass" name="A">
    <eStructuralFeatures xsi:type="ecore:EReference" name="attr" upperBound="-1" eType="#//B"
        containment="true">
      <eAnnotations source="htxp:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="name" value="attribute"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="B">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="x" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>



From this I generate a genmodel and then generat code (model, edit and editor) and start the runtime workbench.

I create a model using the model wizard for this ecore model and it seems to be ok. The reference chnage from 'attr' to 'attribute'.


<?xml version="1.0" encoding="UTF-8"?>
<A xmlns:xsi="htxp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="a">
  <attribute x="x"/>
</A>


When I close it and and try to open it again with the same editor I created it in I get an error (attached as image also, as is the stack trace):

Problem encountered in file "platform/resource/a/My.a"
FeatureNotFoundExeption: Feature 'attribute' not found (platform/resource/a/My.a,3,21)

If I open the model and change the name of the references backto 'attr' (as defined if the ExtendedMetaData wasn't set) it works, ie. it can be loaded.


Can someone explain this behavior to me?

I use:
- Kepler Release Build id: 20130207-1142
- EMF 2.9.0

PS. Due to this "You can only use links to eclipse.org sites while you have fewer than 5 messages." I have to use htxp instated of http. DS
Re: Problem with ExtendedMetaData [message #1015103 is a reply to message #1015092] Wed, 27 February 2013 08:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
Patrik,

Is the resource factory you're using specifying OPTION_EXTENDED_METADATA
as both a load and a save option for the resource it creates?

On 27/02/2013 1:43 PM, Patrik Nandorf wrote:
> I've a problem with EMF and ExtendedMetaData.
>
>
> I tried with a really small ecore model where 'A' contains 'B's through a reference 'attr'. I change the name of this reference to 'attribute' using an ExtendedMetaData anotation.
>
>
> <ecore:EPackage xmi:version="2.0" xmlns:xmi="htxp://www.omg.org/XMI" xmlns:xsi="htxp://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="htxp://www.eclipse.org/emf/2002/Ecore" name="a" nsURI="a" nsPrefix="a">
> <eAnnotations source="htxp:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="qualified" value="false"/>
> </eAnnotations>
> <eClassifiers xsi:type="ecore:EClass" name="A">
> <eStructuralFeatures xsi:type="ecore:EReference" name="attr" upperBound="-1" eType="#//B"
> containment="true">
> <eAnnotations source="htxp:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="attribute"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="B">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="x" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
>
> From this I generate a genmodel and then generat code (model, edit and editor) and start the runtime workbench.
>
> I create a model using the model wizard for this ecore model and it seems to be ok. The reference chnage from 'attr' to 'attribute'.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <A xmlns:xsi="htxp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="a">
> <attribute x="x"/>
> </A>
>
> When I close it and and try to open it again with the same editor I created it in I get an error (attached as image also, as is the stack trace):
>
> Problem encountered in file "platform/resource/a/My.a"
> FeatureNotFoundExeption: Feature 'attribute' not found (platform/resource/a/My.a,3,21)
>
> If I open the model and change the name of the references backto 'attr' (as defined if the ExtendedMetaData wasn't set) it works, ie. it can be loaded.
>
>
> Can someone explain this behavior to me?
>
> I use:
> - Kepler Release Build id: 20130207-1142
> - EMF 2.9.0
>
> PS. Due to this "You can only use links to eclipse.org sites while you have fewer than 5 messages." I have to use htxp instated of http. DS
>
Re: Problem with ExtendedMetaData [message #1015107 is a reply to message #1015103] Wed, 27 February 2013 08:30 Go to previous messageGo to next message
Patrik Nandorf is currently offline Patrik Nandorf
Messages: 9
Registered: January 2013
Location: Sweden
Junior Member
yes, it seems

	/**
	 * Creates an instance of the resource.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Resource createResource(URI uri) {
		XMLResource result = new AResourceImpl(uri);
		result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
		result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

		result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

		result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
		result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);

		result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
		return result;
	}
Re: Problem with ExtendedMetaData [message #1015125 is a reply to message #1015107] Wed, 27 February 2013 09:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
Patrik,

You're sure this resource factory getting used? You could set a
breakpoint in
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getFeature(EClass, String,
String, boolean) to see why it's failing. You can make the breakpoint
conditional on name being the name of the feature in question...


On 27/02/2013 2:30 PM, Patrik Nandorf wrote:
> yes, it seems
>
>
> /**
> * Creates an instance of the resource.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public Resource createResource(URI uri) {
> XMLResource result = new AResourceImpl(uri);
> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
> extendedMetaData);
> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
> extendedMetaData);
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION,
> Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER,
> Boolean.TRUE);
> return result;
> }
>
Re: Problem with ExtendedMetaData [message #1015149 is a reply to message #1015125] Wed, 27 February 2013 10:20 Go to previous messageGo to next message
Patrik Nandorf is currently offline Patrik Nandorf
Messages: 9
Registered: January 2013
Location: Sweden
Junior Member
I assumed it would since I only use generated code. And it does. It is called both when loading an existing model and creating a new one.

Regards,
Patrik
Re: Problem with ExtendedMetaData [message #1015194 is a reply to message #1015149] Wed, 27 February 2013 12:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
So consulted your best friend, the debugger, and you've set a breakpoint
where I suggested?


On 27/02/2013 4:20 PM, Patrik Nandorf wrote:
> I assumed it would since I only use generated code. And it does. It is
> called both when loading an existing model and creating a new one.
>
> Regards,
> Patrik
Re: Problem with ExtendedMetaData [message #1015304 is a reply to message #1015194] Thu, 28 February 2013 02:35 Go to previous message
Patrik Nandorf is currently offline Patrik Nandorf
Messages: 9
Registered: January 2013
Location: Sweden
Junior Member
Yes, I did.
Edit: I've added the test projects as an attached file

[Updated on: Thu, 28 February 2013 02:53]

Report message to a moderator

Previous Topic:CacheAdapter performance issue
Next Topic:[CDO] remove object from resource throws UnsupportedOperationException
Goto Forum:
  


Current Time: Sat Aug 30 06:29:25 EDT 2014

Powered by FUDForum. Page generated in 0.13585 seconds