Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resolving references during model creation
Resolving references during model creation [message #496717] Wed, 11 November 2009 07:10 Go to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
Hi,

I would like to get some opinion on an approach I have taken to resolve references during model creation.

I have a situation where I have to create parts of my model independently and resolve the references between them after all parts are created (This is somehow the case due to the fact how the input data is persisted and read). In my input data, the references are specified as Strings (something like a Primary key - Foreign key relationship in RDBMS).

In short, the approach I have taken to tackle this is as follows. I adapt each of the EObjects on creation such that, when the key attribute (primary key I mentioned above) is set, it is indexed in a type specific map. Later when a reference needs to be set, I check the type of the EReference and see if it indexed already and sets the required EObject as reference (instead of the String name equivalent of it). I do have a problem in this approach that I cannot get the target reference by simply getting the type of the EReference (as it might be a super type (maybe abstract) and there might be many subtypes that are indexed). So I have to additionally pass the exact type of the reference to be set other then inferring the type from the EReference structural feature.

Could you please let me know if my approach is ok or if I am missing some EMF features which already provides such indexing facilities? The EMFIndex project seems to do something similar at a more generic level. Since I have to use Eclipse 3.4 and EMFIndex is supposed to have major changes due to SAP implementation, I am not preferring it at the moment.

Thanks in advance,

Nirmal
Re: Resolving references during model creation [message #496835 is a reply to message #496717] Wed, 11 November 2009 14:20 Go to previous messageGo to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
I read about EMap and it seems to closely match what I am looking for. But I have a constraint that I cannot change the existing Ecore model to include <<MapEntry>> (as indexing in my case is rather an implemetation issue and not allowed in my domain model).

Would it be right implementing the EMap usage by hand?

Thanks and regards,
Nirmal
Re: Resolving references during model creation [message #496841 is a reply to message #496717] Wed, 11 November 2009 14:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Nirmal,

Comments below.


Nirmal Sasidharan wrote:
> Hi,
>
> I would like to get some opinion on an approach I have taken to
> resolve references during model creation.
>
> I have a situation where I have to create parts of my model
> independently and resolve the references between them after all parts
> are created (This is somehow the case due to the fact how the input
> data is persisted and read). In my input data, the references are
> specified as Strings (something like a Primary key - Foreign key
> relationship in RDBMS).
>
> In short, the approach I have taken to tackle this is as follows. I
> adapt each of the EObjects on creation such that, when the key
> attribute (primary key I mentioned above) is set, it is indexed in a
> type specific map. Later when a reference needs to be set, I check
> the type of the EReference and see if it indexed already and sets the
> required EObject as reference (instead of the String name equivalent
> of it). I do have a problem in this approach that I cannot get the
> target reference by simply getting the type of the EReference (as it
> might be a super type (maybe abstract) and there might be many
> subtypes that are indexed). So I have to additionally pass the exact
> type of the reference to be set other then inferring the type from the
> EReference structural feature.
>
> Could you please let me know if my approach is ok or if I am missing
> some EMF features which already provides such indexing facilities? The
> EMFIndex project seems to do something similar at a more generic
> level. Since I have to use Eclipse 3.4 and EMFIndex is supposed to
> have major changes due to SAP implementation, I am not preferring it
> at the moment.
I'm not sure I fully understand your approach, but you might be better
of encoding the "string" information in the form of a URI and use an EMF
proxy. Any instance can act as a proxy by casting to InternalEObject
and using eSetProxyURI. Whenever such an object is fetched, EMF will
first try to resolve the proxy. That involves looking up the resource
for the trimmed URI and then looking up the fragment within that
resource, so you could have a resource that acts as an index on demand.
>
> Thanks in advance,
>
> Nirmal


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Resolving references during model creation [message #496845 is a reply to message #496835] Wed, 11 November 2009 14:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Nirmal,

It's really hard to comment without more substantial details. Sorry...

Nirmal Sasidharan wrote:
> I read about EMap and it seems to closely match what I am looking for.
> But I have a constraint that I cannot change the existing Ecore model
> to include <<MapEntry>> (as indexing in my case is rather an
> implemetation issue and not allowed in my domain model).
> Would it be right implementing the EMap usage by hand?
>
> Thanks and regards,
> Nirmal


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Resolving references during model creation [message #496888 is a reply to message #496845] Wed, 11 November 2009 16:25 Go to previous messageGo to next message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
Thanks Ed. Sorry that the description of my approach was not clear enough.

"Resolve" in my earlier statement didn't really mean a resource resolution, it only meant resolving a object reference which is available in the input as "string" references. All objects will reside in the same resource.

As you suggested, I am thinking of using an EMF proxy. Is EMF proxy a good idea even when I know that the objects will reside in the same resource?

Thanks and regards,
Nirmal
Re: Resolving references during model creation [message #496949 is a reply to message #496888] Wed, 11 November 2009 20:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Nirmal,

Comments below.

Nirmal Sasidharan wrote:
> Thanks Ed. Sorry that the description of my approach was not clear
> enough.
>
> "Resolve" in my earlier statement didn't really mean a resource
> resolution, it only meant resolving a object reference which is
> available in the input as "string" references. All objects will reside
> in the same resource.
It still sounds like the proxy mechanism could be used for that. You'd
just be pointing back at the resource itself and it would have logic to
do efficient indexing of whatever fragment syntax you're using.
>
> As you suggested, I am thinking of using an EMF proxy. Is EMF proxy a
> good idea even when I know that the objects will reside in the same
> resource?
Yes, I think that will work more naturally. In XText for example
they're using this type of approach to lazily look up identifiers...
>
> Thanks and regards,
> Nirmal


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Property ComboBox for References to objects
Next Topic:Re: [Teneo] how to supress Teneo-Output to console
Goto Forum:
  


Current Time: Thu Sep 19 05:04:55 GMT 2024

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

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

Back to the top