Home » Modeling » OCL » using @pre. operator. in the PostConditions
| | | | | | |
Re: using @pre. operator. in the PostConditions [message #655916 is a reply to message #655830] |
Wed, 23 February 2011 09:54 |
Hussam Messages: 19 Registered: January 2011 |
Junior Member |
|
|
Thank you Edward,
The result is that : @pre may only used in an operation postcondition constraint ..
my problem is that I was using the @pre operator in an OCL expression which to be used in an invariant and not a post condition.
but I think in my situation to use the oclHelper.createPostcondition() it needs the OperationContext to be defined as i discussed above with Axel.. but in this case also I have a problem that the Operation that I need to use the pre and post conditions for it is a pure Java Method which uses any UML model to make some operation in it. I wich it is clear, I mean, my Operation is not coming from a UML model, but it will use some element from any UML model as an input to produce some outputs, my Postconditions has to check that this operation produces the correct results:
Example:
I have one of my operation:
public void connectTwoClasses(Dependency connection){
//the preconditions are to make sure that there is a dependency with Stereotype <<ConnectClasses>> and the ends of this dependency must be of type Class.
I made them by the oclHelper.createInvariant(String exp)
the context is the UML model ,any UML model which will contains this classes and the connection elements.
//the postconditions are to cheak whether the connection is made correctly by query the number of interfaces , the number of Association before and after , of course I need to use the @pre . So how to use the OperationContext in this case as the connectTwoClasses(Dependency connection) operation is not in the UML model which will be used as an input for this method?
}
best regards,
|
|
|
Re: using @pre. operator. in the PostConditions [message #655999 is a reply to message #655916] |
Wed, 23 February 2011 17:05 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
I really do not understand your problem because you present only small
excerpts that you think are interesting.
> public void connectTwoClasses(Dependency connection){
> //the preconditions are to make sure that there is a dependency with
> Stereotype <<ConnectClasses>> and the ends of this dependency must be of
> type Class.
public void connectTwoClasses(Dependency connection)
is a Java declaration. It is not OCL, so I am unclear why you expect OCL
post conditions to be relevant.
Regards
Ed Willink
On 23/02/2011 09:54, Hussam wrote:
> Thank you Edward,
>
> The result is that : @pre may only used in an operation postcondition
> constraint ..
>
>
> my problem is that I was using the @pre operator in an OCL expression
> which to be used in an invariant and not a post condition.
> but I think in my situation to use the oclHelper.createPostcondition()
> it needs the OperationContext to be defined as i discussed above with
> Axel.. but in this case also I have a problem that the Operation that I
> need to use the pre and post conditions for it is a pure Java Method
> which uses any UML model to make some operation in it. I wich it is
> clear, I mean, my Operation is not coming from a UML model, but it will
> use some element from any UML model as an input to produce some outputs,
> my Postconditions has to check that this operation produces the correct
> results:
>
> Example:
>
> I have one of my operation:
>
> public void connectTwoClasses(Dependency connection){
> //the preconditions are to make sure that there is a dependency with
> Stereotype <<ConnectClasses>> and the ends of this dependency must be of
> type Class.
>
> I made them by the oclHelper.createInvariant(String exp)
>
> the context is the UML model ,any UML model which will contains this
> classes and the connection elements.
> //the postconditions are to cheak whether the connection is made
> correctly by query the number of interfaces , the number of Association
> before and after , of course I need to use the @pre . So how to use the
> OperationContext in this case as the connectTwoClasses(Dependency
> connection) operation is not in the UML model which will be used as an
> input for this method?
>
> }
>
>
>
>
> best regards,
>
>
|
|
| |
Re: using @pre. operator. in the PostConditions [message #656124 is a reply to message #656006] |
Thu, 24 February 2011 10:06 |
Hussam Messages: 19 Registered: January 2011 |
Junior Member |
|
|
Hi Axel,
You are right ,that I have a java method which is not modeled , my program is not modeled .
to make it more clear:
I am writing a program , this program has to work with the UML models itself, I mean I need to for example add new Interface or Association or Class into the model not manually but automatically , my program will do that. So for adding a new Association between two classes , there are too many elements to be added , Like the interface represented that Association, The Dependencies between the classes and that new added Interface and so on.
my Java method will take the UML Model (Any UML model the user want to use my program to evolve it or to add some new elements ..) as an Input , some preconditions have to be checked before invoking the Java method and I need also to check some postconditions on that Model(The Input model). that means , if I want to model my method , I would have two models, one for my program, and the Input one that my program will evolve it.
So, if it is possible to use the Postconditions without modelling ,please tell me how? if not , is there any way to retrieve the number of elements of specified type in the input model pre and after the implementing of the method using OCL?
one more possibility of help:
Do you know a tool or plugin which coukld be used to generate a UML model for my Java program so that it would be used in Papyrus or like that.
Regards,
|
|
|
Re: using @pre. operator. in the PostConditions [message #656134 is a reply to message #656124] |
Thu, 24 February 2011 10:23 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
It seems you are doing a model to model transformation, so rather than
'my Java method', I would suggest QVTo or ATL. These understand OCL so
you may find that you have the environment you want. You just need to
keep a clear head to avoid confusion between the OCL in the tooling and
the OCL in the generated code, where I would probably recommend
synthesizing a text string in an OpaqueExpression rather than an AST in
an ExpressionInOcl.
Papyrus is a steadily improving tool for UML, so I don't understand
why you want advice on a tool to produce UML for Papyrus.
Regards
Ed Willink
On 24/02/2011 10:06, Hussam wrote:
> Hi Axel,
>
> You are right ,that I have a java method which is not modeled , my
> program is not modeled .
>
> to make it more clear:
>
> I am writing a program , this program has to work with the UML models
> itself, I mean I need to for example add new Interface or Association or
> Class into the model not manually but automatically , my program will do
> that. So for adding a new Association between two classes , there are
> too many elements to be added , Like the interface represented that
> Association, The Dependencies between the classes and that new added
> Interface and so on.
>
> my Java method will take the UML Model (Any UML model the user want to
> use my program to evolve it or to add some new elements ..) as an Input
> , some preconditions have to be checked before invoking the Java method
> and I need also to check some postconditions on that Model(The Input
> model). that means , if I want to model my method , I would have two
> models, one for my program, and the Input one that my program will
> evolve it.
>
> So, if it is possible to use the Postconditions without modelling
> ,please tell me how? if not , is there any way to retrieve the number of
> elements of specified type in the input model pre and after the
> implementing of the method using OCL?
>
> one more possibility of help:
> Do you know a tool or plugin which coukld be used to generate a UML
> model for my Java program so that it would be used in Papyrus or like that.
>
>
> Regards,
>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 03:35:39 GMT 2024
Powered by FUDForum. Page generated in 0.03324 seconds
|