Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Getting Started
Getting Started [message #47853] Fri, 11 January 2008 11:00 Go to next message
Eclipse UserFriend
Originally posted by: lkelly.yahoo.com

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 #47945 is a reply to message #47853] Fri, 11 January 2008 13:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

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 #48063 is a reply to message #47945] Fri, 11 January 2008 16:34 Go to previous messageGo to next message
Eclipse UserFriend
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 18:12 Go to previous messageGo to next message
Eclipse UserFriend
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 15:18 Go to previous messageGo to next message
Eclipse UserFriend
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 #48190 is a reply to message #48165] Mon, 14 January 2008 15:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Lisa,

It's the second one: "OCL Example." This includes an example of a dynamic
constraint provider, which loads constraints from *.ocl resources (which is
why it is included in the OCL Example project).

You will see in the plugin.xml file in the
org.eclipse.emf.validation.examples.ocl project (the "OCL Example") an
extension on the org.eclipse.emf.validation.constraintProviders point,
which plugs in the *.ocl constraint provider. If your GMF diagram editor's
validation function delegates to the EMF Validation Framework (I think it
does), then the constraints defined by your provider will be discovered
automatically and evaluated on the objects to which they are applicable.
The "General Validation Example" adds an action to the EXTLibrary editor
context menu that demonstrates how an application such as GMF invokes the
validation framework to evaluated constraints such as your OCL constraints.

Cheers,

Christian


Lisa Kelly wrote:

> 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

-----8<-----
Re: Getting Started [message #48341 is a reply to message #48190] Tue, 15 January 2008 14:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lkelly.yahoo.com

Hi Christian,

Again thanks so much for your help with this. I think I am nearly there
with the example stuff at least :).

OK got the example to run. I created a Library object with an author
instance that has no books - which should break the OCL constraint. The
only question I have now is how do I get it to validate?

I note that when you click on EXTLibrary Editor -> Validation you get
three options
-Show Validation Events
-Enable Live Validation
-Validate Elements...

I pursume that you use "Validate Elements" but the last two options are
greyed out. Have I missed a step?

After this all I have to integrate it into the GMF app I have - really
interesting stuff :) thanks again for your patience and time!

Lisa



Christian W. Damus wrote:

> Hi, Lisa,

> It's the second one: "OCL Example." This includes an example of a dynamic
> constraint provider, which loads constraints from *.ocl resources (which is
> why it is included in the OCL Example project).

> You will see in the plugin.xml file in the
> org.eclipse.emf.validation.examples.ocl project (the "OCL Example") an
> extension on the org.eclipse.emf.validation.constraintProviders point,
> which plugs in the *.ocl constraint provider. If your GMF diagram editor's
> validation function delegates to the EMF Validation Framework (I think it
> does), then the constraints defined by your provider will be discovered
> automatically and evaluated on the objects to which they are applicable.
> The "General Validation Example" adds an action to the EXTLibrary editor
> context menu that demonstrates how an application such as GMF invokes the
> validation framework to evaluated constraints such as your OCL constraints.

> Cheers,

> Christian


> Lisa Kelly wrote:

>> 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

> -----8<-----
Re: Getting Started [message #48371 is a reply to message #48341] Tue, 15 January 2008 14:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Lisa,

The "Validate Elements..." action requires one or more elements to be
selected in the editor. The "Enable Live Validation" action requires a
resource to be selected, as it attaches a content-adapter to the resource.

HTH,

Christian

Lisa Kelly wrote:

> Hi Christian,
>
> Again thanks so much for your help with this. I think I am nearly there
> with the example stuff at least :).
>
> OK got the example to run. I created a Library object with an author
> instance that has no books - which should break the OCL constraint. The
> only question I have now is how do I get it to validate?
>
> I note that when you click on EXTLibrary Editor -> Validation you get
> three options
> -Show Validation Events
> -Enable Live Validation
> -Validate Elements...
>
> I pursume that you use "Validate Elements" but the last two options are
> greyed out. Have I missed a step?
>
> After this all I have to integrate it into the GMF app I have - really
> interesting stuff :) thanks again for your patience and time!
>
> Lisa

