Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Compare] array as eattribute value
[EMF Compare] array as eattribute value [message #621995] Thu, 14 January 2010 10:24 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060308090502030902030609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,
I am using EMF compare to compare that conversion from xml to objects and back work correctly. My model (see attachment)
has a number of EAttributes which have an Array as value. I have to sets of eobjects, when I persist them to xml/xmi
then the two xmi's are exactly the same. But EMF Compare reports still many differences. It seems that the array values
are not compared on their content but on 'the same object'

I use this code to match and diff:

final Map<String, Object> options = new HashMap<String, Object>();
options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
MatchModel match = MatchService.doResourceMatch(resource1,
resource2, Collections.<String, Object> emptyMap());
// Computing differences
DiffModel diff = DiffService.doDiff(match, false);
assertTrue(diff.getDifferences().isEmpty());

Attached you can find my ecore file and the 2 xml files (which are the same).

(other comparison on other models work fine)

Let me know if I missed something obvious! (or not ofcourse :-)

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org

--------------060308090502030902030609
Content-Type: text/xml;
name="types.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="types.ecore"

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="types"
nsURI="http://www.eclipse.org/emf/texo/test/model//types" nsPrefix="types">
<eClassifiers xsi:type="ecore:EClass" name="SingleTypes">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="string" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral="test&quot;test"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="integer" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="integerObject" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="long" ordered="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"
defaultValueLiteral="200"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="longObject" ordered="false"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELongObject"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="double" ordered="false"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble" defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="doubleObject" ordered="false"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="float" ordered="false"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="floatObject" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloatObject"
defaultValueLiteral="10f"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="clazz" ordered="false">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments/>
</eGenericType>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="char" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EChar"
defaultValueLiteral="z"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="charObject" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ECharacterObject"
defaultValueLiteral="z"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="byte" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByte"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="byteObject" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByteObject"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="byteArray" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByteArray"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bigDecimal" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBigDecimal"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bigInteger" ordered="false"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBigInteger"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="enum" eType="#//TestEnum"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="date" ordered="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="stringArray" eType="#//StringArray"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="longArray" eType="#//LongArray"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="nextEnum" eType="#//TestNextEnum"
defaultValueLiteral="Enum2"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ManyTypes">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="string" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" defaultValueLiteral="test&quot;test"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="integerObject" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="long" ordered="false" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELongObject"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="doubleObject" ordered="false"
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="floatObject" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloatObject"
defaultValueLiteral="10f"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="clazz" ordered="false"
upperBound="-1">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments/>
</eGenericType>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="charObject" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ECharacterObject"
defaultValueLiteral="z"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="byteObject" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByteObject"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="byteArray" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EByteArray"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bigDecimal" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBigDecimal"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="bigInteger" ordered="false"
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBigInteger"
defaultValueLiteral="5"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="enum" upperBound="-1" eType="#//TestEnum"
defaultValueLiteral="test&quot;test"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="date" ordered="false" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate" defaultValueLiteral="test&quot;test"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="stringArray" upperBound="-1"
eType="#//StringArray" defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="longArray" upperBound="-1"
eType="#//LongArray" defaultValueLiteral=""/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="TestEnum">
<eLiterals name="Enum0" literal="Enum0"/>
<eLiterals name="Enum1" value="1" literal="Enum1"/>
<eLiterals name="Enum2" value="2" literal="Enum2"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="LongArray" instanceClassName="long[]"/>
<eClassifiers xsi:type="ecore:EDataType" name="StringArray" instanceClassName="java.lang.String[]"/>
<eClassifiers xsi:type="ecore:EEnum" name="TestNextEnum">
<eLiterals name="Enum1" value="1" literal="Enum1"/>
<eLiterals name="Enum2" value="2" literal="Enum2"/>
</eClassifiers>
</ecore:EPackage>

--------------060308090502030902030609
Content-Type: text/xml;
name="xml2.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="xml2.xml"

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:types="http://www.eclipse.org/emf/texo/test/model//types">
<types:ManyTypes>
<string>string1</string>
<string>string2</string>
<string>string3</string>
<string>string4</string>
<string>string5</string>
<integerObject>1</integerObject>
<integerObject>2</integerObject>
<integerObject>3</integerObject>
<integerObject>4</integerObject>
<integerObject>5</integerObject>
<long>1</long>
<long>2</long>
<long>3</long>
<long>4</long>
<long>5</long>
<doubleObject>0.1</doubleObject>
<doubleObject>0.2</doubleObject>
<doubleObject>0.30000000000000004</doubleObject>
<doubleObject>0.4</doubleObject>
<doubleObject>0.5</doubleObject>
<floatObject>0.1</floatObject>
<floatObject>0.2</floatObject>
<floatObject>0.3</floatObject>
<floatObject>0.4</floatObject>
<floatObject>0.5</floatObject>
<clazz xsi:nil="true"/>
<charObject>84</charObject>
<charObject>72</charObject>
<charObject>73</charObject>
<charObject>83</charObject>
<byteObject>0</byteObject>
<byteObject>1</byteObject>
<byteObject>2</byteObject>
<byteObject>3</byteObject>
<byteObject>4</byteObject>
<byteArray>00</byteArray>
<byteArray>01</byteArray>
<byteArray>02</byteArray>
<byteArray>03</byteArray>
<byteArray>04</byteArray>
<bigDecimal>0.1000000000000000055511151231257827021181583404541015625 </bigDecimal>
<bigDecimal>0.200000000000000011102230246251565404236316680908203125 </bigDecimal>
<bigDecimal>0.3000000000000000444089209850062616169452667236328125 </bigDecimal>
<bigDecimal>0.40000000000000002220446049250313080847263336181640625 </bigDecimal>
<bigDecimal>0.5</bigDecimal>
<bigInteger>1</bigInteger>
<bigInteger>2</bigInteger>
<bigInteger>3</bigInteger>
<bigInteger>4</bigInteger>
<bigInteger>5</bigInteger>
<enum>Enum0</enum>
<enum>Enum1</enum>
<enum>Enum2</enum>
<date>2010-01-29T11:22:08.342+0100</date>
<date>2010-02-28T11:22:08.342+0100</date>
<date>2010-03-29T11:22:08.342+0200</date>
<date>2010-04-28T11:22:08.342+0200</date>
<date>2010-05-27T11:22:08.342+0200</date>
<stringArray>stringArray1</stringArray>
<stringArray>stringArray2</stringArray>
<stringArray>stringArray3</stringArray>
<stringArray>stringArray4</stringArray>
<stringArray>stringArray5</stringArray>
<longArray>1</longArray>
<longArray>2</longArray>
<longArray>3</longArray>
<longArray>4</longArray>
<longArray>5</longArray>
</types:ManyTypes>
<types:SingleTypes string="string1" integer="1" integerObject="1" long="1" longObject="1" double="0.1" doubleObject="0.1" float="0.1" floatObject="0.1" char="84" charObject="84" byte="0" byteObject="0" byteArray="00" bigDecimal="0.1000000000000000055511151231257827021181583404541015625 " bigInteger="1" enum="Enum0" date="2010-01-29T11:22:08.340+0100" stringArray="stringArray1" longArray="1" nextEnum="Enum1"/>
</xmi:XMI>


--------------060308090502030902030609
Content-Type: text/xml;
name="xml3.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="xml3.xml"

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:types="http://www.eclipse.org/emf/texo/test/model//types">
<types:ManyTypes>
<string>string1</string>
<string>string2</string>
<string>string3</string>
<string>string4</string>
<string>string5</string>
<integerObject>1</integerObject>
<integerObject>2</integerObject>
<integerObject>3</integerObject>
<integerObject>4</integerObject>
<integerObject>5</integerObject>
<long>1</long>
<long>2</long>
<long>3</long>
<long>4</long>
<long>5</long>
<doubleObject>0.1</doubleObject>
<doubleObject>0.2</doubleObject>
<doubleObject>0.30000000000000004</doubleObject>
<doubleObject>0.4</doubleObject>
<doubleObject>0.5</doubleObject>
<floatObject>0.1</floatObject>
<floatObject>0.2</floatObject>
<floatObject>0.3</floatObject>
<floatObject>0.4</floatObject>
<floatObject>0.5</floatObject>
<clazz xsi:nil="true"/>
<charObject>84</charObject>
<charObject>72</charObject>
<charObject>73</charObject>
<charObject>83</charObject>
<byteObject>0</byteObject>
<byteObject>1</byteObject>
<byteObject>2</byteObject>
<byteObject>3</byteObject>
<byteObject>4</byteObject>
<byteArray>00</byteArray>
<byteArray>01</byteArray>
<byteArray>02</byteArray>
<byteArray>03</byteArray>
<byteArray>04</byteArray>
<bigDecimal>0.1000000000000000055511151231257827021181583404541015625 </bigDecimal>
<bigDecimal>0.200000000000000011102230246251565404236316680908203125 </bigDecimal>
<bigDecimal>0.3000000000000000444089209850062616169452667236328125 </bigDecimal>
<bigDecimal>0.40000000000000002220446049250313080847263336181640625 </bigDecimal>
<bigDecimal>0.5</bigDecimal>
<bigInteger>1</bigInteger>
<bigInteger>2</bigInteger>
<bigInteger>3</bigInteger>
<bigInteger>4</bigInteger>
<bigInteger>5</bigInteger>
<enum>Enum0</enum>
<enum>Enum1</enum>
<enum>Enum2</enum>
<date>2010-01-29T11:22:08.342+0100</date>
<date>2010-02-28T11:22:08.342+0100</date>
<date>2010-03-29T11:22:08.342+0200</date>
<date>2010-04-28T11:22:08.342+0200</date>
<date>2010-05-27T11:22:08.342+0200</date>
<stringArray>stringArray1</stringArray>
<stringArray>stringArray2</stringArray>
<stringArray>stringArray3</stringArray>
<stringArray>stringArray4</stringArray>
<stringArray>stringArray5</stringArray>
<longArray>1</longArray>
<longArray>2</longArray>
<longArray>3</longArray>
<longArray>4</longArray>
<longArray>5</longArray>
</types:ManyTypes>
<types:SingleTypes string="string1" integer="1" integerObject="1" long="1" longObject="1" double="0.1" doubleObject="0.1" float="0.1" floatObject="0.1" char="84" charObject="84" byte="0" byteObject="0" byteArray="00" bigDecimal="0.1000000000000000055511151231257827021181583404541015625 " bigInteger="1" enum="Enum0" date="2010-01-29T11:22:08.340+0100" stringArray="stringArray1" longArray="1" nextEnum="Enum1"/>
</xmi:XMI>


--------------060308090502030902030609--
Re: [EMF Compare] array as eattribute value [message #621996 is a reply to message #621995] Thu, 14 January 2010 13:12 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1893
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080104000601080904010101
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi Martin,

I have recently observed a bug on reference comparison that compared
objects through "==" instead of metrics ... yet haven't took the time to
look further into it yet. Could you raise a bugzilla describing this
(forgot to do it myself :p)? And possibly attach a basic sample, but
that I can live without :).

Laurent Goubet
Obeo

Martin Taal wrote:
> Hi,
> I am using EMF compare to compare that conversion from xml to objects
> and back work correctly. My model (see attachment) has a number of
> EAttributes which have an Array as value. I have to sets of eobjects,
> when I persist them to xml/xmi then the two xmi's are exactly the same.
> But EMF Compare reports still many differences. It seems that the array
> values are not compared on their content but on 'the same object'
>
> I use this code to match and diff:
>
> final Map<String, Object> options = new HashMap<String,
> Object>();
> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
> options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
> MatchModel match = MatchService.doResourceMatch(resource1,
> resource2, Collections.<String, Object> emptyMap());
> // Computing differences
> DiffModel diff = DiffService.doDiff(match, false);
> assertTrue(diff.getDifferences().isEmpty());
>
> Attached you can find my ecore file and the 2 xml files (which are the
> same).
>
> (other comparison on other models work fine)
>
> Let me know if I missed something obvious! (or not ofcourse :-)
>


--------------080104000601080904010101
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr">Obeo</a>
email;internet:laurent.goubet@obeo.fr
url:http://www.obeo.fr
version:2.1
end:vcard


--------------080104000601080904010101--
Re: [EMF Compare] array as eattribute value [message #621999 is a reply to message #621996] Thu, 14 January 2010 13:31 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Laurent,
Ofcourse no problem, I will enter an issue.

Btw, I can also debug and check this myself. So if you can give me a specific class/method I can put a breakpoint or
debug then I can check it myself also.

gr. Martin

Laurent Goubet wrote:
> Hi Martin,
>
> I have recently observed a bug on reference comparison that compared
> objects through "==" instead of metrics ... yet haven't took the time to
> look further into it yet. Could you raise a bugzilla describing this
> (forgot to do it myself :p)? And possibly attach a basic sample, but
> that I can live without :).
>
> Laurent Goubet
> Obeo
>
> Martin Taal wrote:
>> Hi,
>> I am using EMF compare to compare that conversion from xml to objects
>> and back work correctly. My model (see attachment) has a number of
>> EAttributes which have an Array as value. I have to sets of eobjects,
>> when I persist them to xml/xmi then the two xmi's are exactly the
>> same. But EMF Compare reports still many differences. It seems that
>> the array values are not compared on their content but on 'the same
>> object'
>>
>> I use this code to match and diff:
>>
>> final Map<String, Object> options = new HashMap<String,
>> Object>();
>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
>> options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
>> MatchModel match = MatchService.doResourceMatch(resource1,
>> resource2, Collections.<String, Object> emptyMap());
>> // Computing differences
>> DiffModel diff = DiffService.doDiff(match, false);
>> assertTrue(diff.getDifferences().isEmpty());
>>
>> Attached you can find my ecore file and the 2 xml files (which are the
>> same).
>>
>> (other comparison on other models work fine)
>>
>> Let me know if I missed something obvious! (or not ofcourse :-)
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [EMF Compare] array as eattribute value [message #622001 is a reply to message #621999] Thu, 14 January 2010 14:34 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1893
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000500040509040202070305
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

Looking at the code to give you pointers ... it seems I had indeed fixed
this back in september (AttributesCheck lines 189 through 202).

....

Reading a little more closely your question, no, I have never tried with
Arrays :'(. Indeed the problem remains (see
AttributesCheck#areDistinctValues(Object, Object)) which does not differ
whether the "Object" is an array or a random value (other than EObject
and EEnumLiterals). I don't know if there is a way, in Java, to check
whether a random "Object" is an array, but the fix for your issue needs
such a check in this method.

Laurent Goubet
Obeo

Martin Taal wrote:
> Hi Laurent,
> Ofcourse no problem, I will enter an issue.
>
> Btw, I can also debug and check this myself. So if you can give me a
> specific class/method I can put a breakpoint or debug then I can check
> it myself also.
>
> gr. Martin
>
> Laurent Goubet wrote:
>> Hi Martin,
>>
>> I have recently observed a bug on reference comparison that compared
>> objects through "==" instead of metrics ... yet haven't took the time
>> to look further into it yet. Could you raise a bugzilla describing
>> this (forgot to do it myself :p)? And possibly attach a basic sample,
>> but that I can live without :).
>>
>> Laurent Goubet
>> Obeo
>>
>> Martin Taal wrote:
>>> Hi,
>>> I am using EMF compare to compare that conversion from xml to objects
>>> and back work correctly. My model (see attachment) has a number of
>>> EAttributes which have an Array as value. I have to sets of eobjects,
>>> when I persist them to xml/xmi then the two xmi's are exactly the
>>> same. But EMF Compare reports still many differences. It seems that
>>> the array values are not compared on their content but on 'the same
>>> object'
>>>
>>> I use this code to match and diff:
>>>
>>> final Map<String, Object> options = new HashMap<String,
>>> Object>();
>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>> Boolean.TRUE);
>>> options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
>>> MatchModel match = MatchService.doResourceMatch(resource1,
>>> resource2, Collections.<String, Object> emptyMap());
>>> // Computing differences
>>> DiffModel diff = DiffService.doDiff(match, false);
>>> assertTrue(diff.getDifferences().isEmpty());
>>>
>>> Attached you can find my ecore file and the 2 xml files (which are
>>> the same).
>>>
>>> (other comparison on other models work fine)
>>>
>>> Let me know if I missed something obvious! (or not ofcourse :-)
>>>
>>
>
>


