Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » OCL checker for EMF models in transformation chain
OCL checker for EMF models in transformation chain [message #416366] Tue, 29 January 2008 16:34 Go to next message
Damien Thivolle is currently offline Damien ThivolleFriend
Messages: 25
Registered: July 2009
Junior Member
Hello,

I'm relatively new to Eclipse and the modeling technology. I want to
write a transformation from a meta-model MMa to a meta-model MMb using
ATL. The problem is that the transformation will only concern a subset
of MMa.

I've been hinted to write a checker in OCL that would just tell me
whether a model Ma (conforming to MMa) is included in the subset I'm
interested in.

In the end, if the checker answers true when asked if the input model is
correct, the transformation would take place, if not an error message
would be yielded.

I've been looking for some clues as to where to start and I was
expecting to find something suitable for a newbie like me. Like, I
define a file with a set of OCL constraints, right click on my model and
choose "Validate constraints from file...". But I guess it's not gonna
be that easy.

More generally, I'm having a hard time finding my way around Eclipse,
EMF and such... I've been reading all the material I could find about
using OCL to check constraints on EMF models, and it's like Chinese to
me. For example, I've seen a lot of EMF models with annotations named
"OCL" and having several entries, but I can't really find anything that
would explain me what to do with those.

I'm just saying is that I find it hard to understand this technology and
I'm wondering if it's normal or if this is where my comprehension
reaches its limits.

Best regards,

--
Damien THIVOLLE
Re: OCL checker for EMF models in transformation chain [message #416370 is a reply to message #416366] Tue, 29 January 2008 17:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Damien,

Comments below.


Damien Thivolle wrote:
> Hello,
>
> I'm relatively new to Eclipse and the modeling technology. I want to
> write a transformation from a meta-model MMa to a meta-model MMb using
> ATL. The problem is that the transformation will only concern a subset
> of MMa.
There's a newsgroup for ATL. I've included it on the "to" list of the
reply.
>
> I've been hinted to write a checker in OCL that would just tell me
> whether a model Ma (conforming to MMa) is included in the subset I'm
> interested in.
>
> In the end, if the checker answers true when asked if the input model
> is correct, the transformation would take place, if not an error
> message would be yielded.
>
> I've been looking for some clues as to where to start and I was
> expecting to find something suitable for a newbie like me. Like, I
> define a file with a set of OCL constraints, right click on my model
> and choose "Validate constraints from file...". But I guess it's not
> gonna be that easy.
>
> More generally, I'm having a hard time finding my way around Eclipse,
> EMF and such... I've been reading all the material I could find about
> using OCL to check constraints on EMF models, and it's like Chinese to me.
Note really. If it were Chinese it would use an alphabet you'd not
recognize. :-P
> For example, I've seen a lot of EMF models with annotations named
> "OCL" and having several entries, but I can't really find anything
> that would explain me what to do with those.
Did you look at the Eclipse help?
>
> I'm just saying is that I find it hard to understand this technology
> and I'm wondering if it's normal or if this is where my comprehension
> reaches its limits.
There's an awful lot of technology to learn all at once for sure. And
the documentation is sometimes a little lacking or hard to find...
>
> Best regards,
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: OCL checker for EMF models in transformation chain [message #416421 is a reply to message #416370] Thu, 31 January 2008 09:33 Go to previous messageGo to next message
Damien Thivolle is currently offline Damien ThivolleFriend
Messages: 25
Registered: July 2009
Junior Member
Ed Merks a écrit :
> Damien,
>
> Comments below.
>

Thanks!
>
> Damien Thivolle wrote:
>> Hello,
>>
>> I'm relatively new to Eclipse and the modeling technology. I want to
>> write a transformation from a meta-model MMa to a meta-model MMb using
>> ATL. The problem is that the transformation will only concern a subset
>> of MMa.
> There's a newsgroup for ATL. I've included it on the "to" list of the
> reply.

Thank you but I don't have any problems with ATL and I'm in close
contact with the ATLAS team anyway.

>>
>> I've been hinted to write a checker in OCL that would just tell me
>> whether a model Ma (conforming to MMa) is included in the subset I'm
>> interested in.
>>
>> In the end, if the checker answers true when asked if the input model
>> is correct, the transformation would take place, if not an error
>> message would be yielded.
>>
>> I've been looking for some clues as to where to start and I was
>> expecting to find something suitable for a newbie like me. Like, I
>> define a file with a set of OCL constraints, right click on my model
>> and choose "Validate constraints from file...". But I guess it's not
>> gonna be that easy.
>>
>> More generally, I'm having a hard time finding my way around Eclipse,
>> EMF and such... I've been reading all the material I could find about
>> using OCL to check constraints on EMF models, and it's like Chinese to
>> me.
> Note really. If it were Chinese it would use an alphabet you'd not
> recognize. :-P

Yeah, sorry about my whining :) It's just that usually with Eclipse, the
documentation gives you a lot of examples as starting points. But too
often, there aren't enough explanations to make you really understand
what you're doing (see the doc for the OCL environment class which takes
12 template parameters...).

>> For example, I've seen a lot of EMF models with annotations named
>> "OCL" and having several entries, but I can't really find anything
>> that would explain me what to do with those.
> Did you look at the Eclipse help?
>>
>> I'm just saying is that I find it hard to understand this technology
>> and I'm wondering if it's normal or if this is where my comprehension
>> reaches its limits.
> There's an awful lot of technology to learn all at once for sure. And
> the documentation is sometimes a little lacking or hard to find...

My models are in files with a .sam extension and I want to write an ocl
file with constraints for my models. The SAM meta-model is written in Ecore.

So I was thinking I could implement a contextual menu action that would
only be available for files with a .sam extension. When handling that
action, I would open that model file in JAVA as you explained in one of
your previous messages on this newsgroup
(<fmnq3n$qrm$1@build.eclipse.org>). Then I would ask the user to choose
an ocl file and would use the OCL Eclipse project to open that OCL file,
parse it and verify the constraints on my SAM model. Does that sound
alright or is there a better way to do it?

For now, I'll forget about the transformation chain, I'll implement the
constraints checker and the ATL transformation separately and then, I
will think about how to "connect" them.

Best regards,

--
Damien THIVOLLE | INRIA Rhone-Alpes / VASY
PHD Student | 655, Avenue de l'Europe
damien.thivolle@inria.fr | Montbonnot
http://www.inrialpes.fr/vasy | 38 334 Saint Ismier Cedex France
Re: OCL checker for EMF models in transformation chain [message #416422 is a reply to message #416421] Thu, 31 January 2008 10:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020805040507090406080607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Damien,

Comments below.

Damien Thivolle wrote:
> Ed Merks a


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: OCL checker for EMF models in transformation chain [message #416425 is a reply to message #416422] Thu, 31 January 2008 11:43 Go to previous messageGo to next message
Damien Thivolle is currently offline Damien ThivolleFriend
Messages: 25
Registered: July 2009
Junior Member
Ed Merks a écrit :
> Damien,
>
> Comments below.
>
> Damien Thivolle wrote:
>> Ed Merks a écrit :
>>> Damien,
>>>
>>> Comments below.
>>>
>>
>> Thanks!
>>>
>>> Damien Thivolle wrote:
>>>> Hello,
>>>>
>>>> I'm relatively new to Eclipse and the modeling technology. I want to
>>>> write a transformation from a meta-model MMa to a meta-model MMb
>>>> using ATL. The problem is that the transformation will only concern
>>>> a subset of MMa.
>>> There's a newsgroup for ATL. I've included it on the "to" list of
>>> the reply.
>>
>> Thank you but I don't have any problems with ATL and I'm in close
>> contact with the ATLAS team anyway.
> I guess the introduction of wanting to write an ATL transformation threw
> me...
>>
>>>>
>>>> I've been hinted to write a checker in OCL that would just tell me
>>>> whether a model Ma (conforming to MMa) is included in the subset I'm
>>>> interested in.
> There's also an OCL-specific newsgroup... The EMF extended validation
> framework includes support for writing constraints with OCL
> (org.eclipse.emf.validation.ocl).
>>>>
>>>> In the end, if the checker answers true when asked if the input
>>>> model is correct, the transformation would take place, if not an
>>>> error message would be yielded.
>>>>
>>>> I've been looking for some clues as to where to start and I was
>>>> expecting to find something suitable for a newbie like me. Like, I
>>>> define a file with a set of OCL constraints, right click on my model
>>>> and choose "Validate constraints from file...". But I guess it's not
>>>> gonna be that easy.
>>>>
>>>> More generally, I'm having a hard time finding my way around
>>>> Eclipse, EMF and such... I've been reading all the material I could
>>>> find about using OCL to check constraints on EMF models, and it's
>>>> like Chinese to me.
>>> Note really. If it were Chinese it would use an alphabet you'd not
>>> recognize. :-P
>>
>> Yeah, sorry about my whining :) It's just that usually with Eclipse,
>> the documentation gives you a lot of examples as starting points. But
>> too often, there aren't enough explanations to make you really
>> understand what you're doing (see the doc for the OCL environment
>> class which takes 12 template parameters...).
> Let me whine a bit myself. Have you had a look at some of the
> specifications written out there? How are users supposed to understand
> things like that?

You're very right about that...

>>
>>>> For example, I've seen a lot of EMF models with annotations named
>>>> "OCL" and having several entries, but I can't really find anything
>>>> that would explain me what to do with those.
>>> Did you look at the Eclipse help?
>>>>
>>>> I'm just saying is that I find it hard to understand this technology
>>>> and I'm wondering if it's normal or if this is where my
>>>> comprehension reaches its limits.
>>> There's an awful lot of technology to learn all at once for sure.
>>> And the documentation is sometimes a little lacking or hard to find...
>>
>> My models are in files with a .sam extension and I want to write an
>> ocl file with constraints for my models. The SAM meta-model is written
>> in Ecore.
> Hmmm. I know the validation framework supports writing contains for the
> SAM.ecore model that would apply to instances stored in *.sam files. I
> know Christian has written some nice help information for how to get
> started with live validation...

Yes, I've read all this, and it's really awesome. But I'm not really
sure if I need live validation, maybe later, I need to think some more ;)