-----8<-----
Re: Getting Started [message #48442 is a reply to message #48371] Tue, 15 January 2008 14:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lkelly.yahoo.com

Sorry Christian, I should have said this happens when any element in the
model is selected. The same thing happens when you right-click on an
element and go to Validation tab.

I am using JDK6.0 - would this have a negative effect - because I get the
warning:
Build path specifies execution environment J2SE-1.5. There are no JREs in
the workspace strictly compatible with this environment.
org.eclipse.emf.examples.library Build path 1200048931279 0


Lisa

Christian W. Damus wrote:

> Hi, Lisa,

> The "Validate Elements..." action requires one or more elements to be
> selected in the editor. The "Enable Live Validation" action requires a
> resource to be selected, as it attaches a content-adapter to the resource.

> HTH,

> Christian

> Lisa Kelly wrote:

>> Hi Christian,
>>
>> Again thanks so much for your help with this. I think I am nearly there
>> with the example stuff at least :).
>>
>> OK got the example to run. I created a Library object with an author
>> instance that has no books - which should break the OCL constraint. The
>> only question I have now is how do I get it to validate?
>>
>> I note that when you click on EXTLibrary Editor -> Validation you get
>> three options
>> -Show Validation Events
>> -Enable Live Validation
>> -Validate Elements...
>>
>> I pursume that you use "Validate Elements" but the last two options are
>> greyed out. Have I missed a step?
>>
>> After this all I have to integrate it into the GMF app I have - really
>> interesting stuff :) thanks again for your patience and time!
>>
>> Lisa

> -----8<-----
Re: Getting Started [message #48520 is a reply to message #48442] Tue, 15 January 2008 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lkelly.yahoo.com

Sorry I ran the wrong project - ran the editor instead of
org.eclipse.emf.validation.examples.ocl

Working now!
Thanks!

Lisa Kelly wrote:

> Sorry Christian, I should have said this happens when any element in the
> model is selected. The same thing happens when you right-click on an
> element and go to Validation tab.

> I am using JDK6.0 - would this have a negative effect - because I get the
> warning:
> Build path specifies execution environment J2SE-1.5. There are no JREs in
> the workspace strictly compatible with this environment.
> org.eclipse.emf.examples.library Build path 1200048931279 0


> Lisa

> Christian W. Damus wrote:

>> Hi, Lisa,

>> The "Validate Elements..." action requires one or more elements to be
>> selected in the editor. The "Enable Live Validation" action requires a
>> resource to be selected, as it attaches a content-adapter to the resource.

>> HTH,

>> Christian

>> Lisa Kelly wrote:

>>> Hi Christian,
>>>
>>> Again thanks so much for your help with this. I think I am nearly there
>>> with the example stuff at least :).
>>>
>>> OK got the example to run. I created a Library object with an author
>>> instance that has no books - which should break the OCL constraint. The
>>> only question I have now is how do I get it to validate?
>>>
>>> I note that when you click on EXTLibrary Editor -> Validation you get
>>> three options
>>> -Show Validation Events
>>> -Enable Live Validation
>>> -Validate Elements...
>>>
>>> I pursume that you use "Validate Elements" but the last two options are
>>> greyed out. Have I missed a step?
>>>
>>> After this all I have to integrate it into the GMF app I have - really
>>> interesting stuff :) thanks again for your patience and time!
>>>
>>> Lisa

>> -----8<-----
Re: Getting Started [message #48797 is a reply to message #48096] Wed, 16 January 2008 17:40 Go to previous messageGo to next message
Eclipse UserFriend
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 18:26 Go to previous messageGo to next message
Eclipse UserFriend
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 12:28 Go to previous messageGo to next message
Eclipse UserFriend
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 #48917 is a reply to message #48887] Thu, 17 January 2008 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

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 #48947 is a reply to message #48917] Thu, 17 January 2008 14:09 Go to previous messageGo to next message
Eclipse UserFriend
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 #48977 is a reply to message #48947] Thu, 17 January 2008 14:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Lisa,

Yes, you understand correctly that the *.ocl files can contain constraints
targeting any model.

I think I must have misunderstood your original question. :-)

