Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » [OCLinEcore] Possibility of defining an attribute as a list of list
[OCLinEcore] Possibility of defining an attribute as a list of list [message #558438] Sun, 12 September 2010 20:12 Go to next message
Simon harrer is currently offline Simon harrerFriend
Messages: 25
Registered: August 2010
Junior Member
Hello,

I want to define an attribute as a list of list, or a sequence with sequences of a specific type.

I was only able to do this using generics. Is there another way, as generics are not supported by OCL or QVTo or Acceleo?

My try was to program this:
property parallelTransitions : Set(Set(Transition));


However, I only got this working:
property parallelTransitions : ParallelTransition[*];

class ParallelTRansition {
   property transitions : Transition[*];
}

But this is quite a workaround as the additional data structures have to be created each time the transition data changes ....
Re: [OCLinEcore] Possibility of defining an attribute as a list of list [message #558538 is a reply to message #558438] Mon, 13 September 2010 12:06 Go to previous messageGo to next message
Adolfo Sanchez-Barbudo Herrera is currently offline Adolfo Sanchez-Barbudo HerreraFriend
Messages: 260
Registered: July 2009
Senior Member
Simon,

Remember that the files you are editing mixes your ecore model
definition with the constraints you want to add to them. So

>
> property parallelTransitions : Set(Set(Transition));
>

This is not valid. You are defining a class of your model, and the OCL
Set type is not a valid type of your ecore model. So here, you have to
deal with what emf types offers you (helped in this case by the textual
OCLInEcore editor): the EMF types or the types you create in your model.
>
> However, I only got this working:
>
> property parallelTransitions : ParallelTransition[*];
>
> class ParallelTRansition {
> property transitions : Transition[*];
> }
>
> But this is quite a workaround as the additional data structures have to
> be created each time the transition data changes ....

In this case, you always have to deal with EMF its capabilities, it's
not a problem of OCL. If you don't need to serialize the
parallelTransitions, and just need the generated Java API to be managed
prortgamatically, you could try the attribute EEList:

attribute parallelTransitions : ecore_0::EEList<?>[*] { transient };

Of course you'd lose the type (Transition) of your property, without any
chance to serialize your parallel transitions, so it's not probably very
useful.

Otherwise, you will need other modeling mechanisms as the one you have
mentioned. You may want to forward the question to the EMF newsgroup to
ask the EMF's gurus about the better solution to this.

> I was only able to do this using generics. Is there another way, as
> generics are not supported by OCL or QVTo or Acceleo?

Note that although OCL language doesn't support generics in the
constraints, you could still create your EMF model using generics when
needed, as long as, you don't require to include the use of the generic
type inside the OCL constraint. Look at the following simple example
I've just tested:


import ecore_0 : 'http://www.eclipse.org/emf/2002/Ecore#/';

package Test : Test = 'http://test'
{
class Animal;
class Pork extends Animal;
class Cow extends Animal;
class GroupOfAnimals<A> extends Animal
{
property animal : A[*];
operation isAGroupOfCows() : Boolean[1]
{
body: animal->forAll(oclIsTypeOf(Cow));
}
}
class Farm
{
property content : Animal[*] { composes };
}
}

In our farm, you may create a SetOfAnimals, which refers to several
animals. The "isAGroupOfCows()" operation only evaluates to false if
your group contains something different to a cow.

Regards,
Adolfo.
Re: [OCLinEcore] Possibility of defining an attribute as a list of list [message #558553 is a reply to message #558538] Mon, 13 September 2010 13:14 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Simon, Adolfo

>> property parallelTransitions : Set(Set(Transition));
>>
>
> This is not valid.

This is not valid according to the OCL 2.2 specification, however OCL
aspires to UML alignment and it is a perfectly reasonable thing to want
to do. I suspect that OMG OCL and possibly UML may need to evaolve.

I hope that MDT/OCL 4.0.0 and possibly MDT/OCL 3.2.0 examples for Helios
will support this. But it might be Set<Set<Transformation>> for
UML consistency.

Regards
Previous Topic:Missing "Object Constraint Language (OCL) 2.0 Compatibility API"
Next Topic:Newby question
Goto Forum:
  


Current Time: Thu Apr 25 16:45:00 GMT 2024

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

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

Back to the top