>>
>> So I was thinking I could implement a contextual menu action that
>> would only be available for files with a .sam extension. When handling
>> that action, I would open that model file in JAVA as you explained in
>> one of your previous messages on this newsgroup
>> (<fmnq3n$qrm$1@build.eclipse.org>).
> The basic generated editor already includes support for validating basic
> constraints.
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.doc//references/overview/EMF.Validation.html
>

I know that, but I can't modify the SAM meta-model, I have to build my
checker around what already exists.

> I'm not sure if you ever tracked these references down:
>
> http://help.eclipse.org/help33/nav/25
> http://help.eclipse.org/help33/nav/34
>
>
>> Then I would ask the user to choose an ocl file and would use the OCL
>> Eclipse project to open that OCL file, parse it and verify the
>> constraints on my SAM model. Does that sound alright or is there a
>> better way to do it?
> I think Christian has nice frameworks in place for all of this and that
> he's documented them well. I guess it's a little hard to find though,
> but it is in the help system under fairly easy-to-find headings.

I've found all the documentation, read it and what I explained above is
how I think I should proceed after having processed all I read. I just
wanted to know if this seems a correct way to check a set of OCL
constraints on SAM models given the fact that I can't modify the SAM
meta-model.

Best regards,

--
Damien THIVOLLE | INRIA Rhone-Alpes / VASY
PHD Student | 655, Avenue de l'Europe
damien.thivolle@inria.fr | Montbonnot
http://www.inrialpes.fr/vasy | 38 334 Saint Ismier Cedex France
Re: OCL checker for EMF models in transformation chain [message #416433 is a reply to message #416425] Thu, 31 January 2008 14:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Damien,

Find some comments in-line below.

HTH,

Christian


Damien Thivolle wrote:

> Ed Merks a écrit :
>> Damien,
>>
>> Comments below.
>>
>> Damien Thivolle wrote:

-----8<-----

>>>>> I've been hinted to write a checker in OCL that would just tell me
>>>>> whether a model Ma (conforming to MMa) is included in the subset I'm
>>>>> interested in.
>> There's also an OCL-specific newsgroup... The EMF extended validation
>> framework includes support for writing constraints with OCL
>> (org.eclipse.emf.validation.ocl).

The EMF Validation Framework SDK has an example that might give you a
head-start on what you're looking for. The "New -> Example..." menu has
an "EMF Validation Framework Examples / OCL" example that installs an
org.eclipse.emf.validation.ocl project in your workspace (note that, in
order to get it working, you need to install all three examples; we have a
bugzilla about that).

Included in this project is an example of how to define a Dynamic Constraint
Provider, which in this case parses the constraints in a *.ocl document and
applies them to EXTLibrary model instances. This sounds like what you are
aiming to do.


-----8<-----

>>> Yeah, sorry about my whining :) It's just that usually with Eclipse,
>>> the documentation gives you a lot of examples as starting points. But
>>> too often, there aren't enough explanations to make you really
>>> understand what you're doing (see the doc for the OCL environment
>>> class which takes 12 template parameters...).

