Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] FeatureMap with EOpposites
[EMF] FeatureMap with EOpposites [message #629751] Wed, 29 September 2010 12:55 Go to next message
Mario Charest is currently offline Mario CharestFriend
Messages: 42
Registered: July 2009
Member
Hi everybody,

is it possible to model a FeatureMap based on references with opposites?
I annotated the model like proposed in the EMF book, but the generated
code always contains errors, because it generates a normal Elist instead
of a FeatureMap

In the class "Container" i have list of "Node" in the *.ecore:

<eStructuralFeatures xsi:type="ecore:EReference" name="nodes"
upperBound="-1"
eType="#//Node" containment="true" eOpposite="#//Node/parent">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="group"/>
</eAnnotations>
</eStructuralFeatures>

Then i have a "IFDiagram" and "IGDiagram" Classes that extend the
"Container" Class containing this:

<eStructuralFeatures xsi:type="ecore:EReference" name="node"
upperBound="-1" eType="#//Node"
changeable="false" volatile="true" transient="true"
derived="true" containment="true">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="group" value="#nodes"/>
</eAnnotations>
</eStructuralFeatures>

and a "Node" class with a reference to the parent "Container" like this:

<eStructuralFeatures xsi:type="ecore:EReference" name="parent"
eType="#//Container"
eOpposite="#//Container/nodes"/>

The getNode() methods of IFDiagram and IGDiagram are correctly
generated, but the getNodes() Method in "Container" has the returntype
EList<Node>, because the reference isn't mapped to a featuremap :/
I know that one could model a multi-value Attribute with FeatureMapEntry
type, but attributes don't support eopposites, i guess?
So what did i made wrong? Or is this simply not possible?

Greets, Mario
Re: [EMF] FeatureMap with EOpposites [message #629788 is a reply to message #629751] Wed, 29 September 2010 14:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Mario,

Comments below.

Mario wrote:
> Hi everybody,
>
> is it possible to model a FeatureMap based on references with
> opposites? I annotated the model like proposed in the EMF book, but
> the generated code always contains errors, because it generates a
> normal Elist instead of a FeatureMap
>
> In the class "Container" i have list of "Node" in the *.ecore:
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="nodes"
> upperBound="-1"
> eType="#//Node" containment="true" eOpposite="#//Node/parent">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="group"/>
Doesn't a group need to be a feature map?
> </eAnnotations>
> </eStructuralFeatures>
>
> Then i have a "IFDiagram" and "IGDiagram" Classes that extend the
> "Container" Class containing this:
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="node"
> upperBound="-1" eType="#//Node"
> changeable="false" volatile="true" transient="true"
> derived="true" containment="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="group" value="#nodes"/>
> </eAnnotations>
> </eStructuralFeatures>
>
> and a "Node" class with a reference to the parent "Container" like this:
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="parent"
> eType="#//Container"
> eOpposite="#//Container/nodes"/>
>
> The getNode() methods of IFDiagram and IGDiagram are correctly
> generated, but the getNodes() Method in "Container" has the returntype
> EList<Node>, because the reference isn't mapped to a featuremap :/
> I know that one could model a multi-value Attribute with
> FeatureMapEntry type, but attributes don't support eopposites, i guess?
No, but the features that delegate into the map can.
> So what did i made wrong?
It looks wrong to me.
> Or is this simply not possible?
Feature maps themselves can't have opposites. The features that
delegate to them can. Try to write your model as a schema...
>
> Greets, Mario


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] FeatureMap with EOpposites [message #629845 is a reply to message #629788] Wed, 29 September 2010 17:49 Go to previous messageGo to next message
Mario Charest is currently offline Mario CharestFriend
Messages: 42
Registered: July 2009
Member
Hi Ed,
thanks for your answer.

> Doesn't a group need to be a feature map?
The EMF-Book suggests a Multi-Value Attribute (which works perfectly)
but mentiones (in a little sidenote, though), that this should also work
with a reference.

I just found an online doc
( http://www.eclipse.org/modeling/emf/docs/overviews/FeatureMa p.pdf)
which says:

"[..] (Note: I think that we should change the importer to alternatively
allow the orders feature to be defined in UML as a
third reference to PurchaseOrder as in the previous diagram. I think
that providing the kind=group annotation
would be sufficient information to indicate that it maps to a FeatureMap
implementation) [..]"

My initial question was merely if this feature (annotating reference
with kind=group) realy exists and if yes, why it doesn't work for me :)

> Feature maps themselves can't have opposites. The features that delegate
> to them can. Try to write your model as a schema...

Would this help? The model is not that small and i'm not the only one
working with it. So i really would like to avoid this step.

Am 09/29/10 16:44, schrieb Ed Merks:
> Mario,
>
> Comments below.
>
> Mario wrote:
>> Hi everybody,
>>
>> is it possible to model a FeatureMap based on references with
>> opposites? I annotated the model like proposed in the EMF book, but
>> the generated code always contains errors, because it generates a
>> normal Elist instead of a FeatureMap
>>
>> In the class "Container" i have list of "Node" in the *.ecore:
>>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="nodes"
>> upperBound="-1"
>> eType="#//Node" containment="true" eOpposite="#//Node/parent">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="group"/>
> Doesn't a group need to be a feature map?
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>> Then i have a "IFDiagram" and "IGDiagram" Classes that extend the
>> "Container" Class containing this:
>>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="node"
>> upperBound="-1" eType="#//Node"
>> changeable="false" volatile="true" transient="true" derived="true"
>> containment="true">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="group" value="#nodes"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>>
>> and a "Node" class with a reference to the parent "Container" like this:
>>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="parent"
>> eType="#//Container"
>> eOpposite="#//Container/nodes"/>
>>
>> The getNode() methods of IFDiagram and IGDiagram are correctly
>> generated, but the getNodes() Method in "Container" has the returntype
>> EList<Node>, because the reference isn't mapped to a featuremap :/
>> I know that one could model a multi-value Attribute with
>> FeatureMapEntry type, but attributes don't support eopposites, i guess?
> No, but the features that delegate into the map can.
>> So what did i made wrong?
> It looks wrong to me.
>> Or is this simply not possible?
> Feature maps themselves can't have opposites. The features that delegate
> to them can. Try to write your model as a schema...
>>
>> Greets, Mario
Re: [EMF] FeatureMap with EOpposites [message #629854 is a reply to message #629845] Wed, 29 September 2010 18:28 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Mario,

I only suggest a schema because that's the best way to ensure you have a
consistent set of extended meta data annotations...

Taking a step back and trying to figure out what you're hoping to
accomplish, I'm not at all sure your goal. What exactly is the point of
trying to define both a "node" and a "nodes" references?


Mario wrote:
> Hi Ed,
> thanks for your answer.
>
> > Doesn't a group need to be a feature map?
> The EMF-Book suggests a Multi-Value Attribute (which works perfectly)
> but mentiones (in a little sidenote, though), that this should also
> work with a reference.
>
> I just found an online doc
> ( http://www.eclipse.org/modeling/emf/docs/overviews/FeatureMa p.pdf)
> which says:
>
> "[..] (Note: I think that we should change the importer to
> alternatively allow the orders feature to be defined in UML as a
> third reference to PurchaseOrder as in the previous diagram. I think
> that providing the kind=group annotation
> would be sufficient information to indicate that it maps to a
> FeatureMap implementation) [..]"
>
> My initial question was merely if this feature (annotating reference
> with kind=group) realy exists and if yes, why it doesn't work for me :)
>
> > Feature maps themselves can't have opposites. The features that
> delegate
> > to them can. Try to write your model as a schema...
>
> Would this help? The model is not that small and i'm not the only one
> working with it. So i really would like to avoid this step.
>
> Am 09/29/10 16:44, schrieb Ed Merks:
>> Mario,
>>
>> Comments below.
>>
>> Mario wrote:
>>> Hi everybody,
>>>
>>> is it possible to model a FeatureMap based on references with
>>> opposites? I annotated the model like proposed in the EMF book, but
>>> the generated code always contains errors, because it generates a
>>> normal Elist instead of a FeatureMap
>>>
>>> In the class "Container" i have list of "Node" in the *.ecore:
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="nodes"
>>> upperBound="-1"
>>> eType="#//Node" containment="true" eOpposite="#//Node/parent">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="kind" value="group"/>
>> Doesn't a group need to be a feature map?
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>> Then i have a "IFDiagram" and "IGDiagram" Classes that extend the
>>> "Container" Class containing this:
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="node"
>>> upperBound="-1" eType="#//Node"
>>> changeable="false" volatile="true" transient="true" derived="true"
>>> containment="true">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="group" value="#nodes"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>>
>>> and a "Node" class with a reference to the parent "Container" like
>>> this:
>>>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="parent"
>>> eType="#//Container"
>>> eOpposite="#//Container/nodes"/>
>>>
>>> The getNode() methods of IFDiagram and IGDiagram are correctly
>>> generated, but the getNodes() Method in "Container" has the returntype
>>> EList<Node>, because the reference isn't mapped to a featuremap :/
>>> I know that one could model a multi-value Attribute with
>>> FeatureMapEntry type, but attributes don't support eopposites, i guess?
>> No, but the features that delegate into the map can.
>>> So what did i made wrong?
>> It looks wrong to me.
>>> Or is this simply not possible?
>> Feature maps themselves can't have opposites. The features that delegate
>> to them can. Try to write your model as a schema...
>>>
>>> Greets, Mario
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Restriction Of Complex Types Not Validating
Next Topic:Change Code generation
Goto Forum:
  


Current Time: Thu Apr 25 00:17:56 GMT 2024

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

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

Back to the top