Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » how to create a TupleType?
how to create a TupleType? [message #43078] Wed, 07 November 2007 17:21 Go to next message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Hi All,

I need to create a TupleType with certain structure inside.
I suppose I start from:

org.eclipse.ocl.types.TupleType tupleType =
UMLFactory.eINSTANCE.createTupleType();

and then what?
I cannot find any sensible methods in TupleType interface.

Thanks in advance,
Krzysztof
Re: how to create a TupleType? [message #43112 is a reply to message #43078] Wed, 07 November 2007 18:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Krzysztof,

In order to do this, you will have to know whether you are creating an Ecore
or a UML TupleType, and use the corresponding factories. The generic
org.eclipse.ocl.types.TupleType will be of no use.

The Ecore binding of TupleType (org.eclipse.ocl.ecore.TupleType) extends
EClass, so it can own EStructuralFeatures (which comprise the only
structure that a tuple type can have).

For UML, the org.eclipse.ocl.uml.TupleType extends DataType, so it can own
Propertys.

HTH,

Christian

Krzysztof Kaczmarski wrote:

> Hi All,
>
> I need to create a TupleType with certain structure inside.
> I suppose I start from:
>
> org.eclipse.ocl.types.TupleType tupleType =
> UMLFactory.eINSTANCE.createTupleType();
>
> and then what?
> I cannot find any sensible methods in TupleType interface.
>
> Thanks in advance,
> Krzysztof
Re: how to create a TupleType? [message #43134 is a reply to message #43112] Wed, 07 November 2007 19:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Thanks.

I suppose it should be serialized somewhere in the model as for
instance BagType?

K.

Christian W. Damus wrote:
> Hi, Krzysztof,
>
> In order to do this, you will have to know whether you are creating an Ecore
> or a UML TupleType, and use the corresponding factories. The generic
> org.eclipse.ocl.types.TupleType will be of no use.
>
> The Ecore binding of TupleType (org.eclipse.ocl.ecore.TupleType) extends
> EClass, so it can own EStructuralFeatures (which comprise the only
> structure that a tuple type can have).
>
> For UML, the org.eclipse.ocl.uml.TupleType extends DataType, so it can own
> Propertys.
>
> HTH,
>
> Christian
>
> Krzysztof Kaczmarski wrote:
>
>> Hi All,
>>
>> I need to create a TupleType with certain structure inside.
>> I suppose I start from:
>>
>> org.eclipse.ocl.types.TupleType tupleType =
>> UMLFactory.eINSTANCE.createTupleType();
>>
>> and then what?
>> I cannot find any sensible methods in TupleType interface.
>>
>> Thanks in advance,
>> Krzysztof
>
Re: how to create a TupleType? [message #43159 is a reply to message #43134] Wed, 07 November 2007 19:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Krzysztof,

Yes, you'll want to be sure that your TupleType is serialized someplace
where it can be found when deserializing an OCL AST that references it.
Your Environment's TypeResolver (Environment::getTypeResolver) has a
resolveTupleType(...) method that will ensure it is persisted in the
environment along with the BagTypes and other dynamically-created types.

Say, now that I mention it, it occurs to me that this is a much better
solution than my previous post. The TypeResolver::resolveTupleType method
accepts a list of TypedElements representing the tuple's parts, and will
return an existing tuple type that matches or, if necessary, will create a
new one.

So, all that you really need to do to create your tuple type is to create a
list of Variables with the names and types that you want for your tuple
parts, and use the TypeResolver to get your tuple type.

cW


Krzysztof Kaczmarski wrote:

> Thanks.
>
> I suppose it should be serialized somewhere in the model as for
> instance BagType?
>
> K.
>
> Christian W. Damus wrote:
>> Hi, Krzysztof,
>>
>> In order to do this, you will have to know whether you are creating an
>> Ecore
>> or a UML TupleType, and use the corresponding factories. The generic
>> org.eclipse.ocl.types.TupleType will be of no use.
>>
>> The Ecore binding of TupleType (org.eclipse.ocl.ecore.TupleType) extends
>> EClass, so it can own EStructuralFeatures (which comprise the only
>> structure that a tuple type can have).
>>
>> For UML, the org.eclipse.ocl.uml.TupleType extends DataType, so it can
>> own Propertys.
>>
>> HTH,
>>
>> Christian

-----8<-----
Re: how to create a TupleType? [message #43168 is a reply to message #43159] Thu, 08 November 2007 09:39 Go to previous message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Hi Christian,

indeed, idea of using TypeResolver is very good but it will not work
for me since I do not use OCL's parser.

Thanks,
KK


Christian W. Damus wrote:
> Hi, Krzysztof,
>
> Yes, you'll want to be sure that your TupleType is serialized someplace
> where it can be found when deserializing an OCL AST that references it.
> Your Environment's TypeResolver (Environment::getTypeResolver) has a
> resolveTupleType(...) method that will ensure it is persisted in the
> environment along with the BagTypes and other dynamically-created types.
>
> Say, now that I mention it, it occurs to me that this is a much better
> solution than my previous post. The TypeResolver::resolveTupleType method
> accepts a list of TypedElements representing the tuple's parts, and will
> return an existing tuple type that matches or, if necessary, will create a
> new one.
>
> So, all that you really need to do to create your tuple type is to create a
> list of Variables with the names and types that you want for your tuple
> parts, and use the TypeResolver to get your tuple type.
>
> cW
>
>
> Krzysztof Kaczmarski wrote:
>
>> Thanks.
>>
>> I suppose it should be serialized somewhere in the model as for
>> instance BagType?
>>
>> K.
>>
>> Christian W. Damus wrote:
>>> Hi, Krzysztof,
>>>
>>> In order to do this, you will have to know whether you are creating an
>>> Ecore
>>> or a UML TupleType, and use the corresponding factories. The generic
>>> org.eclipse.ocl.types.TupleType will be of no use.
>>>
>>> The Ecore binding of TupleType (org.eclipse.ocl.ecore.TupleType) extends
>>> EClass, so it can own EStructuralFeatures (which comprise the only
>>> structure that a tuple type can have).
>>>
>>> For UML, the org.eclipse.ocl.uml.TupleType extends DataType, so it can
>>> own Propertys.
>>>
>>> HTH,
>>>
>>> Christian
>
> -----8<-----
Previous Topic:[Announce] MDT 1.1 development plan
Next Topic:OCL to constrain the use of an association
Goto Forum:
  


Current Time: Thu Apr 18 22:51:58 GMT 2024

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

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

Back to the top