Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » using UUIDs in FragmentProvider
using UUIDs in FragmentProvider [message #1130203] Wed, 09 October 2013 10:06 Go to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
Hi,


I'm referencing EObject from non-Xtext (EMF-based) models.

I've read the following section in the documentation.
http://www.eclipse.org/Xtext/documentation.html#fragmentProvider

Could anyone give me insights on how to use UUIDs. In order to return the uuid of the EObject in the getFragment() method.

Many thanks in advance,
Benoît
Re: using UUIDs in FragmentProvider [message #1130270 is a reply to message #1130203] Wed, 09 October 2013 11:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi I don't get your point if you want to reference non Xtext models
you have to implement a iresourceserviceprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using UUIDs in FragmentProvider [message #1130280 is a reply to message #1130270] Wed, 09 October 2013 11:47 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
Hi Christian,

actually I think this is the other way around. I have a non-xtext model in which I reference xtext EObjects.

This is the exact topic of the section "Fragment Provider (Referencing Xtext Models From Other EMF Artifacts)" in the Xtext documentation.

In the xtext doc it is mentioned the following "[...] With an XMI or other binary-like serialization it is also common and possible to use UUIDs [...]"

So in the doc, it says it is common and possible to use UUIDs but I don't have any clue on how to get started.

My question is :

How do I setup my DSL to use UUIDs in my DSL's fragment provider ?
Re: using UUIDs in FragmentProvider [message #1130281 is a reply to message #1130280] Wed, 09 October 2013 11:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Sorry I have no idea on that

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using UUIDs in FragmentProvider [message #1130285 is a reply to message #1130280] Wed, 09 October 2013 11:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
BTW the docs indicates you can use the fragment provider to identify
objects by a "business key" and not a real uuid. If you want so you
would have to implement the stuff yourself ....(I doubt this is
impossible besides e.g. hashing business keys)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using UUIDs in FragmentProvider [message #1130337 is a reply to message #1130280] Wed, 09 October 2013 12:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33217
Registered: July 2009
Senior Member
Benoit,

The fragment provider would need to compute the fragment value from
information available in your Xtext-based model, so unless your
Xtext-based model somehow specifies UUIDs in the syntax, I don't think
this is possible. After all, while something like an XMIResourceImpl
can assign UUIDs automatically, those UUIDs are part of the
serialization of the model, so if you wanted something similar for
Xtext, there too, the UUIDs or whatever information you want to use for
the fragment would need to be part of the serialization...


On 09/10/2013 1:47 PM, Benoit Ries wrote:
> Hi Christian,
>
> actually I think this is the other way around. I have a non-xtext
> model in which I reference xtext EObjects.
>
> This is the exact topic of the section "Fragment Provider (Referencing
> Xtext Models From Other EMF Artifacts)" in the Xtext documentation.
>
> In the xtext doc it is mentioned the following "[...] With an XMI or
> other binary-like serialization it is also common and possible to use
> UUIDs [...]"
>
> So in the doc, it says it is common and possible to use UUIDs but I
> don't have any clue on how to get started.
>
> My question is :
>
> How do I setup my DSL to use UUIDs in my DSL's fragment provider ?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: using UUIDs in FragmentProvider [message #1130389 is a reply to message #1130203] Wed, 09 October 2013 14:04 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
thanks for your answers.
Re: using UUIDs in FragmentProvider [message #1138663 is a reply to message #1130285] Tue, 15 October 2013 08:33 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
Hi Christian, Ed,

I'm following up on this post.

I started the implementation for this issue on giving uuids values to my EObjects. I have added a new attribute "uuid" to my EObject in my DSL's metamodel.

For now what I do is the code below. But the problem is that the value of uuid is not stable and is regenerated every time I access it.

So I guess that the value should not be initialized in this method.


My question is => Where can I initialize the uuid values of my EObjects ??


***
public String getFragment(EObject obj, Fallback fallback) {
String uuid = "";
if (obj instanceof PackageDeclaration) {
PackageDeclaration packageDeclaration = (PackageDeclaration) obj;
if (packageDeclaration.getUuid() == null
|| (packageDeclaration.getUuid() != null
&& packageDeclaration.getUuid().equals(""))) {
packageDeclaration.setUuid(EcoreUtil.generateUUID());
}
uuid = packageDeclaration.getUuid();
}
return !uuid.equals("")? uuid : fallback.getFragment(obj);
}
***

[Updated on: Tue, 15 October 2013 08:41]

Report message to a moderator

Re: using UUIDs in FragmentProvider [message #1138719 is a reply to message #1138663] Tue, 15 October 2013 09:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi as said before: this is not possible. The ids have to be
(syntactically) part of the model or derived from it

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using UUIDs in FragmentProvider [message #1138735 is a reply to message #1138719] Tue, 15 October 2013 09:40 Go to previous messageGo to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
I understand that ids have to be syntactically part of the model.

I have just switched to a manually maintained metamodel, in which I added an uuid attribute to some of my DSL's EObjects.

Do we understand each other ?
Re: using UUIDs in FragmentProvider [message #1138747 is a reply to message #1138735] Tue, 15 October 2013 09:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
You have to write in your model file

Element myelement id yourid

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using UUIDs in FragmentProvider [message #1140216 is a reply to message #1138747] Wed, 16 October 2013 07:52 Go to previous message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
thanks for your very clear answer.
I thought manually maintaining my metamodel would be a workaround and now understand it is not. Sad
Previous Topic:Formatting configuration
Next Topic:Xtext Dsl Persistency in database
Goto Forum:
  


Current Time: Tue Sep 24 12:24:44 GMT 2024

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

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

Back to the top