Referencing Java language elements from OCL statements in EMF [message #1235839] |
Sat, 25 January 2014 12:40 |
Emre T Messages: 119 Registered: April 2013 |
Senior Member |
|
|
Hello there! I am building a model with EMF and I want to be able query/validate certain model elements with OCL. It is not being done programatically, though it might also be an option. I use EAnnotation to define the OCL statements for model elements. The OCL constructs in this case should be based on the Java language itself, like classes, constructors etc.
The trivial case looks like this: In the ecore model, there is an EClass named UtilityClass which inherits from Class Java (for this I am using EMFText and its java.ecore, found in org.eclipse.emftext.language.java/metamodel). I'm adding an EAnnotation to UtilityClass, which contains the OCL statement. Pseudo: A utility class must have only static methods and fields, and shouldn't have to be initialized. I am new to practical usage of OCL, therefor these questions. Don't I have to reference in this case the methods and fields from OCL to Java elements e.g. for later query/validation purposes?
Which packages should be registered for this in my ecore model, beside the one from EMFText, that is based on the metamodel of Java language? Or are there any other things, I need to be aware of?
Thank you..
|
|
|
Re: Referencing Java language elements from OCL statements in EMF [message #1235846 is a reply to message #1235839] |
Sat, 25 January 2014 12:56 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
I recommend that you follow the OCLinEcore tutorial in the Eclipse OCL
Documentation and you will discover that the EAnnotations can all be hidden.
You can use the OCL Console for interactive queries.
Regards
Ed Willink
On 25/01/2014 12:40, Emre T wrote:
> Hello there! I am building a model with EMF and I want to be able
> query/validate certain model elements with OCL. It is not being done
> programatically, though it might also be an option. I use EAnnotation
> to define the OCL statements for model elements. The OCL constructs in
> this case should be based on the Java language itself, like classes,
> constructors etc.
> The trivial case looks like this: In the ecore model, there is an
> EClass named UtilityClass which inherits from Class Java (for this I
> am using EMFText and its java.ecore, found in
> org.eclipse.emftext.language.java/metamodel). I'm adding an
> EAnnotation to UtilityClass, which contains the OCL statement. Pseudo:
> A utility class must have only static methods and fields, and
> shouldn't have to be initialized. I am new to practical usage of OCL,
> therefor these questions. Don't I have to reference in this case the
> methods and fields from OCL to Java elements e.g. for later
> query/validation purposes?
>
> Which packages should be registered for this in my ecore model, beside
> the one from EMFText, that is based on the metamodel of Java language?
> Or are there any other things, I need to be aware of?
>
> Thank you..
|
|
|
|
|
|
|
|
|
Re: Referencing Java language elements from OCL statements in EMF [message #1236610 is a reply to message #1236586] |
Mon, 27 January 2014 17:01 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
The OCLinEcore editor by default uses one model per-namespace URI
loading whichever of nsURI, platform:plugin, platform:/resource is
accessed first and remapping the others to the first. This avoids
problems with inconsistent access, but may just push them down to other
tools. You are strongly recommended to use only one form of access.
nsURI if you access something that you do not (re-)develop.
platform:/resource for you own models.
Regards
Ed Willink
On 27/01/2014 15:53, Emre T wrote:
> Ok, the problem is solved! Silly of me, that I haven't really paid
> attention to which proxies weren't resolved from where. OCLInEcore
> editor, as far as I can see, looks for the platform resources and not
> plugins? So after I have imported to unresolved proxies into my
> workspace, everything was fine.
>
> But again, thanks for the help!
|
|
|
Powered by
FUDForum. Page generated in 0.04002 seconds