Heh heh ... there are some brief works in the Javadoc and the Developer
Guide to explain that these parameters correspond to a metamodels'
representation of modeling constructs such
as "package", "classifier", "operation", "property", etc. Don't let the
number of type parameters get in your way. In concept, they all serve the
same purpose.


>> Let me whine a bit myself. Have you had a look at some of the
>> specifications written out there? How are users supposed to understand
>> things like that?

Much less implement them! :-)


> You're very right about that...
>
>>>
>>>>> For example, I've seen a lot of EMF models with annotations named
>>>>> "OCL" and having several entries, but I can't really find anything
>>>>> that would explain me what to do with those.
>>>> Did you look at the Eclipse help?

The only OCL-specific annotations that I know of are those demonstrated in
my article:

http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html

These are in no way implemented by the Eclipse distributions of EMF or OCL.
They are just an example.


-----8<-----

>> Hmmm. I know the validation framework supports writing contains for the
>> SAM.ecore model that would apply to instances stored in *.sam files. I
>> know Christian has written some nice help information for how to get
>> started with live validation...
>
> Yes, I've read all this, and it's really awesome. But I'm not really
> sure if I need live validation, maybe later, I need to think some more ;)

Live validation really fits best with the EMF Transaction API, with which
you might build editors that use a TransactionalEditingDomain. Otherwise,
some other kind of incremental batch-mode validation strategy is possibly
more advantageous, perhaps as an incremental workspace builder or localized
re-validation of objects affected by the execution of a Command.


