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