--------------000500040509040202070305
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr">Obeo</a>
email;internet:laurent.goubet@obeo.fr
url:http://www.obeo.fr
version:2.1
end:vcard


--------------000500040509040202070305--
Re: [EMF Compare] array as eattribute value [message #622002 is a reply to message #622001] Thu, 14 January 2010 14:45 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Laurent,
Yes indeed there is: object.getClass().isArray().

The efeature.isMany == false for these eattributes (they contain a single value). So I think the solution should be
added to areDistinctValues(...). The Array class in java can be used to generically check length and access values in an
array.

As I like a workaround now, I think I need to create my own DiffEngine inheriting from GenericDiffEngine and overriding
the getAttributesChecker method (to return my own AttributesCheck). Correct?

If it works for me then I will attach the overridden AttributesCheck to the bugzilla I will enter in a few minutes. So
you can make use of it.

gr. Martin

Laurent Goubet wrote:
> Martin,
>
> Looking at the code to give you pointers ... it seems I had indeed fixed
> this back in september (AttributesCheck lines 189 through 202).
>
> ...
>
> Reading a little more closely your question, no, I have never tried with
> Arrays :'(. Indeed the problem remains (see
> AttributesCheck#areDistinctValues(Object, Object)) which does not differ
> whether the "Object" is an array or a random value (other than EObject
> and EEnumLiterals). I don't know if there is a way, in Java, to check
> whether a random "Object" is an array, but the fix for your issue needs
> such a check in this method.
>
> Laurent Goubet
> Obeo
>
> Martin Taal wrote:
>> Hi Laurent,
>> Ofcourse no problem, I will enter an issue.
>>
>> Btw, I can also debug and check this myself. So if you can give me a
>> specific class/method I can put a breakpoint or debug then I can check
>> it myself also.
>>
>> gr. Martin
>>
>> Laurent Goubet wrote:
>>> Hi Martin,
>>>
>>> I have recently observed a bug on reference comparison that compared
>>> objects through "==" instead of metrics ... yet haven't took the time
>>> to look further into it yet. Could you raise a bugzilla describing
>>> this (forgot to do it myself :p)? And possibly attach a basic sample,
>>> but that I can live without :).
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Martin Taal wrote:
>>>> Hi,
>>>> I am using EMF compare to compare that conversion from xml to
>>>> objects and back work correctly. My model (see attachment) has a
>>>> number of EAttributes which have an Array as value. I have to sets
>>>> of eobjects, when I persist them to xml/xmi then the two xmi's are
>>>> exactly the same. But EMF Compare reports still many differences. It
>>>> seems that the array values are not compared on their content but on
>>>> 'the same object'
>>>>
>>>> I use this code to match and diff:
>>>>
>>>> final Map<String, Object> options = new HashMap<String,
>>>> Object>();
>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>>> Boolean.TRUE);
>>>> options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
>>>> MatchModel match = MatchService.doResourceMatch(resource1,
>>>> resource2, Collections.<String, Object>
>>>> emptyMap());
>>>> // Computing differences
>>>> DiffModel diff = DiffService.doDiff(match, false);
>>>> assertTrue(diff.getDifferences().isEmpty());
>>>>
>>>> Attached you can find my ecore file and the 2 xml files (which are
>>>> the same).
>>>>
>>>> (other comparison on other models work fine)
>>>>
>>>> Let me know if I missed something obvious! (or not ofcourse :-)
>>>>
>>>
>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [EMF Compare] array as eattribute value [message #622003 is a reply to message #622002] Thu, 14 January 2010 15:09 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1893
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060408070108000705080609
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

Easiest way is to check out EMF Compare sources and patch the
AttributesCheck from there. I didn't know the Class#isArray() method,
but it makes the fix trivial. If you are willing to patch this, the fix
can easily be reviewed and commited for integration within M5.

If you need it before M5 then yes, you need to create your own
DiffEngine to return your implementation of AttributesCheck.

Laurent Goubet
Obeo

Martin Taal wrote:
> Hi Laurent,
> Yes indeed there is: object.getClass().isArray().
>
> The efeature.isMany == false for these eattributes (they contain a
> single value). So I think the solution should be added to
> areDistinctValues(...). The Array class in java can be used to
> generically check length and access values in an array.
>
> As I like a workaround now, I think I need to create my own DiffEngine
> inheriting from GenericDiffEngine and overriding the
> getAttributesChecker method (to return my own AttributesCheck). Correct?
>
> If it works for me then I will attach the overridden AttributesCheck to
> the bugzilla I will enter in a few minutes. So you can make use of it.
>
> gr. Martin
>
> Laurent Goubet wrote:
>> Martin,
>>
>> Looking at the code to give you pointers ... it seems I had indeed
>> fixed this back in september (AttributesCheck lines 189 through 202).
>>
>> ...
>>
>> Reading a little more closely your question, no, I have never tried
>> with Arrays :'(. Indeed the problem remains (see
>> AttributesCheck#areDistinctValues(Object, Object)) which does not
>> differ whether the "Object" is an array or a random value (other than
>> EObject and EEnumLiterals). I don't know if there is a way, in Java,
>> to check whether a random "Object" is an array, but the fix for your
>> issue needs such a check in this method.
>>
>> Laurent Goubet
>> Obeo
>>
>> Martin Taal wrote:
>>> Hi Laurent,
>>> Ofcourse no problem, I will enter an issue.
>>>
>>> Btw, I can also debug and check this myself. So if you can give me a
>>> specific class/method I can put a breakpoint or debug then I can
>>> check it myself also.
>>>
>>> gr. Martin
>>>
>>> Laurent Goubet wrote:
>>>> Hi Martin,
>>>>
>>>> I have recently observed a bug on reference comparison that compared
>>>> objects through "==" instead of metrics ... yet haven't took the
>>>> time to look further into it yet. Could you raise a bugzilla
>>>> describing this (forgot to do it myself :p)? And possibly attach a
>>>> basic sample, but that I can live without :).
>>>>
>>>> Laurent Goubet
>>>> Obeo
>>>>
>>>> Martin Taal wrote:
>>>>> Hi,
>>>>> I am using EMF compare to compare that conversion from xml to
>>>>> objects and back work correctly. My model (see attachment) has a
>>>>> number of EAttributes which have an Array as value. I have to sets
>>>>> of eobjects, when I persist them to xml/xmi then the two xmi's are
>>>>> exactly the same. But EMF Compare reports still many differences.
>>>>> It seems that the array values are not compared on their content
>>>>> but on 'the same object'
>>>>>
>>>>> I use this code to match and diff:
>>>>>
>>>>> final Map<String, Object> options = new HashMap<String,
>>>>> Object>();
>>>>> options.put(MatchOptions.OPTION_IGNORE_XMI_ID,
>>>>> Boolean.TRUE);
>>>>> options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.TRUE);
>>>>> MatchModel match = MatchService.doResourceMatch(resource1,
>>>>> resource2, Collections.<String, Object>
>>>>> emptyMap());
>>>>> // Computing differences
>>>>> DiffModel diff = DiffService.doDiff(match, false);
>>>>> assertTrue(diff.getDifferences().isEmpty());
>>>>>
>>>>> Attached you can find my ecore file and the 2 xml files (which are
>>>>> the same).
>>>>>
>>>>> (other comparison on other models work fine)
>>>>>
>>>>> Let me know if I missed something obvious! (or not ofcourse :-)
>>>>>
>>>>
>>>
>>>
>>
>
>


--------------060408070108000705080609
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr">Obeo</a>
email;internet:laurent.goubet@obeo.fr
url:http://www.obeo.fr
version:2.1
end:vcard


--------------060408070108000705080609--
Previous Topic:[EMF Compare] "Copy current change from right to left" doesn't work?
Next Topic:[EMF Compare] error in standalone version
Goto Forum:
  


Current Time: Mon Aug 02 16:49:16 GMT 2021

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

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

Back to the top