Home » Modeling » OCL » Getting Started
| |
Re: Getting Started [message #48063 is a reply to message #47945] |
Fri, 11 January 2008 11:34   |
Eclipse User |
|
|
|
Originally posted by: lkelly.yahoo.com
Hi Christian,
Thanks for your response! To be honest I am not sure which what I am
intending to work with. Perhaps if I give you an idea of what I am trying
to do you might have some suggestions for me.
I have an ecore model, this ecore model is used as the base model in a GMF
application. What I want is to be able to define constraints on this model
- but I want to allow the user to define the constraints (as each user has
their own constraints) - for example load in an OCL file which will be
evaluated against the ECore instance model.
I thought the best option was to look into using EMF query but this does
not allow the user to define OCL constraints (although the user can query
the model using the interactive OCL console - perhaps this can be altered
for constraints?)
Any thoughts would be much appriciated.
Thanks,
Lisa
Christian W. Damus wrote:
> Hi, Lisa,
> The tutorial you are looking at is for the OCL extensions in the EMF Model
> Query component. If you install the "OCL Query" example from the EMF Model
> Query SDK, then you will find these menus in the EXTLibrary editor in a
> run-time workbench.
> Are you intending to work primarily with the MDT OCL API or with EMF Query's
> OCL support? If the latter, then you can follow up with questions about
> querying with OCL on the eclipse.tools.emf newsgroup.
> HTH,
> Christian
> Lisa Kelly wrote:
>> Hi everyone,
>>
>> I am just getting started using OCL with EMF and trying to get everything
>> installed correctly. I note that on
>>
>
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. emf.query.doc/tutorials/oclQueryTutorial.html
>> it indicates that there is a UI enhancement that allows OCL to be called
>> from the EMF drop-down menu - I have installed OCL but cant get this menu
>> up, is there something extra I have to do?
>>
>> Thanks,
>> Lisa
|
|
|
Re: Getting Started [message #48096 is a reply to message #48063] |
Fri, 11 January 2008 13:12   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Lisa,
Your GMF-generated editor is hooked in to the EMF Validation Framework (a
separate component of the EMF project), which has extensions supporting
OCL.
The EMF Validation Framework SDK provides an example plug-in
(org.eclipse.emf.validation.examples.ocl) that you can install in your
workspace (much as I described on the EMF newsgroup for the Query
examples). This OCL validation example includes a "dynamic constraint
provider" that reads constraints from a *.ocl text file and applies them to
a model instance. This sounds like what you are looking to do. Have a
look at this:
http://wiki.eclipse.org/EMF-QTV_1.1_New_and_Noteworthy#New_V alidation_Constraint_Provider_Example
If, instead, you want to place OCL constraints directly in your Ecore model
and generate them into your Java code using EMF's intrinsic validation
framework (the EValidator/Diagnostician API), have a look at this Eclipse
Corner article:
http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html
This wouldn't fit as well with your requirement for users to define their
own constraints; the extrinsic validation framework (above) is well suited
to that.
HTH,
Christian
Lisa Kelly wrote:
> Hi Christian,
>
> Thanks for your response! To be honest I am not sure which what I am
> intending to work with. Perhaps if I give you an idea of what I am trying
> to do you might have some suggestions for me.
>
> I have an ecore model, this ecore model is used as the base model in a GMF
> application. What I want is to be able to define constraints on this model
> - but I want to allow the user to define the constraints (as each user has
> their own constraints) - for example load in an OCL file which will be
> evaluated against the ECore instance model.
>
> I thought the best option was to look into using EMF query but this does
> not allow the user to define OCL constraints (although the user can query
> the model using the interactive OCL console - perhaps this can be altered
> for constraints?)
>
> Any thoughts would be much appriciated.
>
> Thanks,
> Lisa
-----8<-----
|
|
|
Re: Getting Started [message #48165 is a reply to message #48096] |
Mon, 14 January 2008 10:18   |
Eclipse User |
|
|
|
Originally posted by: lkelly.yahoo.com
Hi Christian,
Again thanks for your answer (both of them)! The first solution you
outlined sounds exactly what I want :) !
So what I have done is downloaded the EMF Validation examples and
installed them in my eclipse. This now gives me three new options in the
File->New->Examples
-General Validation Example
-OCL Example
-Validation Adapter Example
There doesnt seem to be a "dynamic constraint provider" - have I installed
the wrong thing?
Another question I have is how it all fits together with GMF - for example
where does the dynamic constraint provider go in relation to the GMF
files? I am just having difficulty visualizing how it all comes together.
Thanks again for your help!
Lisa
Christian W. Damus wrote:
> Hi, Lisa,
> Your GMF-generated editor is hooked in to the EMF Validation Framework (a
> separate component of the EMF project), which has extensions supporting
> OCL.
> The EMF Validation Framework SDK provides an example plug-in
> (org.eclipse.emf.validation.examples.ocl) that you can install in your
> workspace (much as I described on the EMF newsgroup for the Query
> examples). This OCL validation example includes a "dynamic constraint
> provider" that reads constraints from a *.ocl text file and applies them to
> a model instance. This sounds like what you are looking to do. Have a
> look at this:
>
http://wiki.eclipse.org/EMF-QTV_1.1_New_and_Noteworthy#New_V alidation_Constraint_Provider_Example
> If, instead, you want to place OCL constraints directly in your Ecore model
> and generate them into your Java code using EMF's intrinsic validation
> framework (the EValidator/Diagnostician API), have a look at this Eclipse
> Corner article:
>
http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html
> This wouldn't fit as well with your requirement for users to define their
> own constraints; the extrinsic validation framework (above) is well suited
> to that.
> HTH,
> Christian
> Lisa Kelly wrote:
>> Hi Christian,
>>
>> Thanks for your response! To be honest I am not sure which what I am
>> intending to work with. Perhaps if I give you an idea of what I am trying
>> to do you might have some suggestions for me.
>>
>> I have an ecore model, this ecore model is used as the base model in a GMF
>> application. What I want is to be able to define constraints on this model
>> - but I want to allow the user to define the constraints (as each user has
>> their own constraints) - for example load in an OCL file which will be
>> evaluated against the ECore instance model.
>>
>> I thought the best option was to look into using EMF query but this does
>> not allow the user to define OCL constraints (although the user can query
>> the model using the interactive OCL console - perhaps this can be altered
>> for constraints?)
>>
>> Any thoughts would be much appriciated.
>>
>> Thanks,
>> Lisa
> -----8<-----
|
|
| | | | | |
Re: Getting Started [message #48797 is a reply to message #48096] |
Wed, 16 January 2008 12:40   |
Eclipse User |
|
|
|
Originally posted by: lkelly.yahoo.com
Hi again,
One question I have about the using the example plugin, is can you change
the *.ocl file at runtime anywhere? I tried to change it in the PDE but
the change was not reflected when i revalidated my model - i have to
restart the plug-in.
Any help would be much appriciated.
Thanks,
Lisa
Christian W. Damus wrote:
> Hi, Lisa,
> Your GMF-generated editor is hooked in to the EMF Validation Framework (a
> separate component of the EMF project), which has extensions supporting
> OCL.
> The EMF Validation Framework SDK provides an example plug-in
> (org.eclipse.emf.validation.examples.ocl) that you can install in your
> workspace (much as I described on the EMF newsgroup for the Query
> examples). This OCL validation example includes a "dynamic constraint
> provider" that reads constraints from a *.ocl text file and applies them to
> a model instance. This sounds like what you are looking to do. Have a
> look at this:
>
http://wiki.eclipse.org/EMF-QTV_1.1_New_and_Noteworthy#New_V alidation_Constraint_Provider_Example
> If, instead, you want to place OCL constraints directly in your Ecore model
> and generate them into your Java code using EMF's intrinsic validation
> framework (the EValidator/Diagnostician API), have a look at this Eclipse
> Corner article:
>
http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html
> This wouldn't fit as well with your requirement for users to define their
> own constraints; the extrinsic validation framework (above) is well suited
> to that.
> HTH,
> Christian
> Lisa Kelly wrote:
>> Hi Christian,
>>
>> Thanks for your response! To be honest I am not sure which what I am
>> intending to work with. Perhaps if I give you an idea of what I am trying
>> to do you might have some suggestions for me.
>>
>> I have an ecore model, this ecore model is used as the base model in a GMF
>> application. What I want is to be able to define constraints on this model
>> - but I want to allow the user to define the constraints (as each user has
>> their own constraints) - for example load in an OCL file which will be
>> evaluated against the ECore instance model.
>>
>> I thought the best option was to look into using EMF query but this does
>> not allow the user to define OCL constraints (although the user can query
>> the model using the interactive OCL console - perhaps this can be altered
>> for constraints?)
>>
>> Any thoughts would be much appriciated.
>>
>> Thanks,
>> Lisa
> -----8<-----
|
|
|
Re: Getting Started [message #48827 is a reply to message #48797] |
Wed, 16 January 2008 13:26   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Lisa,
This is one of those "polishing" jobs that I mentioned in reply elsewhere.
If you need a provider that can parse OCL files in a user's workspace, for
example, to apply constraints to models in the same workspace, then your
provider would probably need to detect when that file is changed (perhaps
via a workspace change listener) then destroy existing constraints and
re-parse the file.
The purpose of the example is just to demonstrate some of the APIs provided
by the EMF Validation component. It is not intended to be reusable as is.
Cheers,
Christian
Lisa Kelly wrote:
> Hi again,
>
> One question I have about the using the example plugin, is can you change
> the *.ocl file at runtime anywhere? I tried to change it in the PDE but
> the change was not reflected when i revalidated my model - i have to
> restart the plug-in.
>
> Any help would be much appriciated.
> Thanks,
> Lisa
-----8<-----
|
|
|
Re: Getting Started [message #48887 is a reply to message #48827] |
Thu, 17 January 2008 07:28   |
Eclipse User |
|
|
|
Originally posted by: lkelly.yahoo.com
Hi Christian,
That sounds like a good plan - will try and do the following as soon as I
get OCL file validation working in GMF.
One question - which is probably a very basic question - How does the
org.eclipse.emf.validation.examples.ocl project know about the rest of
org.eclipse.emf.examples.library.* - as I cant see the connection yet the
ocl project knows about the library when it is run.
Thanks,
Lisa
Christian W. Damus wrote:
> Hi, Lisa,
> This is one of those "polishing" jobs that I mentioned in reply elsewhere.
> If you need a provider that can parse OCL files in a user's workspace, for
> example, to apply constraints to models in the same workspace, then your
> provider would probably need to detect when that file is changed (perhaps
> via a workspace change listener) then destroy existing constraints and
> re-parse the file.
> The purpose of the example is just to demonstrate some of the APIs provided
> by the EMF Validation component. It is not intended to be reusable as is.
> Cheers,
> Christian
> Lisa Kelly wrote:
>> Hi again,
>>
>> One question I have about the using the example plugin, is can you change
>> the *.ocl file at runtime anywhere? I tried to change it in the PDE but
>> the change was not reflected when i revalidated my model - i have to
>> restart the plug-in.
>>
>> Any help would be much appriciated.
>> Thanks,
>> Lisa
> -----8<-----
|
|
| |
Re: Getting Started [message #48947 is a reply to message #48917] |
Thu, 17 January 2008 09:09   |
Eclipse User |
|
|
|
Originally posted by: lkelly.yahoo.com
Hi Christian,
From this I think it should be possible to change the
org.eclipse.emf.validation.examples.ocl's constraints/library.ocl file to
validate other EMF models I have.
I did this creating the following:
package skos
context Education
inv tooManyConcepts: self.concepts->size() < 5
endpackage
To validate my skos ecore model (although the actual physical file is
called skos2.ecore). I went to see if this would work, and ran the
org.eclipse.emf.validation.examples.ocl plugin and created a skos model -
but the validation options are not in the "Skos editor" as they are in the
"EXTLibrary Editor". Have I misinterpreted you here?
Thanks for the help!
Christian W. Damus wrote:
> Hi, Lisa,
> This particular plug-in doesn't need any Java-style or plug-in dependencies
> on the org.eclipse.emf.examples.library example because it defines
> constraints strictly in OCL terms. OCL works with model names, and EMF's
> EPackage registry (or the models in a UML resource set) are used to look up
> packages by name.
> So, for example, an OCL constraint can define a context thus:
> package extlibrary
> context AudioVisualItem
> inv: -- some invariant constraint
> endpackage
> and the OCL parser knows how to look up names such as extlibrary and
> AudioVisualItem. The same applies to any model.
> cW
> Lisa Kelly wrote:
>> Hi Christian,
>>
>> That sounds like a good plan - will try and do the following as soon as I
>> get OCL file validation working in GMF.
>>
>> One question - which is probably a very basic question - How does the
>> org.eclipse.emf.validation.examples.ocl project know about the rest of
>> org.eclipse.emf.examples.library.* - as I cant see the connection yet the
>> ocl project knows about the library when it is run.
>>
>> Thanks,
>> Lisa
>>
> -----8<-----
|
|
| | | | |
Re: Getting Started [message #49456 is a reply to message #49426] |
Wed, 23 January 2008 16:15   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Wong,
You can find this in the plugin.xml file of the
org.eclipse.emf.validation.examples.general plug-in project:
<action
label="%ValidateElementsAction.label"
icon="$nl$/icons/elcl16/validate_co.gif"
class=" org.eclipse.emf.validation.examples.general.actions.BatchVal idationDelegate "
menubarPath=" org.eclipse.emf.examples.extlibraryMenuID/org.eclipse.emf.va lidationMenuID/additions "
id=" org.eclipse.emf.validation.pde.example.general.ui.validateAc tion "/>
HTH,
Christian
wong wrote:
> Hello, Christian,
>
> I am on the 'org.eclipse.emf.validation.examples.ocl' which created from
> 'OCL example'. I tried find any class(edit,editor,ocl) implemented the
> menu and tool bar action, but I can not find it. Could you give me some
> more detail, please.
>
> Thanks for you help.
> Wong.
|
|
| |
Re: Getting Started [message #49515 is a reply to message #49486] |
Thu, 24 January 2008 13:55   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Wong,
I don't quite understand your question.
You can use OCL constraints in an *.ocl file in exactly the same way as the
example does. Presumably your *.ocl file would include different context
declarations because your model is different from the EXTLibrary model.
The example demonstrates one way to obtain constraints from some other
source than plugin.xml and Java (in this case, *.ocl). However, it is not
the only way -- you can invent your own constraint provider, and there are
innumerable possible ways to do that.
Cheers,
Christian
wong wrote:
> Hello, Christian,
>
> I modified the org.eclipse.emf.validation.examples.general, and I got the
> menu works on my own project. But I want use the Ocl constraints from .ocl
> file same as the 'OCL example'. Could you tell me how can I do that
> please.
>
> Thank you for your help,
>
> Wong.
|
|
| |
Re: Getting Started [message #49572 is a reply to message #48827] |
Fri, 25 January 2008 06:45   |
Eclipse User |
|
|
|
Originally posted by: mmelia.computing.dcu.ie
Hi Christian/Lisa,
Would clearing the batch constraint cache have the same effect (listener
still needed to know when to clear)? As that would mean that the
OCLProvider would be recalled and the constraints would be reparsed?
Had a look through the code there - Christian, is it possible to clear the
constraint cache from the outside as the functionality seems to be private
or protected in the IBatchValidator.
Mark
Christian W. Damus wrote:
> Hi, Lisa,
> This is one of those "polishing" jobs that I mentioned in reply elsewhere.
> If you need a provider that can parse OCL files in a user's workspace, for
> example, to apply constraints to models in the same workspace, then your
> provider would probably need to detect when that file is changed (perhaps
> via a workspace change listener) then destroy existing constraints and
> re-parse the file.
> The purpose of the example is just to demonstrate some of the APIs provided
> by the EMF Validation component. It is not intended to be reusable as is.
> Cheers,
> Christian
> Lisa Kelly wrote:
>> Hi again,
>>
>> One question I have about the using the example plugin, is can you change
>> the *.ocl file at runtime anywhere? I tried to change it in the PDE but
>> the change was not reflected when i revalidated my model - i have to
>> restart the plug-in.
>>
>> Any help would be much appriciated.
>> Thanks,
>> Lisa
> -----8<-----
|
|
| | |
Re: Getting Started [message #49660 is a reply to message #49545] |
Fri, 25 January 2008 07:32   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Wong,
The Validation example plug-ins work together: the "general" example
defines constraint categories, a client context, and the "Validate
Elements..." menu action. The "adapter" example defines an EValidator that
delegates EMF's intrinsic validation API to the extensible validation
framework. The "ocl" example illustrates how to use OCL to define
constraints.
The menu action in the "general" example simply invokes the
ModelValidationService to perform a validation. This service, then, finds
constraints contributed by any plug-in, including the "ocl" example
plug-in, that are applicable to the elements being validated, and evaluates
them.
So, if the rules are not being checked, then there may be something wrong in
the registration of your constraint provider, or in client-context bindings
(perhaps your constraints are not included in the client-context of
the "general" example), or in the formulation of your OCL context
declarations or constraints.
Check the workspace log for problems. If you don't find anything there, you
can debug a working example and your code that doesn't work, to see why
they behave differently.
HTH,
Christian
wong wrote:
> Hello, Christian,
>
> Thank you for your quick reply.
>
> There are 3 build-in OCL examples could be load from a new project. The
> first is 'general validation example', the second one is the 'OCL
> example'.
> I got second one working which parses constraints from .ocl file. but I
> could not find the class for add 'validation elements' menu for the
> editor. Then I followed your replys found the action class which for the
> menu from the first example. I modified the class to popup the menu for my
> own model. But it not check the constraints in the .ocl file.
> On my debug view, I can see the .ocl rules are added in the
> OCLConstraintProvider. But the menu action do not check the rules.
>
>
> Thank you for your help,
>
> Wong.
|
|
| | |
Re: Getting Started [message #49808 is a reply to message #49778] |
Fri, 25 January 2008 10:04   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Mark,
Ah, I see. In that case, it isn't the validation framework that's caching
your constraints, but your own provider.
The OCLConstraintProvider specializes the AbstractConstraintProvider, which
constructs a list of constraints exactly once.
The AbstractConstraintProvider expects a subclass either to construct all of
its constraints as constraint proxies in an override of the
setInitializationData() method or to override the getConstraints() to
return a variable number of constraints.
The OCLConstraintProvider example does the former because the constraints in
its *.ocl file are static, so this allows them to be shown statically in
the Constraints preference page. You will need to override
getConstraints() to return whatever constraints you have at the moment.
HTH,
Christian
Mark wrote:
> Hi Christian,
>
> I gave this a try too, but this has no effect on the caching - perhaps a
> handler is meant to be in the example OCLConstraintProvider?
>
> Mark
>
>
> Christian W. Damus wrote:
>
>> Hi, Mark,
>
>> Caching is optional. If your constraints are dynamic and need to change
>> at run-time, you can disable caching by specifying
>
>> cache="false"
>
>> in your <constraintProvider>
>
>> HTH,
>
>> Christian
-----8<-----
|
|
| |
Re: Getting Started [message #50232 is a reply to message #50174] |
Fri, 01 February 2008 09:08  |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Wong,
If your provider is registered in the plugin.xml using cache="false" in the
<constraintProvider> element, then the framework should not be adding it to
the ConstraintCache provider that caches constraints.
If this is happening to your provider, then that is a severe bug. In that
case, a bugzilla with a reproducible test case would be much appreciated.
Cheers,
Christian
wong wrote:
> Hello,
>
>
> I override the getConstraints() to return a variable number of
> constraints. Then I do not find a way to update the ocl constraints in the
> ModelValidationService.
>
> Could I use the
> ModelValidationService.getInstance().configureProviders(elem ents) to set
> the OCLConstraintProvider cache to false.
>
> Thank you for help.
>
> Wong.
|
|
|
Goto Forum:
Current Time: Thu May 22 19:31:46 EDT 2025
Powered by FUDForum. Page generated in 0.07437 seconds
|