-----8<-----

>>> Then I would ask the user to choose an ocl file and would use the OCL
>>> Eclipse project to open that OCL file, parse it and verify the
>>> constraints on my SAM model. Does that sound alright or is there a
>>> better way to do it?

This is the purpose for which the MDT OCL implementation provides parsing of
OCL files. However, there may be more convenient ways to implement this
for your users than asking them to choose OCL files. Perhaps some kind of
automatic discovery of OCL files, or a one-time registration ...


>> I think Christian has nice frameworks in place for all of this and that
>> he's documented them well. I guess it's a little hard to find though,
>> but it is in the help system under fairly easy-to-find headings.
>
> I've found all the documentation, read it and what I explained above is
> how I think I should proceed after having processed all I read. I just
> wanted to know if this seems a correct way to check a set of OCL
> constraints on SAM models given the fact that I can't modify the SAM
> meta-model.

OCL is always my first choice, but then I'm biased :-) Seriously, though.
The nice thing about OCL is that it is model-based and portable between
modeling systems, not tied to any API. I'd start with OCL and look for
alternatives only when your constraints reach beyond the expressive power
of OCL.


> Best regards,
>
Re: [ATL] OCL checker for EMF models in transformation chain [message #416498 is a reply to message #416370] Tue, 05 February 2008 16:27 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello Damien,

Firstly, I added [ATL] as a prefix to the subject of this post because I
am answering from the ATL point of view :-).


