Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Eopposite(navigating relationships by reference without eOpposite if it's possible)
Eopposite [message #492350] Tue, 20 October 2009 07:14 Go to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Hi.

I have a model in several files which are related by some relationships between some entities.
I have defined some bidirectional relations using eopposite, and I can navigate that relations in both senses.
The problem is that when I change one of that relationships that point out by reference a entity of the other module, there will be changes in both modules updating the bidirectional relationship: in the source module, and also in the target module.
In this case, one of that modules is read only, and therefore, that bidirectional relationships, can not be updated.

I think that containment relationships can be navigated in both senses (eContainer for the reverse) but I don't know how can I navigate a relationship by reference without using eopposite nor bidirectional relations to solve the problem, if that's possible.

Have you got any suggestion about this issue?

Thanks in advance.
Best regards.
Carlos.
Re: Eopposite [message #492362 is a reply to message #492350] Tue, 20 October 2009 08:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Carlos,

Comments below.

Carlos wrote:
> Hi.
>
> I have a model in several files which are related by some
> relationships between some entities.
> I have defined some bidirectional relations using eopposite, and I can
> navigate that relations in both senses.
> The problem is that when I change one of that relationships that point
> out by reference a entity of the other module, there will be changes
> in both modules updating the bidirectional relationship: in the source
> module, and also in the target module.
That should be expected.
> In this case, one of that modules is read only, and therefore, that
> bidirectional relationships, can not be updated.
A consistent bidirectional reference updated on both ends.
>
> I think that containment relationships can be navigated in both senses
> (eContainer for the reverse) but I don't know how can I navigate a
> relationship by reference without using eopposite nor bidirectional
> relations to solve the problem, if that's possible.
You'd have to use something like a CrossReferencer or a
ECrossReferenceAdapter.
>
> Have you got any suggestion about this issue?
However handy inverses might be, there are often cases where it just
doesn't make sense. For example, for EClass.eSuperTypes one might be
tempted to define an inverse eSubTypes, but that would require an EClass
to know all EClasses that derive from it, which is generally unbounded
in the real world.
>
> Thanks in advance.
> Best regards.
> Carlos.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Eopposite [message #492381 is a reply to message #492350] Tue, 20 October 2009 10:23 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed,

dou you know where can I get a code example for using:

* CrossReferencer
* ECrossReferenceAdapter.

In this way, I don't know if the method "eCrossReferences( )" has some relation with this issue...

Thanks.


Re: Eopposite [message #492397 is a reply to message #492381] Tue, 20 October 2009 10:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Carlos,

Try this with the Library schema model and then apply those ideas to
your own model. Look closely at how the print methods are implemented
to see how to process the settings.:

Resource resource =
resourceSet.createResource(URI.createURI("http:///My.library"));
DocumentRoot documentRoot =
LibraryFactory.eINSTANCE.createDocumentRoot();
Library root = LibraryFactory.eINSTANCE.createLibrary();
Book book = LibraryFactory.eINSTANCE.createBook();
root.getBooks().add(book);
Writer writer = LibraryFactory.eINSTANCE.createWriter();
root.getWriters().add(writer);
documentRoot.setLibrary(root);
book.setAuthor(writer);
resource.getContents().add(documentRoot);
EcoreUtil.CrossReferencer.print(System.out,
EcoreUtil.CrossReferencer.find(Collections.singleton(resourc eSet)));
ECrossReferenceAdapter eCrossReferenceAdapter = new
ECrossReferenceAdapter();
resourceSet.eAdapters().add(eCrossReferenceAdapter);
EcoreUtil.CrossReferencer.print(System.out,
eCrossReferenceAdapter.getInverseReferences(book));


Carlos wrote:
> Ed,
>
> dou you know where can I get a code example for using:
>
> * CrossReferencer * ECrossReferenceAdapter.
>
> In this way, I don't know if the method "eCrossReferences( )" has some
> relation with this issue...
>
> Thanks.
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Eopposite [message #492404 is a reply to message #492397] Tue, 20 October 2009 11:15 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Ed, once again, thank you very much for your help.
Re: Eopposite [message #492657 is a reply to message #492404] Wed, 21 October 2009 09:39 Go to previous messageGo to next message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
Hi Ed,

I have solved my problem with the utilities for cross references and probably, I will delete the bidirectional references of my meta-model to manage simple relationships. When I want to explore the model in a reverse viewer, I use the cross references instead the opposite relations, and besides, without bidirectional references, disappear the problem I had with several related models having only one in editing mode ...

However, I wanted to know how can I tune a meta-model with bidirectional relationships for being more efficient when a model is loaded. I have noticed that the performance of application decrease at that point with huge models when contains bidirectional relationships, and probably I don't know what is the best ecore configuration.

Thanks in advance.
Best regards.
Carlos.
Re: Eopposite [message #492661 is a reply to message #492657] Wed, 21 October 2009 09:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070801050500090002050205
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Carlos,

Comments below.

Carlos wrote:
> Hi Ed,
>
> I have solved my problem with the utilities for cross references and
> probably, I will delete the bidirectional references of my meta-model
> to manage simple relationships. When I want to explore the model in a
> reverse viewer, I use the cross references instead the opposite
> relations, and besides, without bidirectional references, disappear
> the problem I had with several related models having only one in
> editing mode ...
>
> However, I wanted to know how can I tune a meta-model with
> bidirectional relationships for being more efficient when a model is
> loaded. I have noticed that the performance of application decrease at
> that point with huge models when contains bidirectional relationships,
> and probably I don't know what is the best ecore configuration.
Options like this might help:

/**
* Defer resolution of same document references until the end of
the document is reached.
*/
String OPTION_DEFER_IDREF_RESOLUTION = "DEFER_IDREF_RESOLUTION";

Are you using intrinsic IDs (EAttributes with isID true), extrinsic IDs
(e.g., xmi:id), or fragment paths?
>
> Thanks in advance.
> Best regards.
> Carlos.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Carlos,<br>
<br>
Comments below.<br>
<br>
Carlos wrote:
<blockquote cite="mid:hbmksg$pmp$1@build.eclipse.org" type="cite">Hi
Ed,
<br>
<br>
I have solved my problem with the utilities for cross references and
probably, I will delete the bidirectional references of my meta-model
to manage simple relationships. When I want to  explore the model in a
reverse viewer, I use the cross references instead the opposite
relations, and besides, without bidirectional references, disappear the
problem I had with several related models having only one in editing
mode ...
<br>
<br>
However, I wanted to know how can I tune a meta-model with
bidirectional relationships for being more efficient when a model is
loaded. I have noticed that the performance of application decrease at
that point with huge models when contains bidirectional relationships,
and probably I don't know what is the best ecore configuration.
<br>
</blockquote>
Options like this might help:<br>
<blockquote>  /**<br>
   * Defer resolution of same document references until the end of the
document is reached.<br>
   */<br>
  String OPTION_DEFER_IDREF_RESOLUTION = "DEFER_IDREF_RESOLUTION";<br>
</blockquote>
Are you using intrinsic IDs (EAttributes with isID true), extrinsic IDs
(e.g., xmi:id), or fragment paths?<br>
<blockquote cite="mid:hbmksg$pmp$1@build.eclipse.org" type="cite"><br>
Thanks in advance.
<br>
Best regards.
<br>
Carlos.
<br>
</blockquote>
</body>
</html>

--------------070801050500090002050205--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Eopposite [message #492665 is a reply to message #492661] Wed, 21 October 2009 10:03 Go to previous message
Carlos  is currently offline Carlos Friend
Messages: 52
Registered: September 2009
Member
I'm using XMI identifiers, xmi:id (property ID with true value).

Previous Topic:unload a proxy
Next Topic:ecore2ecore: can i control the mapping?
Goto Forum:
  


Current Time: Thu Mar 28 17:07:06 GMT 2024

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

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

Back to the top