| Home » Modeling » OCL » accessing dynamic eobject api + function libraries
 Goto Forum:| 
| accessing dynamic eobject api + function libraries [message #22906] | Thu, 10 May 2007 13:27  |  | 
| Eclipse User  |  |  |  |  | i would like to be able to check whether an attribute is actually set or not within an expression, and unset it if necessary within an ocl
 expression.
 
 how can i call the eobject dynamic methods such as eIsSet(x),
 isUnsettable(x)  unset(x) etc within an OCL expression?
 
 thanks in advance,
 kagan
 |  |  |  |  |  |  |  |  | 
| Re: accessing dynamic eobject api + function libraries [message #23880 is a reply to message #23670] | Thu, 17 May 2007 09:10   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: cdamus.ca.ibm.com 
 Hi, Antonio,
 
 You can take this one step further by not actually implementing the
 modelClass property in your Ecore model (which might be seen as breaking
 the model's semantic cohesion, especially as it crosses meta-levels), but
 rather defining it in a custom Ecore environment as an OCL-defined
 "additional attribute", for use by OCL constraints only.
 
 See the newly-added Programmer's Guide topic in the M7 build, that discusses
 how to extend the environment for this kind of situation, with a working
 example.  The example defines an additional operation, but the mechanism is
 the same:
 
 OCL Developer Guide
 Programmer's Guide
 Advanced Topics
 Customizing the Environment
 
 The example adds a regexMatch() operation to the String primitive type.  It
 is actually implemented in the
 org.eclipse.ocl.ecore.tests.EcoreEnvironmentTest class, verbatim from the
 guide.
 
 Cheers,
 
 Christian
 
 
 Antonio Carrasco wrote:
 
 > You may try implementing a property (added to your .ecore before
 > generation),
 > returning the instance of the ecore:EClass metaclass,
 > then you can reason over it with OCL.
 >
 >    Youll need to add the ecore metamodel Ecore.ecore
 >    as a resource to your own .ecore metamodel.
 >
 > For any side effects, you may just invoke any method of your own
 > implementation.
 >
 > Thats breaking the rules, right.
 > Thats why we put them there, first!
 >
 > <eClassifiers xsi:type="ecore:EClass" name="ConModelClass"
 > abstract="true">
 >
 > <eStructuralFeatures xsi:type="ecore:EReference" name="modelClass"
 > lowerBound="1" eType="ecore:EClass
 >  ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EC lass "
 > changeable="false" volatile="true" transient="true" derived="true"/>
 >
 > </eClassifiers>
 >
 > From the OCL console:
 > Evaluating:
 >
 > self.modelClass
 >
 > Results:
 >
 > EClass Proceso
 >
 >
 > Evaluating:
 >
 > self.modelClass.eAllAttributes
 >
 > Results:
 >
 > EAttribute codigoYNombre
 >
 > EAttribute codigo
 >
 > EAttribute nombre
 >
 > EAttribute codigoCompleto
 
 <snip>
 |  |  |  |  |  |  |  |  | 
| oclType, Re: accessing dynamic eobject api + function libraries [message #43504 is a reply to message #22950] | Sun, 18 November 2007 06:28   |  | 
| Eclipse User  |  |  |  |  | Hi, Christian. Is oclType now accessible in the newest version of the ocl.ecore,
 or do I need to add it by hand to the environment?
 
 I came to the problem trying to access eContainer, an Issue I will
 describe in a separate post.
 
 Best, Philipp
 
 Christian W. Damus wrote 10.05.2007:
 > Hi, Kagan,
 >
 > In any case, you should never be able to call eUnset() because OCL is a
 > side-effect-free language.  Its semantics do not allow the modification of
 > the model that it is constraining/querying.
 >
 > Regarding eIsSet() and isUnsettable():  OCL provides no means to access the
 > metamodel of the model that it is constraining.  That is, you can check
 > whether
 >
 >     self.oclIsKindOf(Xyz)
 >
 > but you cannot do
 >
 >     self.oclType
 >
 > to get the Xyz metaclass in order then to do
 >
 >    self.oclType.getEStructuralFeature("x")
 >
 > I don't know whether this is an accidental or intentional omission from the
 > spec.  I suspect that it is accidental because the UML 2.1 specification
 > actually uses such non-existent constructs as "self.oclType" in defining
 > its constraints.
 >
 > Cheers,
 >
 > Christian
 >
 >
 > Kagan Turgut wrote:
 >
 >> i would like to be able to check whether an attribute is actually set or
 >>     not within an expression, and unset it if necessary within an ocl
 >> expression.
 >>
 >> how can i call the eobject dynamic methods such as eIsSet(x),
 >> isUnsettable(x)  unset(x) etc within an OCL expression?
 >>
 >> thanks in advance,
 >> kagan
 >
 |  |  |  |  | 
| Re: oclType, Re: accessing dynamic eobject api + function libraries [message #43598 is a reply to message #43504] | Mon, 19 November 2007 08:13  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: cdamus.ca.ibm.com 
 Hi, Philipp,
 
 Nope, oclType isn't available yet, and probably won't be until the OMG
 defines it.
 
 Of course, one could consider, in the mean-time, sneaking it in via a new
 ProblemOption (error by default) for those clients that don't mind
 depending on non-standard constructs.  The problem with that, though, is
 that probably the OMG would end up defining something different, which
 makes for an incompatible transition for these clients, anyway.
 
 Cheers,
 
 Christian
 
 
 Philipp W. Kutter wrote:
 
 > Hi, Christian.
 > Is oclType now accessible in the newest version of the ocl.ecore,
 > or do I need to add it by hand to the environment?
 >
 > I came to the problem trying to access eContainer, an Issue I will
 > describe in a separate post.
 >
 > Best, Philipp
 >
 
 -----8<-----
 |  |  |  | 
 
 
 Current Time: Thu Oct 30 22:11:15 EDT 2025 
 Powered by FUDForum . Page generated in 0.04599 seconds |