[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.mdt.uml2.ocl] Re: OCL and EMF 2.3 Generics

Hi, Miguel,

Currently (and in M5), the OCL parser does not interpret the EEList data
type as equivalent of OCL's Sequence.  Rather, the collection type of a
multivalued feature is implied by the feature's uniqueness and orderedness,
as indicated in both the UML and OCL specifications:

  - multivalued feature of type T is ...
     - unique and ordered      ==> OrderedSet(T)
     - unique and unordered    ==> Set(T)
     - nonunique and ordered   ==> Sequence(T)
     - nonunique and unordered ==> Bag(T)

While Ecore does define an EEList data type, it does not define ESet,
EOrderedSet, EBag.

If you want to define an ETypedElement having a type that resolves (in OCL)
to Sequence(Sequence(CharacterObject)), then you would actually have to use
the OCL collection types in your model.  Otherwise, the type of your
*scalar* feature of type EEList<EEList<CharacterObject>> will be treated by
OCL as an opaque data type.  This probably isn't convenient.

Regarding your usage of the TypeResolverImpl:  this won't do what you want. 
Try this instead:

  private void displayOCLType(ETypedElement te, EClass ec) {
 
   EClassifier oclType = TypeUtil.getOCLType(te);
   String oclTypeName = getName(oclType);

HTH,

Christian

news.eclipse.org wrote:

> 
> Hi,
> 
> I've been looking at how OCL types an ETyped Element with an EGenericType,
> using this code:
> 
>  private void displayOCLType(ETypedElement te, EClass ec) {
> 
>   TypeResolver tr = new TypeResolverImpl(ec.eResource());
> 
>   EClassifier oclType = tr.resolve(te.getEType());
>   String oclTypeName = getName(oclType);
> 
> My question is, in 1.1M5 or later, what OCL types will be given to the
> following (for example):
> 
> a) an ETypedElement with eGenericType "EEList<EEList<CharacterObject>>"
> 
> b) In OCLTest.ecore (in the tests plugin, from CVS) the code above does
> not return
>    OrderedSet(Fruit), Set(Fruit), and so on, for the EReference
>    FruitUtil.orderedSet, and so on.
> Am I using the right APIs?
> 
> Again, this is not with the aim of opening a bug, but rather I would like
> to know the statement of direction for 1.1
> 
> Regards,
> 
> Miguel