Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generating ID based feature reference
Generating ID based feature reference [message #552661] Fri, 13 August 2010 05:56 Go to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
Hello,

I have a requirement of creating a sub model export from a main model. The source model has an id attribute to identify elements uniquely. The target model also needs to use the same ID to reference each other. The id's are not however part of the target metamodel.

Below is the solution I am using. Please let me know if this is the right approach.

I use extrinsic id's in the output resource. To have the Id's copied from my input model to output model I create a new Interface called EObjectIdentiable (which of course extends EObject). This interface has a transient property to hold id. I then change the gemodel to use this as the root for the output model elements. During the output model creation I copy the id's to this transient property. Then in the output resource implementation I override useUUIDs() and setID(). From setID I use the transient Id property to set the extrinsic ID.

Is there a better way of during this?

Thanks and regards,
Nirmal
Re: Generating ID based feature reference [message #552829 is a reply to message #552661] Fri, 13 August 2010 16:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020504010106020904090707
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Nirmal,

Comments below.


Nirmal Sasidharan wrote:
> Hello,
>
> I have a requirement of creating a sub model export from a main model.
> The source model has an id attribute to identify elements uniquely.
> The target model also needs to use the same ID to reference each
> other. The id's are not however part of the target metamodel.
>
> Below is the solution I am using. Please let me know if this is the
> right approach.
>
> I use extrinsic id's in the output resource. To have the Id's copied
> from my input model to output model I create a new Interface called
> EObjectIdentiable (which of course extends EObject). This interface
> has a transient property to hold id. I then change the gemodel to use
> this as the root for the output model elements. During the output
> model creation I copy the id's to this transient property. Then in the
> output resource implementation I override useUUIDs() and setID(). From
> setID I use the transient Id property to set the extrinsic ID.
>
> Is there a better way of during this?
You could just call XMLResource.setID *after *you've added the target
object to the output resource.
>
> Thanks and regards,
> Nirmal

--------------020504010106020904090707
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Nirmal,<br>
<br>
Comments below.<br>
<br>
<br>
Nirmal Sasidharan wrote:
<blockquote cite="mid:i42mq1$cn8$1@build.eclipse.org" type="cite">Hello,
<br>
<br>
I have a requirement of creating a sub model export from a main model.
The source model has an id attribute to identify elements uniquely. The
target model also needs to use the same ID to reference each other. The
id's are not however part of the target metamodel.
<br>
<br>
Below is the solution I am using. Please let me know if this is the
right approach.
<br>
<br>
I use extrinsic id's in the output resource. To have the Id's copied
from my input model to output model I create a new Interface called
EObjectIdentiable (which of course extends EObject). This interface has
a transient property to hold id. I then change the gemodel to use this
as the root for the output model elements. During the output model
creation I copy the id's to this transient property. Then in the output
resource implementation I override useUUIDs() and setID(). From setID I
use the transient Id property to set the extrinsic ID.
<br>
<br>
Is there a better way of during this?
<br>
</blockquote>
You could just call XMLResource.setID <b>after </b>you've added the
target object to the output resource.<br>
<blockquote cite="mid:i42mq1$cn8$1@build.eclipse.org" type="cite"><br>
Thanks and regards,
<br>
Nirmal
<br>
</blockquote>
</body>
</html>

--------------020504010106020904090707--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Looking for a tool for generating intuitive UI for instantiating Ecore Model entities
Next Topic:Interdependent attributes
Goto Forum:
  


Current Time: Fri Apr 26 04:14:50 GMT 2024

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

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

Back to the top