eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

eGet()-like feature with OCL #1414

Closed eclipse-ocl-bot closed 1 month ago

eclipse-ocl-bot commented 1 month ago

| --- | --- | | Bugzilla Link | 452683 | | Status | RESOLVED DUPLICATE of bug 452972 | | Importance | P3 normal | | Reported | Nov 21, 2014 11:46 EDT | | Modified | Nov 24, 2014 06:44 EDT | | Version | 5.0.0 | | Reporter | Yves BERNARD |

Description

Continuing discussion I wrongly started in the bug287052 thread:

I'm endeavouring to support the OMG specifications, where you will find no reference to EObject, eClass(), eGet() etc, so yes, avoid eGet() wherever possible a) because it's non-OMG, b) because when used in Eclipse OCL its polymorphic Object/List return is broken.

The point is that the ability to deal with model elements in a generic way is sometimes useful(unavoidable?). Example: assume I have to write a query returning the index of a value specification in a collection assigned to a slot of an instance specification. I need to make it work for any slot of any instance specification. The (classifier,feature) couple allowing to get this information is not known in advance, it has to be discovered. How to do this without generic interfaces as those provided by Ecore?

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Nov 21, 2014 13:45

I don't understand why indexOf() and oclAsType() cannot solve the problem.

eclipse-ocl-bot commented 1 month ago

By Yves BERNARD on Nov 24, 2014 06:23

Maybe my example is not that good. Actually it can easily be solved when you know that the value specification is owned by a slot and that the feature of uml::Slot that owns this value specification is "value".

If you want that this query can work with any value specification (i.e. independently of what it is owned by) you would have to write a specific code for each possible kind of value specification owner.

In the example I gave, the OCL expression: self.owner.oclType().oclType()\ is evaluated to 'Metaclass(UML::Slot)' in the context of one of the value specification. This "metaclass level" could provide the expected genericity but it does not seem possible to cast it to a uml::Class (albeit it should be one, formally).

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Nov 24, 2014 06:44

(In reply to Yves BERNARD from comment #2)

In the example I gave, the OCL expression: self.owner.oclType().oclType() is evaluated to 'Metaclass(UML::Slot)'

Things have moved on. My OCL colleagues disliked the power/complexity of Metaclass(T) when all that was required was a simple typeof() annotation. The current prototype is much simpler becuase of their comments.

oclType() returns an OCL::Class not a UML::Class.

I raised Bug 452972 neglecting this one, so I'll close this as a duplicate.

This bug has been marked as a duplicate of bug 452972