|Incorrect behaviour from using "EcoreUtil.equals" instead "==" in Graphiti [message #658966]
||Thu, 10 March 2011 15:12
| Dobrou Mising name
Registered: December 2010
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
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 [message #742486 is a reply to message #659476]
||Thu, 20 October 2011 14:38
| Hernan Gonzalez
Registered: October 2010
Location: Buenos Aires, Argentina
Ouch... another one hit by this one, here , 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
Powered by FUDForum
. Page generated in 0.02287 seconds