|
|
Re: EReference and EKeys [message #1667734 is a reply to message #1666053] |
Thu, 12 March 2015 06:57 |
Martin Jacob Messages: 191 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Helvetica, Arial, sans-serif">Hi Ed,<br>
<br>
thanks for your comments. Live validation is enabled in preference
setting "Model Validation/Constraints". Do I have to sent an
option / annotation to enable validation? See my settings in the
picture below.<br>
<br>
But still its possible to have twice the same key. In my case the
key is a java.lang.String. May be it has some thing to do with the
use of == instead of equals to compare the keys?<br>
<br>
</font><br>
<img src="https://www.eclipse.org/forums/index.php?t=getfile&id=21144" alt=""><br>
<div class="moz-cite-prefix">Ed Merks schrieb am 11.03.2015 um
15:19:<br>
</div>
<blockquote cite="mid:mdpith$cov$1@xxxxxxxxe.org" type="cite">Martin,
<br>
<br>
Comments below.
<br>
<br>
On 11/03/2015 9:21 AM, Martin Jacob wrote:
<br>
<blockquote type="cite">Dear all,
<br>
<br>
I can not figure out how the ERefernce works with EKeys. I
imagine the EReference should reject to add an Object if already
an Object with the same EKey exists in this particular list.
<br>
</blockquote>
No, it's a constraint that's validated. If you've enabled live
validation for the generated editor you'll see that it's checked
after the fact...
<br>
<blockquote type="cite">But the generated default editor is able
to set two objects with the same key into a reference.
<br>
</blockquote>
Imagine changing the value of the key after the fact such that a
duplicate arises as a result of that, rather than as a result of
adding an object to the reference's list.
<br>
<blockquote type="cite">
<br>
I am using Ecore Tools with Eclipse 4.4.1.
<br>
<br>
The object ConductorTypes references ConductorType (without"s"
at the end)
<br>
<br>
The eCore snippet is as below:
<br>
<eClassifiers xsi:type="ecore:EClass"
name="ConductorType">
<br>
<eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>>
<br>
<details key="kind" value="elementOnly"/>
<br>
</eAnnotations>
<br>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="name" eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//String">http://www.eclipse.org/emf/2003/XMLType#//String</a>"/>
<br>
<eStructuralFeatures xsi:type="ecore:EReference"
name="material" lowerBound="1"
<br>
eType="#//Material" eKeys="#//Material/name">
<br>
<eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>>
<br>
<details key="kind" value="attribute"/>
<br>
<details key="name" value="materialID"/>
<br>
</eAnnotations>
<br>
</eStructuralFeatures>
<br>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="crossSection_mm2" eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//Double">http://www.eclipse.org/emf/2003/XMLType#//Double</a>"/>
<br>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="degreeOfWear_percent" eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//Double">http://www.eclipse.org/emf/2003/XMLType#//Double</a>"/>
<br>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="equivalentRadius_mm" eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//Double">http://www.eclipse.org/emf/2003/XMLType#//Double</a>"/>
<br>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="temperature_DegreeCentigrade"
<br>
eType="ecore:EDataType
<a class="moz-txt-link-freetext" href="http://www.eclipse.org/emf/2003/XMLType#//Double">http://www.eclipse.org/emf/2003/XMLType#//Double</a>"
defaultValueLiteral="20"/>
<br>
</eClassifiers>
<br>
<br>
<br>
<eClassifiers xsi:type="ecore:EClass"
name="ConductorTypes">
<br>
<eStructuralFeatures xsi:type="ecore:EReference"
name="conductorType" lowerBound="1"
<br>
upperBound="-1" eType="#//ConductorType"
containment="true" eKeys="#//ConductorType/name">
<br>
<eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>>
<br>
<details key="kind" value="element"/>
<br>
<details key="name" value="ConductorType"/>
<br>
</eAnnotations>
<br>
</eStructuralFeatures>
<br>
</eClassifiers>
<br>
<br>
<br>
any help is appreciated, Martin
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>
-
Attachment: jibhhegc.png
(Size: 125.04KB, Downloaded 131 times)
|
|
|
Re: EReference and EKeys [message #1668744 is a reply to message #1667734] |
Thu, 12 March 2015 16:22 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Martin,
Yes, it's a GenModel property (Decorator) in the Editor section which
you can set when you open the *.genmodel.
Yes, in general the model can be in an invalid state with respect to
this constraint. The runtime should be using .equals to compare keys.
On 12/03/2015 7:57 AM, Martin Jacob wrote:
> Hi Ed,
>
> thanks for your comments. Live validation is enabled in preference
> setting "Model Validation/Constraints". Do I have to sent an option /
> annotation to enable validation? See my settings in the picture below.
>
> But still its possible to have twice the same key. In my case the key
> is a java.lang.String. May be it has some thing to do with the use of
> == instead of equals to compare the keys?
>
>
>
> Ed Merks schrieb am 11.03.2015 um 15:19:
>> Martin,
>>
>> Comments below.
>>
>> On 11/03/2015 9:21 AM, Martin Jacob wrote:
>>> Dear all,
>>>
>>> I can not figure out how the ERefernce works with EKeys. I imagine
>>> the EReference should reject to add an Object if already an Object
>>> with the same EKey exists in this particular list.
>> No, it's a constraint that's validated. If you've enabled live
>> validation for the generated editor you'll see that it's checked
>> after the fact...
>>> But the generated default editor is able to set two objects with the
>>> same key into a reference.
>> Imagine changing the value of the key after the fact such that a
>> duplicate arises as a result of that, rather than as a result of
>> adding an object to the reference's list.
>>>
>>> I am using Ecore Tools with Eclipse 4.4.1.
>>>
>>> The object ConductorTypes references ConductorType (without"s" at
>>> the end)
>>>
>>> The eCore snippet is as below:
>>> <eClassifiers xsi:type="ecore:EClass" name="ConductorType">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="kind" value="elementOnly"/>
>>> </eAnnotations>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//String"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="material"
>>> lowerBound="1"
>>> eType="#//Material" eKeys="#//Material/name">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="kind" value="attribute"/>
>>> <details key="name" value="materialID"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="crossSection_mm2" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//Double"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="degreeOfWear_percent" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//Double"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="equivalentRadius_mm" eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//Double"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="temperature_DegreeCentigrade"
>>> eType="ecore:EDataType
>>> http://www.eclipse.org/emf/2003/XMLType#//Double"
>>> defaultValueLiteral="20"/>
>>> </eClassifiers>
>>>
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="ConductorTypes">
>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>> name="conductorType" lowerBound="1"
>>> upperBound="-1" eType="#//ConductorType" containment="true"
>>> eKeys="#//ConductorType/name">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="kind" value="element"/>
>>> <details key="name" value="ConductorType"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>> </eClassifiers>
>>>
>>>
>>> any help is appreciated, Martin
>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02959 seconds