Skip to main content



      Home
Home » Modeling » OCL » Concat collection
Concat collection [message #899617] Wed, 01 August 2012 11:10 Go to next message
Eclipse UserFriend
Hi,
I have a class A which can have multiple references to class B

What I want to do is, to concatenate all referenced names.

When I use the following command
self.VVCase__vvSubject->asSequence().name

I get:
'name1'
'name2'
'name3'


But what I want to have sth like this:
'name1, name2, name3'


How can I achive this with OCL ?! I found an example with "->iterate()", however my OCL sais "cannot find operation iterate() for the type (OrderedSet(VVCase)).


thanks
Re: Concat collection [message #899622 is a reply to message #899617] Wed, 01 August 2012 11:31 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I often use iterate for exactly this purpose. It works.

Without seeing your code there is no chance of telling why it doesn't
work for you.

Regards

Ed Willink


On 01/08/2012 16:10, Matthias N wrote:
> Hi,
> I have a class A which can have multiple references to class B
>
> What I want to do is, to concatenate all referenced names.
>
> When I use the following command
>
> self.VVCase__vvSubject->asSequence().name
>
> I get:
>
> 'name1'
> 'name2'
> 'name3'
>
>
> But what I want to have sth like this:
> 'name1, name2, name3'
>
>
> How can I achive this with OCL ?! I found an example with
> "->iterate()", however my OCL sais "cannot find operation iterate()
> for the type (OrderedSet(VVCase)).
>
>
> thanks
Re: Concat collection [message #899678 is a reply to message #899617] Wed, 01 August 2012 14:49 Go to previous messageGo to next message
Eclipse UserFriend
I am using the GMF Framework with OCL. Should "iterate" work ?!
Re: Concat collection [message #899711 is a reply to message #899678] Thu, 02 August 2012 00:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi

And what did my reply say?

Yes. You have to provide an example to get further help ...

Regards

Ed Willink


On 01/08/2012 19:49, Matthias N wrote:
> I am using the GMF Framework with OCL. Should "iterate" work ?!
Re: Concat collection [message #899773 is a reply to message #899711] Thu, 02 August 2012 06:03 Go to previous messageGo to next message
Eclipse UserFriend
Okay, I modelled the following with Ecore

+--------+
| root   |
+--------+
    <>
    |
    | 
+--------+        dogs * +-------+
| Person | <>----------- |  Dog  |
+--------+               +-------+

I populated the model with 3 dogs.

I use the interactive OCL console, e.g. context Person: self.dogs->size() results to 3.

When I input
self.dogs->
, auto-completion gives me
includes
includesAll
including
indexOf
insertAt
intersection
isEmpty
isUnique

no iterate ;(
Re: Concat collection [message #899788 is a reply to message #899617] Thu, 02 August 2012 07:20 Go to previous messageGo to next message
Eclipse UserFriend
finally I got it.
Don't know why the auto-completion is not showing iterate, however it works:

dogs->iterate(iterator: Dog; result : String = '' | result.concat(iterator.name))
Re: Concat collection [message #899813 is a reply to message #899773] Thu, 02 August 2012 08:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Which release are you using?

Completion assist was ropy in Indigo. It's much better in Juno. Works
for me in Juno.

[Not even JDT is perfect on Completion assist; it is only a guide of
likely candidates.]

Regards

Ed Willink


On 02/08/2012 11:03, Matthias N wrote:
> Okay, I modelled the following with Ecore
>
>
> +--------+
> | root |
> +--------+
> <>
> |
> | +--------+ dogs * +-------+
> | Person | <>----------- | Dog |
> +--------+ +-------+
>
> I populated the model with 3 dogs.
>
> I use the interactive OCL console, e.g. context Person:
> self.dogs->size() results to 3.
>
> When I input self.dogs->, auto-completion gives me
>
> includes
> includesAll
> including
> indexOf
> insertAt
> intersection
> isEmpty
> isUnique
>
> no iterate ;(
Re: Concat collection [message #900246 is a reply to message #899813] Mon, 06 August 2012 03:18 Go to previous message
Eclipse UserFriend
Okay, I am using helios
Previous Topic:Referencing to OCL constraint
Next Topic:Acceleo invoking a Java Service Wrapping OCL
Goto Forum:
  


Current Time: Wed Jul 23 19:18:03 EDT 2025

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

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

Back to the top