Hi there,
I've defined my metamodel using ecore but now I want to give some
behavior to some operations that I want to define. I've tried to use
some OCL, but it looks like nothing changes between the version without
or with OCL.
- I added an operation in the ecore model named addName(EString);
- To this operation I added an EAnotation and I named it ocl;
- To the EAnotation I added a "Detail Entry" which has as key "body" and
as Value the constraint :
"if(myName)
self.name = myName
else
false
endif"
where name is an attribute from my class.
When I validate the ecore model everything goes fine; when I "Generate
All" from the .genemodel I don't get any errors; but, in the java
generated code I don't have any difference appart from the fact that I
have new comments in the method signature:
* @model annotation="ocl invariant='if(myName)\r self.name =
myName\relse\r false\rendif'"
So... it looks like my invariant is just transformed into a comment.
Besides this, I added to "Model Plug-in Variables" the following:
EMFT_OCL=org.eclipse.emf.ocl; Switched to True the "Dinamic Templates"
and added "Templates Directory" equal to
/org.eclipse.emf.ocl.examples.codegen/templates