Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » simple problem from a beginner (Solved)(Location a collection in another collection)
simple problem from a beginner (Solved) [message #798637] Tue, 14 February 2012 23:16 Go to next message
Mohamed Mussa is currently offline Mohamed MussaFriend
Messages: 43
Registered: August 2010
Location: Canada
Member
Hi,


I am trying to locate a collection of UML class names in another collection of UML classes.

I have reach the following expression:
UML2!"uml::Class".allInstancesFrom('INModel')->select(s | s.hasStereotype('TESTCOMPONENT'))

which provide me with all classes with stereotypes "testcomponent", and it works fine.

I have another module attribute which holds a collection of names that I need to find & extract from previous expression.

Your help to complete this expression is appreciated, and thanks in advance.

Yours,
Mohamed

[Updated on: Wed, 15 February 2012 20:52]

Report message to a moderator

Re: simple problem from a beginner [message #798856 is a reply to message #798637] Wed, 15 February 2012 06:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I'm afraid that the vagueness of your English makes it difficult to
understand exactly what you want.

I suggest expressing the algorithm clearly and you may then find that it
maps to select/includes/union/... operators.

Your example is clearly not OCL; probably ATL. OCL has no ! or ",
although for historical compatibility OCL allows "" to enclose names,
but that would make "uml::Class" one not two names.

Regards

Ed Willink


On 14/02/2012 23:16, Mohamed Mussa wrote:
> Hi,
>
>
> I am trying to locate a collection of UML class names in another
> collection of UML classes.
>
> I have reach the following expression:
> UML2!"uml::Class".allInstancesFrom('INModel')->select(s |
> s.hasStereotype('TESTCOMPONENT'))
>
> which provide me with all classes with stereotypes "testcomponent",
> and it works fine.
>
> I have another module attribute which holds a collection of names that
> I need to find & extract from previous expression.
>
> Your help to complete this expression is appreciated, and thanks in
> advance.
>
> Yours,
> Mohamed
>
Re: simple problem from a beginner [message #799256 is a reply to message #798856] Wed, 15 February 2012 17:01 Go to previous messageGo to next message
Mohamed Mussa is currently offline Mohamed MussaFriend
Messages: 43
Registered: August 2010
Location: Canada
Member
Thanks Ed Willink,

I'm sorry for my ESL. Yes, it is an ATL command. I studied OCL 3 yrs ago, but I didn't practice it.

Here is my question:
How to locate the existence of an OCL collection in another OCL collection, which represents a UML classes, and point to these UML classes in a new collection if found?

To clarify, lets go through the following ex.:

Suppose we have the following collection
Col1={A, k, L} Note: I have this one.
and we have UML Diagram with the following
UML classes = {A, B, C, K, R} Note: I have this one.

I want to write an OCL/ATL expression to locate the existence of any of the Col1's members among the UML classes, so the result should be
Matched UML classes = {A, K} Note: I need to reach this one.


I hope I clarified my request.

Yours,
Mohamed

Edward Willink wrote on Wed, 15 February 2012 01:39
Hi

I'm afraid that the vagueness of your English makes it difficult to
understand exactly what you want.

I suggest expressing the algorithm clearly and you may then find that it
maps to select/includes/union/... operators.

Your example is clearly not OCL; probably ATL. OCL has no ! or ",
although for historical compatibility OCL allows "" to enclose names,
but that would make "uml::Class" one not two names.

Regards

Ed Willink


On 14/02/2012 23:16, Mohamed Mussa wrote:
> Hi,
>
>
> I am trying to locate a collection of UML class names in another
> collection of UML classes.
>
> I have reach the following expression:
> UML2!"uml::Class".allInstancesFrom('INModel')->select(s |
> s.hasStereotype('TESTCOMPONENT'))
>
> which provide me with all classes with stereotypes "testcomponent",
> and it works fine.
>
> I have another module attribute which holds a collection of names that
> I need to find & extract from previous expression.
>
> Your help to complete this expression is appreciated, and thanks in
> advance.
>
> Yours,
> Mohamed
>

Re: simple problem from a beginner [message #799273 is a reply to message #799256] Wed, 15 February 2012 17:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The union, intersection, -, symmetricDifference, includes, excludes
operations allow you to do a variety of collection operations.

Regards

Ed Willink


On 15/02/2012 17:01, Mohamed Mussa wrote:
> Thanks Ed Willink,
>
> I'm sorry for my ESL. Yes, it is an ATL command. I studied OCL 3 yrs
> ago, but I didn't practice it.
>
> Here is my question:
> How to locate the existence of an OCL collection in another OCL
> collection, which represents a UML classes, and point to these UML
> classes in a new collection if found?
> To clarify, lets go through the following ex.:
>
> Suppose we have the following collection Col1={A, k, L} Note: I
> have this one.
> and we have UML Diagram with the following UML classes = {A, B, C, K,
> R} Note: I have this one.
>
> I want to write an OCL/ATL expression to locate the existence of any
> of the Col1's members among the UML classes, so the result should be
> Matched UML classes = {A, K} Note: I need to reach this one.
>
>
> I hope I clarified my request.
>
> Yours,
> Mohamed
>
> Edward Willink wrote on Wed, 15 February 2012 01:39
>> Hi
>>
>> I'm afraid that the vagueness of your English makes it difficult to
>> understand exactly what you want.
>>
>> I suggest expressing the algorithm clearly and you may then find that
>> it maps to select/includes/union/... operators.
>>
>> Your example is clearly not OCL; probably ATL. OCL has no ! or ",
>> although for historical compatibility OCL allows "" to enclose names,
>> but that would make "uml::Class" one not two names.
>>
>> Regards
>>
>> Ed Willink
>>
>>
>> On 14/02/2012 23:16, Mohamed Mussa wrote:
>> > Hi,
>> >
>> >
>> > I am trying to locate a collection of UML class names in another >
>> collection of UML classes.
>> >
>> > I have reach the following expression:
>> > UML2!"uml::Class".allInstancesFrom('INModel')->select(s | >
>> s.hasStereotype('TESTCOMPONENT'))
>> >
>> > which provide me with all classes with stereotypes "testcomponent",
>> > and it works fine.
>> >
>> > I have another module attribute which holds a collection of names
>> that > I need to find & extract from previous expression.
>> >
>> > Your help to complete this expression is appreciated, and thanks in
>> > advance.
>> >
>> > Yours,
>> > Mohamed
>> >
>
>
Re: simple problem from a beginner [message #799321 is a reply to message #799273] Wed, 15 February 2012 18:43 Go to previous message
Mohamed Mussa is currently offline Mohamed MussaFriend
Messages: 43
Registered: August 2010
Location: Canada
Member
Thanks for your respond.

I have solved the problem

UML2!"uml::Class".allInstancesFrom('IN')->select(s | s.hasStereotype('TESTCOMPONENT'))->collect(sn | sn.name.toUpper())->select(t| thisModule.contextSUT.includes(t));

and the contextSUT collection must be in uppercase

My best regards,

Mohamed
Previous Topic:[OCLInEcore] Cannot find operation
Next Topic:OCLinEcore does not work with Xtext 2.2.1
Goto Forum:
  


Current Time: Tue Apr 16 05:30:41 GMT 2024

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

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

Back to the top