The presence of the "Validate Elements..." action in the diagram is an
entirely separate matter. Your OCL constraint provider plugs constraints
into the validation service. Invocation of that service is different; the
org.eclipse.emf.validation.examples.general example is where the "Validate
Elements..." action is defined and contributed to the EXTLibrary editor.
The same action contributed to your Skos Editor should work (as an example,
of course).

You might be interested in this bug:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=191471

which suggests that these interdependencies between the validation examples
are not a good thing.

cW


Lisa Kelly wrote:

> 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!
>

-----8<-----
Re: Getting Started [message #49368 is a reply to message #48977] Wed, 23 January 2008 16:53 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello,

I got the EXTLibrary working. I want do a something with my own ecore
model. I generated all code from genmodel, but I can not find the
"Validate Elements..." action from the top menu.

Thank you.
Wong.
Re: Getting Started [message #49398 is a reply to message #49368] Wed, 23 January 2008 17:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Wong,

That is because the org.eclipse.emf.validation.examples.general plug-in only
contributes a "Validate Elements..." action to the EXTLibrary editor.

You will need to implement a menu action, tool bar button, project builder,
or whatever is most appropriate for your application to invoke validation
of your resources.

Cheers,

Christian

wong wrote:

> Hello,
>
> I got the EXTLibrary working. I want do a something with my own ecore
> model. I generated all code from genmodel, but I can not find the
> "Validate Elements..." action from the top menu.
>
> Thank you.
> Wong.
Re: Getting Started [message #49426 is a reply to message #49398] Wed, 23 January 2008 18:10 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
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 #49456 is a reply to message #49426] Wed, 23 January 2008 21:15 Go to previous messageGo to next message
Eclipse UserFriend
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 #49486 is a reply to message #49456] Thu, 24 January 2008 16:51 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
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 #49515 is a reply to message #49486] Thu, 24 January 2008 18:55 Go to previous messageGo to next message
Eclipse UserFriend
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 #49545 is a reply to message #49515] Thu, 24 January 2008 19:12 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
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 #49572 is a reply to message #48827] Fri, 25 January 2008 11:45 Go to previous messageGo to next message
Eclipse UserFriend
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 #49602 is a reply to message #49572] Fri, 25 January 2008 12:07 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello Mark,

Try use: I am not sure

ModelValidationService mvs = ModelValidationService.getInstance();

mvs.replaceInCache(oldConstraint, newConstraint)

In the BatchValidationDelegate class.

Wong.
Re: Getting Started [message #49631 is a reply to message #49602] Fri, 25 January 2008 12:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

Hi Wong,

Nice idea, the only problem is that in order to replace the constraints in
the cache, I need to get a list of all the constraints, which isn't
available through the ModelValidationService. Maybe if someone knows how
to get a list of the constraints in the cache this will work?

Thanks,
Mark

wong wrote:

> Hello Mark,

> Try use: I am not sure

> ModelValidationService mvs = ModelValidationService.getInstance();

> mvs.replaceInCache(oldConstraint, newConstraint)

> In the BatchValidationDelegate class.

> Wong.
Re: Getting Started [message #49660 is a reply to message #49545] Fri, 25 January 2008 12:32 Go to previous messageGo to next message
Eclipse UserFriend
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 #49689 is a reply to message #49572] Fri, 25 January 2008 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

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

Mark wrote:

> 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

-----8<-----
Re: Getting Started [message #49778 is a reply to message #49689] Fri, 25 January 2008 14:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

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

> Mark wrote:

>> 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

> -----8<-----
Re: Getting Started [message #49808 is a reply to message #49778] Fri, 25 January 2008 15:04 Go to previous messageGo to next message
Eclipse UserFriend
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 #50174 is a reply to message #49808] Thu, 31 January 2008 18:30 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
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.
Re: Getting Started [message #50232 is a reply to message #50174] Fri, 01 February 2008 14:08 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Adding OCL in Ecore Model
Next Topic:OCLConstraintProvider customization
Goto Forum:
  


Current Time: Sat Nov 22 09:05:13 GMT 2014

Powered by FUDForum. Page generated in 0.03073 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software