Home » Modeling » OCL » New to EMF and OCL
| | |
Re: New to EMF and OCL [message #478773 is a reply to message #468435] |
Thu, 06 August 2009 19:26 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Richard
setHardwareNotes is an implementation artefact created by EMF, it is not
part of the Ecore class, so it is not accessible from OCL, although the
OCL implementation may use it.
You have defined a property so that is what you should use.
self.hardwareNotes = 'hw1'
Regards
Ed Willink
Richard Catlin wrote:
> Further thoughts on this question:
>
> If I create a simple EClass called Architecture in Ecore with a property
> of "hardwareNotes", then when I generate the model, a
> setHardwareNotes(String name) method is generated. When I use the
> Interactive OCL Console, I get the following error:
>
> self.setHardwareNotes('hw1')
>
> Cannot find operation (setHardwareNotes(String)) for the type
> (Architecture)
>
> How can I go about setting this?
>
> Thank you,
> Richard
>
> On 8/4/2009 8:13 PM, Richard Catlin wrote:
>> All,
>>
>> I am using the EMF Framework Validation Plug-in: "OCL Example". It
>> allows me to write OCL expressions in a text file.
>>
>> Is it possible to set properties in the model based on OCL
>> expressions? The OCL 2.0 Spec says that expressions are guaranteed to
>> be without side effects, but then goes on to say that OCL expressio
>> can be used to specify a state change (eg. in a post-condition).
>>
>> Pardon me if this is an obvious question. I am new to EMF and OCL.
>>
>> Thank you,
>> Richard Catlin
|
|
|
Re: New to EMF and OCL [message #478801 is a reply to message #478773] |
Fri, 07 August 2009 00:23 |
Richard Catlin Messages: 50 Registered: July 2009 |
Member |
|
|
Ed,
I'm not sure where I should use
self.hardwareNotes = 'hw1'
I am using the OCL text file, so should it be something like this?
package sizing
context: Architecture
if(true)
self.hardwareNotes = 'hw1'
end
endpackage
Thank you for your help.
Regards,
Richard Catlin
On 8/6/2009 12:26 PM, Ed Willink wrote:
> Hi Richard
>
> setHardwareNotes is an implementation artefact created by EMF, it is not
> part of the Ecore class, so it is not accessible from OCL, although the
> OCL implementation may use it.
>
> You have defined a property so that is what you should use.
>
> self.hardwareNotes = 'hw1'
>
> Regards
>
> Ed Willink
>
>
> Richard Catlin wrote:
>> Further thoughts on this question:
>>
>> If I create a simple EClass called Architecture in Ecore with a
>> property of "hardwareNotes", then when I generate the model, a
>> setHardwareNotes(String name) method is generated. When I use the
>> Interactive OCL Console, I get the following error:
>>
>> self.setHardwareNotes('hw1')
>>
>> Cannot find operation (setHardwareNotes(String)) for the type
>> (Architecture)
>>
>> How can I go about setting this?
>>
>> Thank you,
>> Richard
>>
>> On 8/4/2009 8:13 PM, Richard Catlin wrote:
>>> All,
>>>
>>> I am using the EMF Framework Validation Plug-in: "OCL Example". It
>>> allows me to write OCL expressions in a text file.
>>>
>>> Is it possible to set properties in the model based on OCL
>>> expressions? The OCL 2.0 Spec says that expressions are guaranteed
>>> to be without side effects, but then goes on to say that OCL
>>> expressio can be used to specify a state change (eg. in a
>>> post-condition).
>>>
>>> Pardon me if this is an obvious question. I am new to EMF and OCL.
>>>
>>> Thank you,
>>> Richard Catlin
|
|
|
Re: New to EMF and OCL [message #478814 is a reply to message #478801] |
Fri, 07 August 2009 04:50 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
HI Richard
I am sorry, but if you want help learning the OCL lanaguage you should
consult one of the inline guides or buy a book. I found that Warmer and
Kleppe's book is very readable.
Regards
Ed Willink
Richard Catlin wrote:
> Ed,
>
> I'm not sure where I should use
> self.hardwareNotes = 'hw1'
>
> I am using the OCL text file, so should it be something like this?
>
> package sizing
>
> context: Architecture
> if(true)
> self.hardwareNotes = 'hw1'
> end
>
> endpackage
>
> Thank you for your help.
>
> Regards,
> Richard Catlin
>
>
> On 8/6/2009 12:26 PM, Ed Willink wrote:
>> Hi Richard
>>
>> setHardwareNotes is an implementation artefact created by EMF, it is
>> not part of the Ecore class, so it is not accessible from OCL,
>> although the OCL implementation may use it.
>>
>> You have defined a property so that is what you should use.
>>
>> self.hardwareNotes = 'hw1'
>>
>> Regards
>> Ed Willink
>>
>>
>> Richard Catlin wrote:
>>> Further thoughts on this question:
>>>
>>> If I create a simple EClass called Architecture in Ecore with a
>>> property of "hardwareNotes", then when I generate the model, a
>>> setHardwareNotes(String name) method is generated. When I use the
>>> Interactive OCL Console, I get the following error:
>>>
>>> self.setHardwareNotes('hw1')
>>>
>>> Cannot find operation (setHardwareNotes(String)) for the type
>>> (Architecture)
>>>
>>> How can I go about setting this?
>>>
>>> Thank you,
>>> Richard
>>>
>>> On 8/4/2009 8:13 PM, Richard Catlin wrote:
>>>> All,
>>>>
>>>> I am using the EMF Framework Validation Plug-in: "OCL Example". It
>>>> allows me to write OCL expressions in a text file.
>>>>
>>>> Is it possible to set properties in the model based on OCL
>>>> expressions? The OCL 2.0 Spec says that expressions are guaranteed
>>>> to be without side effects, but then goes on to say that OCL
>>>> expressio can be used to specify a state change (eg. in a
>>>> post-condition).
>>>>
>>>> Pardon me if this is an obvious question. I am new to EMF and OCL.
>>>>
>>>> Thank you,
>>>> Richard Catlin
|
|
|
Re: New to EMF and OCL - Question: If my method returns void, how do I use it in the invariant? [message #479164 is a reply to message #478814] |
Mon, 10 August 2009 03:38 |
Richard Catlin Messages: 50 Registered: July 2009 |
Member |
|
|
Ed,
Thanks. I ordered Kleppe's book. I was reading Ch 7 of the OCL Spec,
and did understand the syntax. The problem I was having was
understanding how to call a method on the generated code; mainly because
I was using the OCL text file to create the invariants. I finally got
this method to work:
public boolean setOutput1() {
setHardwareNotes("test33");
return true;
}
with the invariant declared as:
package sizing
context Architecture
inv inv_3: self.questions->size() < 1
inv inv_4: self.hardwareNotes = 'hw5'
inv inv_5: self.setOutput1()
endpackage
Question: If my method returns void, how do I use it in the invariant?
Regards,
Richard Catlin
On 8/6/2009 9:50 PM, Ed Willink wrote:
> HI Richard
>
> I am sorry, but if you want help learning the OCL lanaguage you should
> consult one of the inline guides or buy a book. I found that Warmer and
> Kleppe's book is very readable.
>
> Regards
>
> Ed Willink
>
> Richard Catlin wrote:
>> Ed,
>>
>> I'm not sure where I should use
>> self.hardwareNotes = 'hw1'
>>
>> I am using the OCL text file, so should it be something like this?
>>
>> package sizing
>>
>> context: Architecture
>> if(true)
>> self.hardwareNotes = 'hw1'
>> end
>>
>> endpackage
>>
>> Thank you for your help.
>>
>> Regards,
>> Richard Catlin
>>
>>
>> On 8/6/2009 12:26 PM, Ed Willink wrote:
>>> Hi Richard
>>>
>>> setHardwareNotes is an implementation artefact created by EMF, it is
>>> not part of the Ecore class, so it is not accessible from OCL,
>>> although the OCL implementation may use it.
>>>
>>> You have defined a property so that is what you should use.
>>>
>>> self.hardwareNotes = 'hw1'
>>>
>>> Regards
>>> Ed Willink
>>>
>>>
>>> Richard Catlin wrote:
>>>> Further thoughts on this question:
>>>>
>>>> If I create a simple EClass called Architecture in Ecore with a
>>>> property of "hardwareNotes", then when I generate the model, a
>>>> setHardwareNotes(String name) method is generated. When I use the
>>>> Interactive OCL Console, I get the following error:
>>>>
>>>> self.setHardwareNotes('hw1')
>>>>
>>>> Cannot find operation (setHardwareNotes(String)) for the type
>>>> (Architecture)
>>>>
>>>> How can I go about setting this?
>>>>
>>>> Thank you,
>>>> Richard
>>>>
>>>> On 8/4/2009 8:13 PM, Richard Catlin wrote:
>>>>> All,
>>>>>
>>>>> I am using the EMF Framework Validation Plug-in: "OCL Example". It
>>>>> allows me to write OCL expressions in a text file.
>>>>>
>>>>> Is it possible to set properties in the model based on OCL
>>>>> expressions? The OCL 2.0 Spec says that expressions are guaranteed
>>>>> to be without side effects, but then goes on to say that OCL
>>>>> expressio can be used to specify a state change (eg. in a
>>>>> post-condition).
>>>>>
>>>>> Pardon me if this is an obvious question. I am new to EMF and OCL.
>>>>>
>>>>> Thank you,
>>>>> Richard Catlin
|
|
|
Re: New to EMF and OCL - Question: If my method returns void, how do I use it in the invariant? [message #479169 is a reply to message #479164] |
Mon, 10 August 2009 05:14 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Richard
Any OCL expression is side effect free, so anything used in an OCL
invariant is side effect free, so why would you want to call a method
that returned void? the method returns nothing and so does nothing.
So the answer is you can't.
NB. Your inv_4 is a comparison not an assignment.
NB. Your inv-5 invokes a side effecting function and so is not a valid
OCL invariant.
Regards
Ed Willink
Richard Catlin wrote:
> Ed,
>
> Thanks. I ordered Kleppe's book. I was reading Ch 7 of the OCL Spec,
> and did understand the syntax. The problem I was having was
> understanding how to call a method on the generated code; mainly because
> I was using the OCL text file to create the invariants. I finally got
> this method to work:
>
> public boolean setOutput1() {
> setHardwareNotes("test33");
> return true;
> }
>
> with the invariant declared as:
>
> package sizing
>
> context Architecture
>
> inv inv_3: self.questions->size() < 1
>
> inv inv_4: self.hardwareNotes = 'hw5'
>
> inv inv_5: self.setOutput1()
>
> endpackage
>
> Question: If my method returns void, how do I use it in the invariant?
>
> Regards,
> Richard Catlin
>
>
>
> On 8/6/2009 9:50 PM, Ed Willink wrote:
>> HI Richard
>>
>> I am sorry, but if you want help learning the OCL lanaguage you should
>> consult one of the inline guides or buy a book. I found that Warmer
>> and Kleppe's book is very readable.
>>
>> Regards
>>
>> Ed Willink
>>
>> Richard Catlin wrote:
>>> Ed,
>>>
>>> I'm not sure where I should use
>>> self.hardwareNotes = 'hw1'
>>>
>>> I am using the OCL text file, so should it be something like this?
>>>
>>> package sizing
>>>
>>> context: Architecture
>>> if(true)
>>> self.hardwareNotes = 'hw1'
>>> end
>>>
>>> endpackage
>>>
>>> Thank you for your help.
>>>
>>> Regards,
>>> Richard Catlin
>>>
>>>
>>> On 8/6/2009 12:26 PM, Ed Willink wrote:
>>>> Hi Richard
>>>>
>>>> setHardwareNotes is an implementation artefact created by EMF, it is
>>>> not part of the Ecore class, so it is not accessible from OCL,
>>>> although the OCL implementation may use it.
>>>>
>>>> You have defined a property so that is what you should use.
>>>>
>>>> self.hardwareNotes = 'hw1'
>>>>
>>>> Regards
>>>> Ed Willink
>>>>
>>>>
>>>> Richard Catlin wrote:
>>>>> Further thoughts on this question:
>>>>>
>>>>> If I create a simple EClass called Architecture in Ecore with a
>>>>> property of "hardwareNotes", then when I generate the model, a
>>>>> setHardwareNotes(String name) method is generated. When I use the
>>>>> Interactive OCL Console, I get the following error:
>>>>>
>>>>> self.setHardwareNotes('hw1')
>>>>>
>>>>> Cannot find operation (setHardwareNotes(String)) for the type
>>>>> (Architecture)
>>>>>
>>>>> How can I go about setting this?
>>>>>
>>>>> Thank you,
>>>>> Richard
>>>>>
>>>>> On 8/4/2009 8:13 PM, Richard Catlin wrote:
>>>>>> All,
>>>>>>
>>>>>> I am using the EMF Framework Validation Plug-in: "OCL Example".
>>>>>> It allows me to write OCL expressions in a text file.
>>>>>>
>>>>>> Is it possible to set properties in the model based on OCL
>>>>>> expressions? The OCL 2.0 Spec says that expressions are
>>>>>> guaranteed to be without side effects, but then goes on to say
>>>>>> that OCL expressio can be used to specify a state change (eg. in a
>>>>>> post-condition).
>>>>>>
>>>>>> Pardon me if this is an obvious question. I am new to EMF and OCL.
>>>>>>
>>>>>> Thank you,
>>>>>> Richard Catlin
|
|
|
Goto Forum:
Current Time: Fri Mar 29 11:26:36 GMT 2024
Powered by FUDForum. Page generated in 0.02626 seconds
|