Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Cross Document References persistence customization
Cross Document References persistence customization [message #505800] Tue, 05 January 2010 05:44 Go to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi,

In case of Cross Document Reference between Supplier and Customer, I get the following persistence:

<supplier>
<customers>
<customer>file:/C:/Test/src/main/test/a.customer#//@customer <\customer>
<customer>file:/C:/Test/src/main/test/b.customer#//@customer <\customer>
<\customers>
<\supplier>

Now, the name of the customer is unique across the supplier, hence would it be possible to persist the customer cross reference by name rather than the entire path. As the name is the unique identier:

<supplier>
<customers>
<customer>a<\customer>
<customer>b<\customer>
<\customers>
<\supplier>

Thanks & Regards,
Nidhi
Re: Cross Document References persistence customization [message #505865 is a reply to message #505800] Tue, 05 January 2010 07:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
Nidhi,

Comments below.

Nidhi wrote:
> Hi,
>
> In case of Cross Document Reference between Supplier and Customer, I
> get the following persistence:
>
> <supplier>
> <customers>
> <customer>file:/C:/Test/src/main/test/a.customer#//@customer <\customer>
> <customer>file:/C:/Test/src/main/test/b.customer#//@customer <\customer>
> <\customers>
> <\supplier>
>
> Now, the name of the customer is unique across the supplier, hence
> would it be possible to persist the customer cross reference by name
> rather than the entire path.
It looks like each customer is in a separate resource so you'd need to
specify the file name. You could make the customer's name be an ID,
i.e., EAttribute.isID set to true or using xsd:ID as the type (which
would imply it needs to be an NCName).
> As the name is the unique identier:
>
> <supplier>
> <customers>
> <customer>a<\customer>
> <customer>b<\customer>
> <\customers>
> <\supplier>
>
> Thanks & Regards,
> Nidhi
Re: Cross Document References persistence customization [message #506107 is a reply to message #505865] Wed, 06 January 2010 08:20 Go to previous messageGo to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi Ed,

Thanks for the reply.

> It looks like each customer is in a separate resource so you'd need to
> specify the file name. You could make the customer's name be an ID,
> i.e., EAttribute.isID set to true or using xsd:ID as the type (which
> would imply it needs to be an NCName).

That's right each customer is in a separate resource.
I did set the ID attribute of Customer's Name as true, but the
persistence achieved was something like this:

<supplier>
<customers>
<customer>file:/C:/Test/src/main/test/a.customer#a <\customer>
<customer>file:/C:/Test/src/main/test/b.customer#b <\customer>
<\customers>
<\supplier>

"//@customer" was replaced by the name of the customer "a".

However, is it also possible to get rid of the file path name (absolute or relative).

I did read somewhere, that EcorePlugin.getPlatformMap() can be used to associate a string with a file location.
Would this be the right thing to do, if so how can this be done.

The reason why I wanted to achieve this is because the target users of my tool are expert with manipulating the source xml (persisted xml) rather than using a UI.
Hence, wanted the persistence to be fairly simple without any long path names for the referenced customer resources.

Thanks & Regards,
Nidhi
Re: Cross Document References persistence customization [message #506158 is a reply to message #506107] Wed, 06 January 2010 11:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
Nidhi,

Comments below.

Nidhi wrote:
> Hi Ed,
>
> Thanks for the reply.
>
>> It looks like each customer is in a separate resource so you'd need
>> to specify the file name. You could make the customer's name be an
>> ID, i.e., EAttribute.isID set to true or using xsd:ID as the type
>> (which would imply it needs to be an NCName).
>
> That's right each customer is in a separate resource.
> I did set the ID attribute of Customer's Name as true, but the
> persistence achieved was something like this:
>
> <supplier>
> <customers>
> <customer>file:/C:/Test/src/main/test/a.customer#a <\customer>
> <customer>file:/C:/Test/src/main/test/b.customer#b <\customer>
> <\customers>
> <\supplier>
>
> "//@customer" was replaced by the name of the customer "a".
That's what I'd expect.
>
> However, is it also possible to get rid of the file path name
> (absolute or relative).
Not really, no. Just the ID alone isn't sufficient for EMF to be able to
locate an arbitrary resource containing something with that ID.
>
> I did read somewhere, that EcorePlugin.getPlatformMap() can be used to
> associate a string with a file location.
> Would this be the right thing to do, if so how can this be done.
It only lets you map project names to project locations so that
something like platform:/resource/project-name/... can be resolved to a
location such as file:/c:/workspace/project-name. I.e., you can only
map one URI to another.
>
> The reason why I wanted to achieve this is because the target users of
> my tool are expert with manipulating the source xml (persisted xml)
> rather than using a UI.
> Hence, wanted the persistence to be fairly simple without any long
> path names for the referenced customer resources.
If both the source and target resources of the reference have absolute
URIs, EMF will make the reference between them relative, so that would
help. You can also specialize getURIFragment and getEObject for your
customer resource to make and handle simpler fragment than //@customer.
With that approach you might end up with customer-name.customer# which
is pretty simple..
>
> Thanks & Regards,
> Nidhi
Re: Cross Document References persistence customization [message #506212 is a reply to message #506158] Wed, 06 January 2010 15:00 Go to previous message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi Ed,

Thanks a lot. it works Smile

Cheers,
Nidhi
Previous Topic:Newlines in generated code
Next Topic:XsdEcoreBuilder producing an illegal Java package name
Goto Forum:
  


Current Time: Fri Nov 22 05:56:13 GMT 2019

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

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

Back to the top