Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Re: some OCL questions
Re: some OCL questions [message #54530] Tue, 29 April 2008 13:51 Go to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Kai,

It's best to ask on the OCL newsgroup, which I've added to the "to" list
of my reply. Christian is on vacation this week though, so an answer
might be slow in coming...


Kai Boettcher wrote:
> Hi,
> I am working with the org.eclipse.emf.ocl plugin (version 1.1.1) and got
> some
> questions that i coudn't answer by myself.
>
> First of all, is there any method or framework to fire an ocl query to an
> entire model ?
> I have a Metamodel and an instance of this Metamodel in different Resource
> objects,
> and it would be great to pass these models to the ocl along with a query (or
> maybe a
> collection of queries) so that i don't have to bother with finding the
> correct context object
> which causes me a lot of trouble in the past (I don't have generated classes
> for my model,
> i have to work completly dynamic - i feel this makes things a little bit
> harder :) ).
> Or do i have to implement such a functionality by myself ?
>
> Second, are there any good tutorials or code snippets or something like this
> that covers
> working with the ocl plugin in greater detail, especially for the UML
> Metamodel binding
> and working with dynamically created models ?
> I couldn't find anything useful, neither on eclipse.org nor using Google to
> search the web.
> The Library examples are good to get an overview, but i feel that i need to
> dig much deeper
> into that matter.
>
> P.S.: Please be patient with my english, its not my native language :) - if
> you didn't understand
> something just ask and i will try to explain it in more detail.
>
> With best regards
> Kai Boettcher
>
>
>
Re: some OCL questions [message #54557 is a reply to message #54530] Tue, 29 April 2008 19:35 Go to previous messageGo to next message
Antonio Dias is currently offline Antonio DiasFriend
Messages: 8
Registered: July 2009
Junior Member
Kai,

I want to execute a complete ocl query on a model just like you want to
and I also do not know how to do so. Please, let me know if you find this
information elsewhere.

Best regards,

Antonio Dias.

Ed Merks wrote:

> Kai,

> It's best to ask on the OCL newsgroup, which I've added to the "to" list
> of my reply. Christian is on vacation this week though, so an answer
> might be slow in coming...


> Kai Boettcher wrote:
>> Hi,
>> I am working with the org.eclipse.emf.ocl plugin (version 1.1.1) and got
>> some
>> questions that i coudn't answer by myself.
>>
>> First of all, is there any method or framework to fire an ocl query to an
>> entire model ?
>> I have a Metamodel and an instance of this Metamodel in different Resource
>> objects,
>> and it would be great to pass these models to the ocl along with a query
(or
>> maybe a
>> collection of queries) so that i don't have to bother with finding the
>> correct context object
>> which causes me a lot of trouble in the past (I don't have generated
classes
>> for my model,
>> i have to work completly dynamic - i feel this makes things a little bit
>> harder :) ).
>> Or do i have to implement such a functionality by myself ?
>>
>> Second, are there any good tutorials or code snippets or something like
this
>> that covers
>> working with the ocl plugin in greater detail, especially for the UML
>> Metamodel binding
>> and working with dynamically created models ?
>> I couldn't find anything useful, neither on eclipse.org nor using Google to
>> search the web.
>> The Library examples are good to get an overview, but i feel that i need to
>> dig much deeper
>> into that matter.
>>
>> P.S.: Please be patient with my english, its not my native language :) - if
>> you didn't understand
>> something just ask and i will try to explain it in more detail.
>>
>> With best regards
>> Kai Boettcher
>>
>>
>>
Re: some OCL questions [message #54859 is a reply to message #54530] Sun, 04 May 2008 14:31 Go to previous message
Eclipse UserFriend
Originally posted by: give.a.damus.gmail.com

Hi, Kai, Ed,

Find some replies in-lnine, below.

HTH,

Christian

On Tuesday 04-29-2008 (09:51), Ed Merks wrote:
> Kai,

> It's best to ask on the OCL newsgroup, which I've added to the "to"
> list of my reply. Christian is on vacation this week though, so an
> answer might be slow in coming...

> Kai Boettcher wrote:
>> Hi,
>> I am working with the org.eclipse.emf.ocl plugin (version 1.1.1)
>> and got some
>> questions that i coudn't answer by myself.

>> First of all, is there any method or framework to fire an ocl
>> query to an entire model ?
>> I have a Metamodel and an instance of this Metamodel in different
>> Resource objects,
>> and it would be great to pass these models to the ocl along with a
>> query (or maybe a
>> collection of queries) so that i don't have to bother with finding
>> the correct context object
>> which causes me a lot of trouble in the past (I don't have
>> generated classes for my model,
>> i have to work completly dynamic - i feel this makes things a
>> little bit harder :) ).
>> Or do i have to implement such a functionality by myself ?

The context object (and the "contextual classifier") are generally
very important to the semantics of an OCL expression. Evaluating an
expression on an instance that is not of the contextual classifier
just doesn't make sense.

However, given a query expression represented as an ExpressionInOCL,
you can easily automate the process of finding the objects on which it
can be evaluated. The ExpressionInOCL owns a contextVariable, which
is the definition of the "self" variable. The context variable's type
is the contextual classifier. So, any object in your resources that
conforms to this variable's type can evaluate the expression (the
ExpressionInOCL's body).

The MDT OCL API provides no such mechanism out-of-the-box, but it
provides some useful pieces. For example, the LazyExtentMap class
implements a mapping of classifiers to the sets of their instances (in
Ecore terms, Map<EClass, Set<EObject> and in UML terms, Map<Class,
Set<EObject>). So, given the contextual classifier, you can use a
LazyExtentMap to look up its instances and use the
org.eclipse.ocl.Query::evaluate(List<?>) API to get a 1-for-1 list of
the results of evaluating the body expression on each instance.

The LazyExtentMap by default is scoped to only a single Resource
(containing some arbitrary context object), but you can subclass it if
you wish to scope it to an entire resource set or some bunch of
resources.
>> Second, are there any good tutorials or code snippets or something
>> like this that covers
>> working with the ocl plugin in greater detail, especially for the
>> UML Metamodel binding
>> and working with dynamically created models ?

Most of the OCL documentation is generic, because all of the concepts
in the API generally apply to any metamodel binding. What are you
looking for, specifically? The biggest difference between the Ecore
and UML bindings is in how to determine that an EObject is an instance
of a UML Class, which usually involves a correlation between that
Class and an EClass is the Ecore representation of the UML model.
>> I couldn't find anything useful, neither on eclipse.org nor using
>> Google to search the web.
>> The Library examples are good to get an overview, but i feel that
>> i need to dig much deeper
>> into that matter.

>> P.S.: Please be patient with my english, its not my native
>> language :) - if you didn't understand
>> something just ask and i will try to explain it in more detail.

Don't worry. These newsgroups are a global community, and there is no
excuse for one citizen to be impatient with another's grasp of his
preferred language.
>> With best regards
>> Kai Boettcher

>>


--

I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo
Previous Topic:Resolving Collection Types....
Next Topic:OCL Checkers
Goto Forum:
  


Current Time: Tue Apr 23 07:25:06 GMT 2024

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

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

Back to the top