Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Design pattern creation through ocl
Design pattern creation through ocl [message #636955] Wed, 03 November 2010 10:20 Go to next message
Marina is currently offline Marina
Messages: 9
Registered: July 2009
Junior Member
Hi all,

I have to create a model-to-model transformation from a UML diagram into another UML diagram following the Composite design pattern (for more info take a look at http://en.wikipedia.org/wiki/Composite_pattern ) using QVT relation and OCL.

I have successfully created my ecore and source model.

In order to detect a composite pattern, I think I have to look for all the classes that have an Aggregation and have the same operation in common. In this way I could determine the Composite and Leaf classes.

So, i think a recursive method is quite necessary.

I tried to use iterate() but i get always an error message. Here's the code about iterate()

temp->iterate(x:UMLISW2::UmlClass; acc: Sequence(UMLISW2::UmlClass)|classe->union(SubClass(x));

where Subclass is

query SubClass(classe : UMLISW2::UmlClass): Sequence(UMLISW2::UmlClass){
classe.umlForward-> select(x:UMLISW2::UmlAssociation|x.isAggregation=true).umlSo urce
}



Is it possible to get a recursive query with OCL?

Thanks
Re: Design pattern creation through ocl [message #637125 is a reply to message #636955] Thu, 04 November 2010 05:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi Marina

OCL certainly supports recursion.

However I'm not sure wgat tooling you are using, since Eclipse M2M/QVTr
currently has no execution capability. So I don't know what OCL you are
using and so whether it is supported there.

You don't give the error message.

Your acc is a Sequencxe which is a bit odd when using union to gather
results.

You might find closure more helpful. Search this newsgroup for details.

Regards

Ed Willink

On 03/11/2010 14:20, Marina wrote:
> Hi all,
>
> I have to create a model-to-model transformation from a UML diagram into
> another UML diagram following the Composite design pattern (for more
> info take a look at http://en.wikipedia.org/wiki/Composite_pattern )
> using QVT relation and OCL.
>
> I have successfully created my ecore and source model.
>
> In order to detect a composite pattern, I think I have to look for all
> the classes that have an Aggregation and have the same operation in
> common. In this way I could determine the Composite and Leaf classes.
>
> So, i think a recursive method is quite necessary.
>
> I tried to use iterate() but i get always an error message. Here's the
> code about iterate()
>
> temp->iterate(x:UMLISW2::UmlClass; acc:
> Sequence(UMLISW2::UmlClass)|classe->union(SubClass(x));
>
> where Subclass is
>
> query SubClass(classe : UMLISW2::UmlClass): Sequence(UMLISW2::UmlClass){
> classe.umlForward->
> select(x:UMLISW2::UmlAssociation|x.isAggregation=true).umlSo urce
> }
>
>
>
> Is it possible to get a recursive query with OCL?
>
> Thanks
Re: Design pattern creation through ocl [message #637143 is a reply to message #637125] Thu, 04 November 2010 07:05 Go to previous messageGo to next message
Marina is currently offline Marina
Messages: 9
Registered: July 2009
Junior Member
Hi Ed,
thanks for your reply.

I'm using Ecore Tools, EMF and Medini on Galileo Eclipse.

The error message is : acc is not assigned.

why should I use closure instead of iterate?
I've already searched but i still have this doubt

Regards

[Updated on: Thu, 04 November 2010 13:31]

Report message to a moderator

Re: Design pattern creation through ocl [message #637350 is a reply to message #637143] Fri, 05 November 2010 03:55 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi Marina

Medini QVT is a third party Eclipse product and so not formally
supported by Eclipse.

I'm not sure what OCL engine Medini QVT uses but I don't think it's
MDT/OCL. Certainly MDT/OCL has no message that could produce
"is not assigned".

Guessing: accis not assigned might arise through an attempt to realize
iterators through a generic iterate as discussed in the specification.
Initialization failure of the iterate acc would then make that a
sensible message. However it should always or never work for select, so
unless select is totally broken, I suggest that some type analysis
failure or empty/null-containing collection may be the cause.

If you are not using MDT/OCL you are unlikley to have closure() that
supports transitive collection iteration.

Regards

Ed Willink

On 04/11/2010 11:05, Marina wrote:
> Hi Ed,
> Thanks for your reply.
> I'm using Ecore Tools, EMF and Medini on Galileo Eclipse.
>
> The error message is : acc is not assigned.
> why should I use closure instead of iterate? I've already searched but i
> still have this doubt
>
> Regards
Previous Topic:check syntax of OCL query
Next Topic:OCL iterate - help a begineer
Goto Forum:
  


Current Time: Wed Jul 23 02:04:46 EDT 2014

Powered by FUDForum. Page generated in 0.04047 seconds