Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Direct access to pre/post conditions of an context operation
Direct access to pre/post conditions of an context operation [message #68466] Thu, 05 March 2009 16:27 Go to next message
Timothy Marc is currently offline Timothy Marc
Messages: 547
Registered: July 2009
Senior Member
Hey all again,

is there the possibility to navigate directly to a pre/post condition of
an operation, defined in a ocl document. i want to handle only some
preconditions, which have specific name.

I was wondering, that there is no getPreconditions() metod for
operations. i know, inside the uml spec, every operation can define a
number of pre/postconditions directly. but how can i access the ast of
each precondition, if i haven't the possibility to access them?

and is there the possibility to serialize the generated ast (the ocl
metamodel instrance) for visualizing it with the emf editor?

thanks again. i hope after getting access to the pre/ostconditions, i
won't have so much questions any more. imho, in contrast to the uml
spec, the ocl spec is much more confusing and harder to understand.

Timothy
Re: Direct access to pre/post conditions of an context operation [message #68507 is a reply to message #68466] Fri, 06 March 2009 14:01 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

Hi, Timothy,

See some replies in-line, below.

HTH,

Christian


Timothy Marc wrote:
> Hey all again,
>
> is there the possibility to navigate directly to a pre/post condition of
> an operation, defined in a ocl document. i want to handle only some
> preconditions, which have specific name.

If you assign your constraints names (between the "pre" or "post"
keyword and the colon), then you will be able to find them again, after
parsing.

You can determine that a constraint is a pre- or post-condition of an
operation by checking that UMLReflection::getConstrainedElements(...)
includes your operation. Get the name of the constraint using
UMLReflection::getName(...).


> I was wondering, that there is no getPreconditions() metod for
> operations. i know, inside the uml spec, every operation can define a
> number of pre/postconditions directly. but how can i access the ast of
> each precondition, if i haven't the possibility to access them?

The OCL façade object through which you parsed the OCL constraints keeps
track of them. You can find them all using OCL::getConstraints().
These are the ASTs. Then, it's a matter of using the UMLReflection API
as I mentioned above to find the right constraint. There is potential,
here, for handy additions to the OCLUtil class ...


> and is there the possibility to serialize the generated ast (the ocl
> metamodel instrance) for visualizing it with the emf editor?

Yes. You can serialize the environment, which includes all of the
constraints that you parsed, additional operation/attribute definitions
("helpers"), demand-created collection types, etc. Just get the
Environment's resource, set a useful URI, and save it:

Environment<...> myEnv = /* ... */;
Resource res = myEnv.getTypeResolver().getResource();
// set res's URI and save it


> thanks again. i hope after getting access to the pre/ostconditions, i
> won't have so much questions any more. imho, in contrast to the uml
> spec, the ocl spec is much more confusing and harder to understand.

Well, the newsgroup is always here to answer. :-)


> Timothy
Re: Direct access to pre/post conditions of an context operation [message #68540 is a reply to message #68507] Fri, 06 March 2009 16:35 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy Marc
Messages: 547
Registered: July 2009
Senior Member
Dear Christian,

thanks again for that detailed answer, and i will accept your invitation
for posting questions here one times more:

I have (for the first time) a very simple ocl expression:

context AccountManager::store(currentBalance:Integer,money:Integer): Integer
pre handy: currentBalance > 0

When i parse this document and get the OperationCallExp with the
operation code 68, which stands for greater-than. But is there somewhere
a lookup table or a document, where the operation codes are described?

Thx Timothy
Re: Direct access to pre/post conditions of an context operation [message #68551 is a reply to message #68540] Fri, 06 March 2009 16:46 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy Marc
Messages: 547
Registered: July 2009
Senior Member
Again, don't care. Just yet browsed to the correct class in the API
documentation. Sorry for asking to fast.

Timothy Marc schrieb:
> Dear Christian,
>
> thanks again for that detailed answer, and i will accept your invitation
> for posting questions here one times more:
>
> I have (for the first time) a very simple ocl expression:
>
> context AccountManager::store(currentBalance:Integer,money:Integer): Integer
> pre handy: currentBalance > 0
>
> When i parse this document and get the OperationCallExp with the
> operation code 68, which stands for greater-than. But is there somewhere
> a lookup table or a document, where the operation codes are described?
>
> Thx Timothy
Re: Direct access to pre/post conditions of an context operation [message #68561 is a reply to message #68507] Fri, 06 March 2009 20:36 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy Marc
Messages: 547
Registered: July 2009
Senior Member
Christian,

so, it is me again for the (hopefully) last question today. I tried to
serialize the parsed ast, but i got a ClassNotFoundException, when i
open the xmi with the sample reflective edtitor.

The Class "ExpressionInOcl" could not be found. I think, the connection
to the ocl.uml metamodel is lost??? Is it so?

And by the way, how can the OCL AST View be used? I don't know how to
pass an ast to it, since it seems that there is no functionality
implemented.

Thx
Timothy

Christian W. Damus schrieb:
> Hi, Timothy,
>
> See some replies in-line, below.
>
> HTH,
>
> Christian
>
>
> Timothy Marc wrote:
>> Hey all again,
>>
>> is there the possibility to navigate directly to a pre/post condition
>> of an operation, defined in a ocl document. i want to handle only some
>> preconditions, which have specific name.
>
> If you assign your constraints names (between the "pre" or "post"
> keyword and the colon), then you will be able to find them again, after
> parsing.
>
> You can determine that a constraint is a pre- or post-condition of an
> operation by checking that UMLReflection::getConstrainedElements(...)
> includes your operation. Get the name of the constraint using
> UMLReflection::getName(...).
>
>
>> I was wondering, that there is no getPreconditions() metod for
>> operations. i know, inside the uml spec, every operation can define a
>> number of pre/postconditions directly. but how can i access the ast of
>> each precondition, if i haven't the possibility to access them?
>
> The OCL façade object through which you parsed the OCL constraints keeps
> track of them. You can find them all using OCL::getConstraints(). These
> are the ASTs. Then, it's a matter of using the UMLReflection API as I
> mentioned above to find the right constraint. There is potential, here,
> for handy additions to the OCLUtil class ...
>
>
>> and is there the possibility to serialize the generated ast (the ocl
>> metamodel instrance) for visualizing it with the emf editor?
>
> Yes. You can serialize the environment, which includes all of the
> constraints that you parsed, additional operation/attribute definitions
> ("helpers"), demand-created collection types, etc. Just get the
> Environment's resource, set a useful URI, and save it:
>
> Environment<...> myEnv = /* ... */;
> Resource res = myEnv.getTypeResolver().getResource();
> // set res's URI and save it
>
>
>> thanks again. i hope after getting access to the pre/ostconditions, i
>> won't have so much questions any more. imho, in contrast to the uml
>> spec, the ocl spec is much more confusing and harder to understand.
>
> Well, the newsgroup is always here to answer. :-)
>
>
>> Timothy
Re: Direct access to pre/post conditions of an context operation [message #68615 is a reply to message #68561] Wed, 11 March 2009 13:28 Go to previous message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

Hi, Timothy,

Is your code running in an Eclipse instance? If so, you should have no
trouble find this class because the OCL-UML metamodel is statically
registered. Otherwise, you would have to take care of the package
registrations, yourself. The org.eclipse.ocl.standalone.tests project
provides a complete example of how to do that: it runs the OCL JUnit
tests in an Eclipse-free context.

I don't know what condition the OCL AST View is in. It hasn't been
updated in years, as far as I know, so it may be out of touch with the
OCL API. Best to ask its authors about that.

HTH,

Christian


Timothy Marc wrote:
> Christian,
>
> so, it is me again for the (hopefully) last question today. I tried to
> serialize the parsed ast, but i got a ClassNotFoundException, when i
> open the xmi with the sample reflective edtitor.
>
> The Class "ExpressionInOcl" could not be found. I think, the connection
> to the ocl.uml metamodel is lost??? Is it so?
>
> And by the way, how can the OCL AST View be used? I don't know how to
> pass an ast to it, since it seems that there is no functionality
> implemented.
>
> Thx
> Timothy
>
> Christian W. Damus schrieb:
>> Hi, Timothy,
>>
>> See some replies in-line, below.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Timothy Marc wrote:
>>> Hey all again,
>>>
>>> is there the possibility to navigate directly to a pre/post condition
>>> of an operation, defined in a ocl document. i want to handle only
>>> some preconditions, which have specific name.
>>
>> If you assign your constraints names (between the "pre" or "post"
>> keyword and the colon), then you will be able to find them again,
>> after parsing.
>>
>> You can determine that a constraint is a pre- or post-condition of an
>> operation by checking that UMLReflection::getConstrainedElements(...)
>> includes your operation. Get the name of the constraint using
>> UMLReflection::getName(...).
>>
>>
>>> I was wondering, that there is no getPreconditions() metod for
>>> operations. i know, inside the uml spec, every operation can define a
>>> number of pre/postconditions directly. but how can i access the ast
>>> of each precondition, if i haven't the possibility to access them?
>>
>> The OCL façade object through which you parsed the OCL constraints
>> keeps track of them. You can find them all using
>> OCL::getConstraints(). These are the ASTs. Then, it's a matter of
>> using the UMLReflection API as I mentioned above to find the right
>> constraint. There is potential, here, for handy additions to the
>> OCLUtil class ...
>>
>>
>>> and is there the possibility to serialize the generated ast (the ocl
>>> metamodel instrance) for visualizing it with the emf editor?
>>
>> Yes. You can serialize the environment, which includes all of the
>> constraints that you parsed, additional operation/attribute
>> definitions ("helpers"), demand-created collection types, etc. Just
>> get the Environment's resource, set a useful URI, and save it:
>>
>> Environment<...> myEnv = /* ... */;
>> Resource res = myEnv.getTypeResolver().getResource();
>> // set res's URI and save it
>>
>>
>>> thanks again. i hope after getting access to the pre/ostconditions, i
>>> won't have so much questions any more. imho, in contrast to the uml
>>> spec, the ocl spec is much more confusing and harder to understand.
>>
>> Well, the newsgroup is always here to answer. :-)
>>
>>
>>> Timothy
Previous Topic:Pre-compiled OCL expressions?
Next Topic:[Announce] MDT OCL 1.3.0 I200903110918 is available
Goto Forum:
  


Current Time: Sun Oct 26 05:05:40 GMT 2014

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

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