Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Query over association instead of the classes (classifiers) with OCL
Query over association instead of the classes (classifiers) with OCL [message #1231452] Tue, 14 January 2014 18:09 Go to next message
Hamid Qartal is currently offline Hamid QartalFriend
Messages: 33
Registered: December 2013
Member
suppose I have a simple Ecore as bellow:

	

   ----  (0..3)          (0..*)  ---------
  | A  | ---------------------- |   B     |               // AB is association name 
   ----         AB              |-------- |
                                |age:EInt |
                                 ---------   


I would like to write a query that its output is as below:

	

  ----  (0..3)          (0..*)  ---------
 | A  | ---------------------- |   B'    |                // AB' is  association name
  ----         AB'             |-------- |                // B' is subset of B where age > 20
                               |age:EInt |                // and AB' is subset of AB 
                                ---------   


I can write a query to get B' like
B'=B->select(b:B | B.age>20)


I would like to write a query in OCL to get AB'. Semi-formal definition of AB' would be:
AB'=  all AB which its B side is restricted to B'
, in other words AB' is the same association as AB, but its target(co-domain) is restricted to B'.


I looked at OCL reference, but it seems that it is intended to work on Classes (like A and B here) rather than associations (like AB) in terms of query results. Am I right?

Any suggestion is appreciated.

Thanks
Re: Query over association instead of the classes (classifiers) with OCL [message #1231458 is a reply to message #1231452] Tue, 14 January 2014 18:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You are very vague about the relationship of B and B' but it seems that
where you write query but actually you are performing a transformation.

OCL as specified cannot create objects so a query cannot help. The new
Pivot binding of Eclipse OCL has an experimental implementation of type
constructors, so you might be able to do what you want. But it doesn;'t
seem right at all.

You should use a transformation language, nearly all of which use OCL as
theuir underlying query foundation.

Regards

Ed Willink


On 14/01/2014 18:09, Hamid Qartal wrote:
> suppose I have a simple Ecore as bellow:
>
>
>
> ---- (0..3) (0..*) ---------
> | A | ---------------------- | B | // AB is
> association name ---- AB |-------- |
> |age:EInt |
> ---------
>
> I would like to write a query that its output is as below:
>
>
>
> ---- (0..3) (0..*) ---------
> | A | ---------------------- | B' | // AB' is
> association name
> ---- AB' |-------- | // B' is
> subset of B where age > 20
> |age:EInt | // and AB' is
> subset of AB ---------
>
> I can write a query to get B' like B'=B->select(b:B | B.age>20)
>
> I would like to write a query in OCL to get AB'. Semi-formal
> definition of AB' would be: AB'= all AB which its B side is
> restricted to B', in other words AB' is the same association as AB,
> but its target(co-domain) is restricted to B'.
>
>
> I looked at OCL reference, but it seems that it is intended to work on
> Classes (like A and B here) rather than associations (like AB) in
> terms of query results. Am I right?
>
> Any suggestion is appreciated.
>
> Thanks
Re: Query over association instead of the classes (classifiers) with OCL [message #1231485 is a reply to message #1231458] Tue, 14 January 2014 19:51 Go to previous message
Hamid Qartal is currently offline Hamid QartalFriend
Messages: 33
Registered: December 2013
Member
B' here is subset of B, in OO terms we can consider B' is a new Type which inherits B so:

B' extends B

http://s29.postimg.org/3w7mtmucn/Screen_Shot_2014_01_14_at_2_21_49_PM.png

Actually I don't intend to create a new type ( I know that is another story). I intend to query association. As I wrote I can write to get B':

 B'=B->select(b:B | B.age>20)


My question is that can I write a query on associations like AB-> select (ab:AB | AB->codomain()=B'). so the query returns me association instead of class.

As you see I am not questioning creation of the types and association, but just having query on associations.

Thanks




Previous Topic:union two sets of different classifier
Next Topic:change in the use of environmentView from juno to kepler
Goto Forum:
  


Current Time: Wed Apr 24 20:07:05 GMT 2024

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

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

Back to the top