Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » automatic values for maps
automatic values for maps [message #401717] Tue, 13 June 2006 05:46 Go to next message
Philipp W. Kutter is currently offline Philipp W. Kutter
Messages: 301
Registered: July 2009
Senior Member
We have the following use case:

A map myMap is defined in Ecore, keyType="myKeyType"
valueType="myValueType"

Now, the only purpose of the myValueType objects is to be values of
this map. The actual content is in the features of myValueType.

Currently, we need to have a second containment feature besides myMap,
called rangeObjectsForMyMap, which contains the instances of myValueType,
and for each entry in the map, we first need to create the instance of
myValueType, then set it as value, and then we set the features of the
myValueType object.

Disadvantages are:
- we need to introduce a feature, which is only here for technical reasons
- objects of the myValueType must be explicitly definied, but its an
automatic
task: each time a new entry in the map is done, a new instance of the
value
type is created.
- the actual fields of the map-values cannot be edited in the map, but in
the
artificial containment list.


What would be great is an additional option "automaticValues" for the maps,
which creates all these things in the background, and then displays the
map value object below the map-entry in the editor, rather than in the
artificial containment list.

I know that all the ingredients to do so have been discussed here and in
the
book, and we have done similar things. While there are many, many variants
of this which may be useful, this particular use case has popped up again
and
again in our daily work.

Would be great to have post of people who have the same need.

Best Regards, Philipp
Re: automatic values for maps [message #401721 is a reply to message #401717] Tue, 13 June 2006 07:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Philipp,

Comments below...

Philipp W. Kutter wrote:
> We have the following use case:
>
> A map myMap is defined in Ecore, keyType="myKeyType"
> valueType="myValueType"
>
> Now, the only purpose of the myValueType objects is to be values of
> this map. The actual content is in the features of myValueType.
>
> Currently, we need to have a second containment feature besides myMap,
> called rangeObjectsForMyMap, which contains the instances of
> myValueType, and for each entry in the map, we first need to create
> the instance of myValueType, then set it as value, and then we set the
> features of the
> myValueType object.
Why can't the value feature itself be a containment reference to hold
the value?
>
> Disadvantages are:
> - we need to introduce a feature, which is only here for technical
> reasons
> - objects of the myValueType must be explicitly definied, but its an
> automatic
> task: each time a new entry in the map is done, a new instance of the
> value
> type is created.
It sounds like the value field itself should be a containment then.
> - the actual fields of the map-values cannot be edited in the map, but
> in the
> artificial containment list.
>
>
> What would be great is an additional option "automaticValues" for the
> maps,
> which creates all these things in the background, and then displays
> the map value object below the map-entry in the editor, rather than in
> the artificial containment list.
It again sounds like making value be a containment would do the trick...
>
> I know that all the ingredients to do so have been discussed here and
> in the book, and we have done similar things. While there are many,
> many variants of this which may be useful, this particular use case
> has popped up again and again in our daily work.
>
> Would be great to have post of people who have the same need.
>
> Best Regards, Philipp
>
>
Re: automatic values for maps [message #401829 is a reply to message #401721] Wed, 14 June 2006 06:36 Go to previous messageGo to next message
Philipp W. Kutter is currently offline Philipp W. Kutter
Messages: 301
Registered: July 2009
Senior Member
Dear Ed,

>> A map myMap is defined in Ecore, keyType="myKeyType"
>> valueType="myValueType"
>>
>> Now, the only purpose of the myValueType objects is to be values of
>> this map. The actual content is in the features of myValueType.
>>
>> Currently, we need to have a second containment feature besides myMap,
>> called rangeObjectsForMyMap, which contains the instances of
>> myValueType, and for each entry in the map, we first need to create
>> the instance of myValueType, then set it as value, and then we set the
>> features of the
>> myValueType object.
> Why can't the value feature itself be a containment reference to hold
> the value?

Agreed :) We didn't take into account (for whatever reason...) that it
is possible to change the properties of the value feature. Setting the
containment property of the value feature in the ecore leads directly to
what we wanted. Thanks!

However, there is a new question now: is it possible to specify the
containment property for the value feature directly in a Java
annotation? We tried the following:

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model keyType="A" valueType="B" valueContainment="true"
* @generated
*/
EMap getA2BMap();

But this does not seem to have any influence on the containment property
of the value feature of the generated map entry class. Any hints?

Best,
Marc
Re: automatic values for maps [message #401834 is a reply to message #401829] Wed, 14 June 2006 06:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020402040801040602010405
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Philipp,

Once you've generated the XyzPackage, the map entry information will be
specified on the map entry's classifier like this example from EcorePackage:

/**
* Returns the meta object for class '{@link java.util.Map.Entry
<em>EString To String Map Entry</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the meta object for class '<em>EString To String Map
Entry</em>'.
* @see java.util.Map.Entry
* @model keyType="java.lang.String"
* valueType="java.lang.String"
* @generated
*/
EClass getEStringToStringMapEntry();

Once specified here, the information specified at the point of reference
is redundant and changing details like valueContainment="true" are
ignored. At that point, you need to specify details like
valueContainment="true" where the map entry is actually defined, which
is the XyzPackage interface.


Philipp W. Kutter wrote:

> Dear Ed,
>
>>> A map myMap is defined in Ecore, keyType="myKeyType"
>>> valueType="myValueType"
>>>
>>> Now, the only purpose of the myValueType objects is to be values of
>>> this map. The actual content is in the features of myValueType.
>>>
>>> Currently, we need to have a second containment feature besides
>>> myMap, called rangeObjectsForMyMap, which contains the instances of
>>> myValueType, and for each entry in the map, we first need to create
>>> the instance of myValueType, then set it as value, and then we set
>>> the features of the
>>> myValueType object.
>>
>> Why can't the value feature itself be a containment reference to hold
>> the value?
>
>
> Agreed :) We didn't take into account (for whatever reason...) that it
> is possible to change the properties of the value feature. Setting the
> containment property of the value feature in the ecore leads directly
> to what we wanted. Thanks!
>
> However, there is a new question now: is it possible to specify the
> containment property for the value feature directly in a Java
> annotation? We tried the following:
>
> /**
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @model keyType="A" valueType="B" valueContainment="true"
> * @generated
> */
> EMap getA2BMap();
>
> But this does not seem to have any influence on the containment
> property of the value feature of the generated map entry class. Any
> hints?
>
> Best,
> Marc



--------------020402040801040602010405
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Philipp,<br>
<br>
Once you've generated the XyzPackage, the map entry information will be
specified on the map entry's classifier like this example from
EcorePackage:<br>
<blockquote>
Re: automatic values for maps [message #401844 is a reply to message #401834] Wed, 14 June 2006 11:19 Go to previous message
Philipp W. Kutter is currently offline Philipp W. Kutter
Messages: 301
Registered: July 2009
Senior Member
Thanks a lot great. Like this, the models and editors get much nicer!

Best, Philipp

Ed Merks wrote:
> Philipp,
>
> Once you've generated the XyzPackage, the map entry information will be
> specified on the map entry's classifier like this example from EcorePackage:
>
> /**
> * Returns the meta object for class '{@link java.util.Map.Entry
> <em>EString To String Map Entry</em>}'.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @return the meta object for class '<em>EString To String Map
> Entry</em>'.
> * @see java.util.Map.Entry
> * @model keyType="java.lang.String"
> * valueType="java.lang.String"
> * @generated
> */
> EClass getEStringToStringMapEntry();
>
> Once specified here, the information specified at the point of reference
> is redundant and changing details like valueContainment="true" are
> ignored. At that point, you need to specify details like
> valueContainment="true" where the map entry is actually defined, which
> is the XyzPackage interface.
>
>
> Philipp W. Kutter wrote:
>
>> Dear Ed,
>>
>>>> A map myMap is defined in Ecore, keyType="myKeyType"
>>>> valueType="myValueType"
>>>>
>>>> Now, the only purpose of the myValueType objects is to be values of
>>>> this map. The actual content is in the features of myValueType.
>>>>
>>>> Currently, we need to have a second containment feature besides
>>>> myMap, called rangeObjectsForMyMap, which contains the instances of
>>>> myValueType, and for each entry in the map, we first need to create
>>>> the instance of myValueType, then set it as value, and then we set
>>>> the features of the
>>>> myValueType object.
>>>
>>> Why can't the value feature itself be a containment reference to hold
>>> the value?
>>
>>
>> Agreed :) We didn't take into account (for whatever reason...) that it
>> is possible to change the properties of the value feature. Setting the
>> containment property of the value feature in the ecore leads directly
>> to what we wanted. Thanks!
>>
>> However, there is a new question now: is it possible to specify the
>> containment property for the value feature directly in a Java
>> annotation? We tried the following:
>>
>> /**
>> * <!-- begin-user-doc -->
>> * <!-- end-user-doc -->
>> * @model keyType="A" valueType="B" valueContainment="true"
>> * @generated
>> */
>> EMap getA2BMap();
>>
>> But this does not seem to have any influence on the containment
>> property of the value feature of the generated map entry class. Any
>> hints?
>>
>> Best,
>> Marc
>
>
Previous Topic:dynamic feature map
Next Topic:trying to reach fixpoint in regenerating model: problems with data type
Goto Forum:
  


Current Time: Wed Jul 30 21:35:10 EDT 2014

Powered by FUDForum. Page generated in 0.01628 seconds