Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti
Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti [message #658966] Thu, 10 March 2011 15:12 Go to next message
Dobrou Mising name is currently offline Dobrou Mising nameFriend
Messages: 16
Registered: December 2010
Junior Member
Graphiti methods (examples at the end), that work with business objects, use org.eclipse.emf.ecore.util.EcoreUtil.equals(EObject, EObject) for comparing objects.

EcoreUtil.equals use EqualityHelper whose Javadoc says "... determining whether two EObjects are structurally equal. Two EObjects, eObject1 and eObject2, are structurally equal if their classes are the same, and if, for each non-derived feature of the class, the isSet states are the same and the corresponding values are structurally equal as appropriate for the type of feature. ..."

But in my project, it's possible to have two instances of business objects, that are structurally equal, but they are still different objects.
That means Graphiti takes some objects as equal, even if they shouldn't be.
Correct behaviour would be using "==" when comparing two bussiness EObjects for equality.


Call hierarchy of equals(EObject, EObject) : boolean - org.eclipse.emf.ecore.util.EcoreUtil
	getAllPictogramElementsForBusinessObject(Object) : PictogramElement[] - org.eclipse.graphiti.features.impl.AbstractFeatureProvider
	getElementsNotInDiagram(EObject[], Diagram) : EObject[] - org.eclipse.graphiti.internal.services.impl.PeServiceImpl
	getLinkedDiagrams(PictogramElement) : Collection<Diagram> - org.eclipse.graphiti.ui.features.AbstractDrillDownFeature
	getLinkedPictogramElements(EObject[], Diagram) : Object[] - org.eclipse.graphiti.internal.services.impl.PeServiceImpl
	getPictogramElementForBusinessObject(Object) : PictogramElement - org.eclipse.graphiti.features.impl.AbstractFeatureProvider
	getPictogramElements(Diagram, EObject) : List<PictogramElement> - org.eclipse.graphiti.internal.services.impl.LinkServiceImpl


For example:
I have two different instances of EObject: Obj1 and Obj2. Obj1 and Obj2 are different instances! but they are structurally equal. Obj1 is linked from diagram and Obj2 is not linked.
Calling getPictogramElements( Diagram, Obj2) return PictogramElements with link to Obj1.


Is it possible to convince Graphiti those Obj1 and Obj2 are not "equal" ?

[Updated on: Thu, 10 March 2011 15:15]

Report message to a moderator

Re: Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti f [message #658969 is a reply to message #658966] Thu, 10 March 2011 15:19 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Dobrou,

maybe the easiest way would be to add an "ID" feature to your objects.
Then the EMF mechanism would distinguish the objects.

Best, Tim
Re: Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti f [message #658972 is a reply to message #658969] Thu, 10 March 2011 15:24 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
The issue is already tracked:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=335828
Re: Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti [message #658989 is a reply to message #658966] Thu, 10 March 2011 15:58 Go to previous messageGo to next message
Dobrou Mising name is currently offline Dobrou Mising nameFriend
Messages: 16
Registered: December 2010
Junior Member
Thank you for bug link and sorry for duplicate announcement.
Re: Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti [message #659281 is a reply to message #658966] Fri, 11 March 2011 19:40 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Hi,

I have similar problems with the EcoreUtil.equals. In our case, we use CDO and the EObject we compare are (CDO)invalid, which means that you cannot get any feature value from it. Graphiti then dies ungracefully.

Using the ID feature does not help, because that still needs access to the values of a feature of the invalid object.

I do think that == is also a valid definition of being equal, users should at least have the choice.

Jos
Re: Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti [message #659476 is a reply to message #659281] Mon, 14 March 2011 08:40 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
I think the best solution would be to introduce a hook for tool builders,
see my latest comment in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=335828

Michael

"Jos Warmer" wrote in message news:ildtdm$n3e$1@news.eclipse.org...

Hi,

I have similar problems with the EcoreUtil.equals. In our case, we use CDO
and the EObject we compare are (CDO)invalid, which means that you cannot get
any feature value from it. Graphiti then dies ungracefully.

Using the ID feature does not help, because that still needs access to the
values of a feature of the invalid object.

I do think that == is also a valid definition of being equal, users should
at least have the choice.

Jos
Re: Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti [message #742486 is a reply to message #659476] Thu, 20 October 2011 14:38 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Ouch... another one hit by this one, here Rolling Eyes , several hours trying to understand why some pictograms appeared as linked to more BO that it should...

Perhaps this should be more prominent in the docs... and perhaps the javadoc should say something that "This is only relevant (but VERY relevant) for business objects that are to be linked with pictogram elements)" (I think this is true, isn't it?)
Also, that it will only called for objects linked in the same diagram (so, for example, if we have some sort of local ID, that's enough) (isn't it?)

Actually, I'm not sure about why the simple == would be not enough. Someone commented about unloaded resources, but it's not clear for me.

[Updated on: Thu, 20 October 2011 14:57]

Report message to a moderator

Re: Incorrect behaviour from using &quot;EcoreUtil.equals&quot; instead &quot;==&quo [message #747739 is a reply to message #742486] Mon, 24 October 2011 08:53 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
I added some JavaDoc on this to the linking, getBO... and getPE... methods
on this.

Michael
Previous Topic:Removing remove
Next Topic:Sizing Multi-line text
Goto Forum:
  


Current Time: Wed Apr 24 19:18:59 GMT 2024

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

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

Back to the top