Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to turn element name into lowercase using eAnnotations ?
How to turn element name into lowercase using eAnnotations ? [message #430618] Sat, 30 May 2009 01:28 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

I'm trying to use eAnnotations to turn the element name into lowercase :

<eClassifiers xsi:type="ecore:EClass" name="Process">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="elementOnly"/>
<details key="name" value="process"/>
</eAnnotations>
</eClassifiers>


But the result is still the same. FYI the Process element is the document
root here. Am I using the eAnnotations incorrectly here ?

Any help would be greatly appreciated.

Regards,

Setya
Re: How to turn element name into lowercase using eAnnotations ? [message #430619 is a reply to message #430618] Sat, 30 May 2009 10:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Setya,

Comments below.

Setya wrote:
> Hi all,
>
> I'm trying to use eAnnotations to turn the element name into lowercase :
>
> <eClassifiers xsi:type="ecore:EClass" name="Process">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="elementOnly"/>
> <details key="name" value="process"/>
> </eAnnotations>
> </eClassifiers>
>
>
> But the result is still the same. FYI the Process element is the
> document root here. Am I using the eAnnotations incorrectly here ?
Yes, but you're renaming the type, not the "element". Is there an
actual DocumentRoot EClass with a feature named Process? When
serializing, are you using OPTION_EXTENDED_META_DATA?
>
> Any help would be greatly appreciated.
>
> Regards,
>
> Setya
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to turn element name into lowercase using eAnnotations ? [message #430621 is a reply to message #430619] Sat, 30 May 2009 10:45 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

Thanks for your response.

>> I'm trying to use eAnnotations to turn the element name into lowercase :
>>
>> <eClassifiers xsi:type="ecore:EClass" name="Process">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="elementOnly"/>
>> <details key="name" value="process"/>
>> </eAnnotations>
>> </eClassifiers>
>>
>>
>> But the result is still the same. FYI the Process element is the
>> document root here. Am I using the eAnnotations incorrectly here ?
> Yes, but you're renaming the type, not the "element". Is there an
> actual DocumentRoot EClass with a feature named Process?

No, actually there's Process EClass in Domain Model definition and in
the Mapping Model definition this Process element maps to Canvas.

> When serializing, are you using OPTION_EXTENDED_META_DATA?

I'm not sure where to look at this option since everything was generated
by GMF.


Regards,

Setya
Re: How to turn element name into lowercase using eAnnotations ? [message #430623 is a reply to message #430621] Sat, 30 May 2009 12:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Setya,

Typically you'd specialize a resource factory for the type of resource
that's being serialized and ensure that this option is set for your
model's resource as it's being created. If there is an
XyzResourceFactoryImpl in your model plugin, make the change there. If
not, you probably want to generate one so you could do that by setting
the GenPackage's Resource Type to XMI or XML; note that you should
delete your plugin.xml if you do that so that the registration there is
generated when you subsequently regenerate.

Setya wrote:
> Hi,
>
> Thanks for your response.
>
>>> I'm trying to use eAnnotations to turn the element name into
>>> lowercase :
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="Process">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="kind" value="elementOnly"/>
>>> <details key="name" value="process"/>
>>> </eAnnotations>
>>> </eClassifiers>
>>>
>>>
>>> But the result is still the same. FYI the Process element is the
>>> document root here. Am I using the eAnnotations incorrectly here ?
>> Yes, but you're renaming the type, not the "element". Is there an
>> actual DocumentRoot EClass with a feature named Process?
>
> No, actually there's Process EClass in Domain Model definition and in
> the Mapping Model definition this Process element maps to Canvas.
>
>> When serializing, are you using OPTION_EXTENDED_META_DATA?
>
> I'm not sure where to look at this option since everything was
> generated by GMF.
>
>
> Regards,
>
> Setya
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to turn element name into lowercase using eAnnotations ? [message #430624 is a reply to message #430623] Sat, 30 May 2009 14:45 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

> Typically you'd specialize a resource factory for the type of resource
> that's being serialized and ensure that this option is set for your
> model's resource as it's being created. If there is an
> XyzResourceFactoryImpl in your model plugin, make the change there. If
> not, you probably want to generate one so you could do that by setting
> the GenPackage's Resource Type to XMI or XML; note that you should
> delete your plugin.xml if you do that so that the registration there is
> generated when you subsequently regenerate.

I have checked the XyzResourceFactoryImpl class and I can confirm that
OPTION_EXTENDED_META_DATA has been added upon generation as follows:

@Override
public Resource createResource(URI uri)
{
....
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);
....
}

and the GenPackage's Resource Type is set to XML.

Before regenerating I deleted plugin.xml so I can confirm that
org.eclipse.emf.ecore.extension_parser ext. point was added.

But the generated Process element in the Domain file is still 'Process'.


Regards,

Setya
Re: How to turn element name into lowercase using eAnnotations ? [message #430626 is a reply to message #430624] Sun, 31 May 2009 00:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Setya,

Can you show what your serialization looks like? What's the name of the
resource you're saving? Did you set breakpoints to confirm your factory
is really being used?


Setya wrote:
> Hi,
>
>> Typically you'd specialize a resource factory for the type of
>> resource that's being serialized and ensure that this option is set
>> for your model's resource as it's being created. If there is an
>> XyzResourceFactoryImpl in your model plugin, make the change there.
>> If not, you probably want to generate one so you could do that by
>> setting the GenPackage's Resource Type to XMI or XML; note that you
>> should delete your plugin.xml if you do that so that the registration
>> there is generated when you subsequently regenerate.
>
> I have checked the XyzResourceFactoryImpl class and I can confirm that
> OPTION_EXTENDED_META_DATA has been added upon generation as follows:
>
> @Override
> public Resource createResource(URI uri)
> {
> ...
> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
> Boolean.TRUE);
> ...
> }
>
> and the GenPackage's Resource Type is set to XML.
>
> Before regenerating I deleted plugin.xml so I can confirm that
> org.eclipse.emf.ecore.extension_parser ext. point was added.
>
> But the generated Process element in the Domain file is still 'Process'.
>
>
> Regards,
>
> Setya


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to turn element name into lowercase using eAnnotations ? [message #430628 is a reply to message #430626] Sun, 31 May 2009 14:33 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Ed,

> Can you show what your serialization looks like? What's the name of the
> resource you're saving? Did you set breakpoints to confirm your factory
> is really being used?

Here's the code generated in serialization class:

/**
* <copyright>
* </copyright>
*
* $Id$
*/
package com.farbeyond.designer.test.jpdl.util;

import com.farbeyond.designer.test.jpdl.JpdlPackage;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource;

/**
* <!-- begin-user-doc -->
* The <b>Resource Factory</b> associated with the package.
* <!-- end-user-doc -->
* @see com.farbeyond.designer.test.jpdl.util.JpdlResourceImpl
* @generated
*/
public class JpdlResourceFactoryImpl extends ResourceFactoryImpl
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ExtendedMetaData extendedMetaData;

/**
* Creates an instance of the resource factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public JpdlResourceFactoryImpl()
{
super();
extendedMetaData = new BasicExtendedMetaData(new
EPackageRegistryImpl(EPackage.Registry.INSTANCE));
extendedMetaData.putPackage(null, JpdlPackage.eINSTANCE);
}

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

result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
extendedMetaData);

result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
extendedMetaData);

result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
Boolean.TRUE);


result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);

result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);

result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
Boolean.TRUE);
return result;
}

} //JpdlResourceFactoryImpl


Here's the ext. point declaration taken from plugin.xml:

<extension point="org.eclipse.emf.ecore.extension_parser">
<parser type="jpdl"
class=" com.farbeyond.designer.test.jpdl.util.JpdlResourceFactoryImp l "/>
</extension>

For additional information, gmfgen file I have set Diagram File
Extension to 'jpdl' and Domain File Extension to 'jpdl.xml'.

Regards,

Setya
Re: How to turn element name into lowercase using eAnnotations ? [message #430629 is a reply to message #430628] Sun, 31 May 2009 14:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Setya,

Comments below.

Setya wrote:
> Hi Ed,
>
>> Can you show what your serialization looks like? What's the name of
>> the resource you're saving? Did you set breakpoints to confirm your
>> factory is really being used?
>
> Here's the code generated in serialization class:
>
> /**
> * <copyright>
> * </copyright>
> *
> * $Id$
> */
> package com.farbeyond.designer.test.jpdl.util;
>
> import com.farbeyond.designer.test.jpdl.JpdlPackage;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
> import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
> import org.eclipse.emf.ecore.util.ExtendedMetaData;
> import org.eclipse.emf.ecore.xmi.XMLResource;
>
> /**
> * <!-- begin-user-doc -->
> * The <b>Resource Factory</b> associated with the package.
> * <!-- end-user-doc -->
> * @see com.farbeyond.designer.test.jpdl.util.JpdlResourceImpl
> * @generated
> */
> public class JpdlResourceFactoryImpl extends ResourceFactoryImpl
> {
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> protected ExtendedMetaData extendedMetaData;
>
> /**
> * Creates an instance of the resource factory.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> public JpdlResourceFactoryImpl()
> {
> super();
> extendedMetaData = new BasicExtendedMetaData(new
> EPackageRegistryImpl(EPackage.Registry.INSTANCE));
> extendedMetaData.putPackage(null, JpdlPackage.eINSTANCE);
> }
>
> /**
> * Creates an instance of the resource.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public Resource createResource(URI uri)
> {
> XMLResource result = new JpdlResourceImpl(uri);
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
> extendedMetaData);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
> extendedMetaData);
>
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
> Boolean.TRUE);
>
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
> Boolean.TRUE);
> return result;
> }
>
> } //JpdlResourceFactoryImpl
So this indicates to me that likely you started with an XML Schema with
no target namespace. You're sure this schema doesn't have any global
(top-level) element declarations? Perhaps an element named "process"?
And you're sure there's no EClass called DocumentRoot?
>
>
> Here's the ext. point declaration taken from plugin.xml:
>
> <extension point="org.eclipse.emf.ecore.extension_parser">
> <parser type="jpdl"
> class=" com.farbeyond.designer.test.jpdl.util.JpdlResourceFactoryImp l "/>
> </extension>
So this will apply only for resources that end in jpdl.
>
> For additional information, gmfgen file I have set Diagram File
> Extension to 'jpdl'
So the diagram (notation model instance) itself will use the above
factory. I'm not sure that's right.
> and Domain File Extension to 'jpdl.xml'.
The file extension is the last segment that starts with "." so don't
think that an extension that includes a "." is correct.

Did you set breakpoints to see what's going on? The debugger can answer
questions better than can I...
>
> Regards,
>
> Setya


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to turn element name into lowercase using eAnnotations ? [message #430630 is a reply to message #430629] Sun, 31 May 2009 15:41 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

>> <extension point="org.eclipse.emf.ecore.extension_parser">
>> <parser type="jpdl"
>> class=" com.farbeyond.designer.test.jpdl.util.JpdlResourceFactoryImp l "/>
>> </extension>
> So this will apply only for resources that end in jpdl.

This is in fact the cause the problem, once I changed the parser type
into "xml" it worked as expected. I didn't expect this since it was
generated by GMF. Where did the "jpdl" come from ?


Regards,

Setya
Re: How to turn element name into lowercase using eAnnotations ? [message #430631 is a reply to message #430630] Sun, 31 May 2009 16:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Setya,

There's a setting you can control for this. By default it's just the
package name. Keep in mind that you're exceedingly likely to run into a
conflict trying to use "xml" as your extension. You'd typically need
to exploit content types to rely on that (by setting a content type
identifier in the GenPackage's properties)...


Setya wrote:
> Hi,
>
>>> <extension point="org.eclipse.emf.ecore.extension_parser">
>>> <parser type="jpdl"
>>> class=" com.farbeyond.designer.test.jpdl.util.JpdlResourceFactoryImp l "/>
>>>
>>> </extension>
>> So this will apply only for resources that end in jpdl.
>
> This is in fact the cause the problem, once I changed the parser type
> into "xml" it worked as expected. I didn't expect this since it was
> generated by GMF. Where did the "jpdl" come from ?
>
>
> Regards,
>
> Setya


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to turn element name into lowercase using eAnnotations ? [message #430635 is a reply to message #430631] Mon, 01 June 2009 03:20 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi Ed,

> Keep in mind that you're exceedingly likely to run into a
> conflict trying to use "xml" as your extension.

Sorry Ed, I still don't understand what you're saying here.
I've specified Diagram file extension to 'jpdl' and Domain file
extension to 'xml' in *.gmfgen file. So you're saying this is bad idea
since it will run into conflict later ?

> You'd typically need
> to exploit content types to rely on that (by setting a content type
> identifier in the GenPackage's properties)...

Are you talking about 'contentTypeIdentifier' attribute in *.genmodel
file ? What value should I specify in it ?


Regards,

Setya
Re: How to turn element name into lowercase using eAnnotations ? [message #430639 is a reply to message #430635] Mon, 01 June 2009 09:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Setya,

Comments below.

Setya wrote:
> Hi Ed,
>
>> Keep in mind that you're exceedingly likely to run into a conflict
>> trying to use "xml" as your extension.
>
> Sorry Ed, I still don't understand what you're saying here.
> I've specified Diagram file extension to 'jpdl' and Domain file
> extension to 'xml' in *.gmfgen file. So you're saying this is bad idea
> since it will run into conflict later ?
Imagine how many people in the world might want to register a parser
against extension "xml". If there are two such people, the
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ) will only
register one of them.
>
>> You'd typically need to exploit content types to rely on that (by
>> setting a content type identifier in the GenPackage's properties)...
>
> Are you talking about 'contentTypeIdentifier' attribute in *.genmodel
> file ? What value should I specify in it ?
Yes, it's specified on the GenPackage of the GenModel and must be an
identifier, e.g., org.example.jdpl. With a content type, the actual
contents of the file will be scanned to determine if it matches the
content type. Typically that's done by checking that the namespace of
the root element matches the expected namespace of the package, though
you've got a no namespace package. I'm not sure how well that's handled
automatically, but in this case, you'd want to match against the null
namespace and the expected root element name.
>
>
> Regards,
>
> Setya


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:NPE on transaction commit
Next Topic:Mandatory attribute with default value
Goto Forum:
  


Current Time: Fri Apr 26 09:41:00 GMT 2024

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

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

Back to the top