Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Serialization Option
Serialization Option [message #689228] Mon, 27 June 2011 07:51 Go to next message
ben  is currently offline ben Friend
Messages: 30
Registered: April 2011
Location: France/Bordeaux
Member
Hi,

I'm looking for a options for serialize my EMF Model. My Model consisted of 1 EClass and 2 EAttributes.

That follow part code shows how i create my dynamic EMF model.
 EClass purchaseOrderClass = ecoreFactory.createEClass();
		purchaseOrderClass.setName("PurchaseOrder");
		EAttribute shipTo = ecoreFactory.createEAttribute();
		shipTo.setName("shipTo");
		shipTo.setEType(EcorePackage.Literals.ESTRING);
		purchaseOrderClass.getEStructuralFeatures().add(shipTo);
		EAttribute billTo = ecoreFactory.createEAttribute();
		billTo.setName("billTo");
		billTo.setEType(EcorePackage.Literals.ESTRING);
		purchaseOrderClass.getEStructuralFeatures().add(billTo);


This small part of code shows how create an instance of my dynamic EMF model.
EFactory poFactory = poPackage.getEFactoryInstance();
 
		EObject purchaseOrder = poFactory.create(purchaseOrderClass);
		purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("shipTo"),
				"123 Maple Street");
		purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("billTo"),
				"200 Maple Street");

And then, after serialization when i open the serialiezd model with "sample reflective ecore Model editor" ,i have this view.
Purchase Order123 Maple Street


Is there an option of serialization for choice the EAttributes for display like that:
Purchase Order 200 Maple Street


Any help will be appreciated.

Ben
Re: Serialization Option [message #689443 is a reply to message #689228] Mon, 27 June 2011 16:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30457
Registered: July 2009
Senior Member
Ben,

Comments below.

On 27/06/2011 12:51 AM, ben wrote:
> Hi,
>
> I'm looking for a options for serialize my EMF Model. My Model
> consisted of 1 EClass and 2 EAttributes.
>
> That follow part code shows how i create my dynamic EMF model. EClass
> purchaseOrderClass = ecoreFactory.createEClass();
> purchaseOrderClass.setName("PurchaseOrder");
> EAttribute shipTo = ecoreFactory.createEAttribute();
> shipTo.setName("shipTo");
> shipTo.setEType(EcorePackage.Literals.ESTRING);
> purchaseOrderClass.getEStructuralFeatures().add(shipTo);
> EAttribute billTo = ecoreFactory.createEAttribute();
> billTo.setName("billTo");
> billTo.setEType(EcorePackage.Literals.ESTRING);
> purchaseOrderClass.getEStructuralFeatures().add(billTo);
> This small part of code shows how create an instance of my dynamic
> EMF model. EFactory poFactory = poPackage.getEFactoryInstance();
>
> EObject purchaseOrder = poFactory.create(purchaseOrderClass);
>
> purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("shipTo"),
> "123 Maple Street");
>
> purchaseOrder.eSet(purchaseOrderClass.getEStructuralFeature("billTo"),
> "200 Maple Street");
> And then, after serialization when i open the serialiezd model with
> "sample reflective ecore Model editor" ,i have this view.
> Purchase Order123 Maple Street
>
> Is there an option of serialization for choice the EAttributes for
> display like that: Purchase Order 200 Maple Street
No, the reflective editor has no idea which feature you'd prefer to use
as the label. It just picks one using a heuristic. If you make the
billTo address feature earlier in the list of the class' features, it
should pick that one instead.
>
> Any help will be appreciated.
>
> Ben
Re: Serialization Option [message #689789 is a reply to message #689443] Tue, 28 June 2011 11:18 Go to previous message
ben  is currently offline ben Friend
Messages: 30
Registered: April 2011
Location: France/Bordeaux
Member
Hi,

You are right Ed, for that billTo address feature display as label, i should build the billTo address feature at the earlier in the list of the EClass features.

Thank you

Ben
Previous Topic:EcoreUtil.copy and String attributes
Next Topic:Multiple EType in EAttribute or EReference
Goto Forum:
  


Current Time: Fri Sep 20 18:56:19 GMT 2019

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

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

Back to the top