Secondly, here is a possible approach to do what you described:

1- Write the OCL constraints as a transformation (e.g., in ATL). Source:
Ma, target: a diagnostic (e.g., a model containing the list of failed
constraints). Examples:
http://www.eclipse.org/m2m/atl/atlTransformations/#ATL2Probl em,
http://www.eclipse.org/m2m/atl/atlTransformations/#KM32Probl em,
http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.gmt /org.eclipse.gmt.tcs/dsls/TCS/WFR/TCS2Problem.atl?view=marku p


2- Use a query to check if there are errors.


3- Run the actual transformation if there is no error.


2 and 3 are for instance used in the TCS compiler, at lines 122 to 142:
http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.gmt /org.eclipse.gmt.tcs/scripts/AMMAScripts/build.syntax.xml?vi ew=markup

Note that because we use TCS to parse the source model, we can apply
markers for the detected errors using the am3.applyMarkers task.


The TCS compiler that I mentioned above is implemented using the AM3 ant
tasks:
http://wiki.eclipse.org/AM3_Ant_Tasks

Note that it is also implemented as an Eclipse plugin. This means that
you can also implement such a scenario in Java.


Regards,

Frédéric Jouault


Ed Merks wrote:
> Damien,
>
> Comments below.
>
>
> Damien Thivolle wrote:
>> Hello,
>>
>> I'm relatively new to Eclipse and the modeling technology. I want to
>> write a transformation from a meta-model MMa to a meta-model MMb using
>> ATL. The problem is that the transformation will only concern a subset
>> of MMa.
> There's a newsgroup for ATL. I've included it on the "to" list of the
> reply.
>>
>> I've been hinted to write a checker in OCL that would just tell me
>> whether a model Ma (conforming to MMa) is included in the subset I'm
>> interested in.
>>
>> In the end, if the checker answers true when asked if the input model
>> is correct, the transformation would take place, if not an error
>> message would be yielded.
>>
>> I've been looking for some clues as to where to start and I was
>> expecting to find something suitable for a newbie like me. Like, I
>> define a file with a set of OCL constraints, right click on my model
>> and choose "Validate constraints from file...". But I guess it's not
>> gonna be that easy.
>>
>> More generally, I'm having a hard time finding my way around Eclipse,
>> EMF and such... I've been reading all the material I could find about
>> using OCL to check constraints on EMF models, and it's like Chinese to
>> me.
> Note really. If it were Chinese it would use an alphabet you'd not
> recognize. :-P
>> For example, I've seen a lot of EMF models with annotations named
>> "OCL" and having several entries, but I can't really find anything
>> that would explain me what to do with those.
> Did you look at the Eclipse help?
>>
>> I'm just saying is that I find it hard to understand this technology
>> and I'm wondering if it's normal or if this is where my comprehension
>> reaches its limits.
> There's an awful lot of technology to learn all at once for sure. And
> the documentation is sometimes a little lacking or hard to find...
>>
>> Best regards,
>>
Previous Topic:FeatureMaps
Next Topic:generated ecore file in impl directory
Goto Forum:
  


Current Time: Fri Apr 19 11:14:14 GMT 2024

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

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

Back to the top