Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Re: EMF Compare -- Compare two model instances
Re: EMF Compare -- Compare two model instances [message #127168] Tue, 15 July 2008 13:53 Go to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040802080501030202000305
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Thomas,

Please use the EMFT newsgroup for questions about compare. I've added
it to the "to" list of the reply, so no need to repost.


Thomas Rheker wrote:
> Hi,
>
> for a research project I am trying to automatically compare two
> resources containing instances of the same meta model. These are the
> input and output of a bidirectional transformation and should be the
> same. The problem is to test them for equality in a junit test.
>
> My current approach does not work as expected, it looks as the following
> code snippet:
>
>>>> snip>>>
>>>>
> Resource compareInstance1 = loadEMFInstanceFromFile(emfInput);
> Resource compareInstance2 = loadEMFInstanceFromFile(emfOutput);
>
> MatchModel match = null;
> IMatchEngine matchEngine = new GenericMatchEngine();
> try {
> Map compareOptions = new HashMap();
> match = matchEngine.resourceMatch(compareInstance1,
> compareInstance2, compareOptions);
> } catch (InterruptedException e1) {
> e1.printStackTrace();
> }
> IDiffEngine diffEngine = new GenericDiffEngine();
> DiffModel diff = diffEngine.doDiff(match);
> <<<snap<<<
>
> For two exactly identical files the comparison still returns a DiffModel
> containing an Addition.
>
> If I compare the files by hand in the Eclipse GUI, Compare states that
> there are no differences, as is the case. See the attached files for the
> compared models and the meta model.
>
> What am I doing wrong? Also, is there an easy way to check two models
> for semantic equality, which is all I need for my tests right now?
>
> Greetings,
> Thomas Rheker
>

--------------040802080501030202000305
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">
Thomas,<br>
<br>
Please use the EMFT newsgroup for questions about compare.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Compare -- Compare two model instances [message #127317 is a reply to message #127168] Sat, 19 July 2008 10:24 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050006020802040709080702
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Thomas,

This snippet seems fine as is. Are you sure the two models you're
comparing by code are the same as those you compare from the GUI? If so,
did you check that all the compare options are set to their default
value when comparing from GUI (Window => Preferences => EMF Compare)?
You'll need to set them programmatically if needed (see
org.eclipse.emf.compare.util.MatchOptions).

As a side note, you shouldn't use the GenericMatchEngine and
GenericDiffEngine directly.
org.eclipse.emf.compare.match.service.MatchService and
org.eclipse.emf.compare.diff.service.DiffService both provide the
necessary API.

Cheers,

Laurent Goubet
Obeo

Ed Merks a
Re: EMF Compare -- Compare two model instances [message #127341 is a reply to message #127317] Sun, 20 July 2008 18:17 Go to previous messageGo to next message
Thomas Rheker is currently offline Thomas RhekerFriend
Messages: 8
Registered: July 2009
Junior Member
Laurent,

laurent Goubet schrieb:
> This snippet seems fine as is. Are you sure the two models you're
> comparing by code are the same as those you compare from the GUI?

Yes, they are the same.

> If so,
> did you check that all the compare options are set to their default
> value when comparing from GUI (Window => Preferences => EMF Compare)?
> You'll need to set them programmatically if needed (see
> org.eclipse.emf.compare.util.MatchOptions).

The compare options are all default, as they are in the code.

Also, when comparing differing files of the same meta model (or of
another meta model) in the GUI, all I get is an empty panel. This works
fine if I start another Eclipse instance though. There seems to be
something wrong with my Compare installation.
I will try reinstalling Eclipse and come back to you if necessary.

Greetings,
Thomas Rheker
Re: EMF Compare -- Compare two model instances [message #127551 is a reply to message #127341] Fri, 25 July 2008 17:06 Go to previous messageGo to next message
Thomas Rheker is currently offline Thomas RhekerFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

I still have problems comparing the two resources. I changed my code
according to Laurent's advice:

> Resource compareInstance1 = loadEMFInstanceFromFile(emfInput);
> Resource compareInstance2 = loadEMFInstanceFromFile(emfOutput);
>
> MatchModel match = null;
> try {
> Map compareOptions = new HashMap();
> match = MatchService.doResourceMatch(compareInstance1,
> compareInstance2, compareOptions);
> } catch (InterruptedException e1) { // TODO Auto-generated catch block
> e1.printStackTrace();
> }
> DiffModel diff = DiffService.doDiff(match);

But still diff contains an Addition element, although the input files
are definitely the same. This is all excecuted as a JUnit Plugin Test.

Maybe the problem lies somewhere in the loadEMFInstanceFromFile-method?

> public static Resource loadEMFInstanceFromFile(String pathToFile) {
> Resource resource;
> resource = null;
> File file = new File(pathToFile);
> URI fileURI = URI.createFileURI(file.getAbsolutePath());
> try {
> resource = EMFRESOURCESET.getResource(fileURI, true);
> System.out.println("Loaded emf instance " + fileURI);
> } catch (Exception e) {
> System.out.println("Couldn't load emf instance " + fileURI);
> System.out.print(e);
> System.exit(1234);
> }
> return resource;
> }

EMFRESOURCESET is a static final ResourceSetImpl. Is there a way to
access a ResourceSet of the Eclipse instance running the plugin? There,
the meta model would be known which may be where my problem stems from.

Greetings,
Thomas
Re: EMF Compare -- Compare two model instances [message #127577 is a reply to message #127551] Sat, 26 July 2008 21:04 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080905080900010607050309
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Thomas,

Well we use pretty much the same thing to load our models. You can take
a look at org.eclipse.utils.ModelUtils, it can be used standalone so you
can try delegating the model loading to it.

I fail to see what could cause the differences you get when comparing
from code. Could you provide us with the models you are comparing?
Preferably through a new bugzilla entry against emft/compare.

Cheers

Laurent Goubet
Obeo

Thomas Rheker a
Re: EMF Compare -- Compare two model instances [message #620128 is a reply to message #127168] Sat, 19 July 2008 10:24 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050006020802040709080702
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Thomas,

This snippet seems fine as is. Are you sure the two models you're
comparing by code are the same as those you compare from the GUI? If so,
did you check that all the compare options are set to their default
value when comparing from GUI (Window => Preferences => EMF Compare)?
You'll need to set them programmatically if needed (see
org.eclipse.emf.compare.util.MatchOptions).

As a side note, you shouldn't use the GenericMatchEngine and
GenericDiffEngine directly.
org.eclipse.emf.compare.match.service.MatchService and
org.eclipse.emf.compare.diff.service.DiffService both provide the
necessary API.

Cheers,

Laurent Goubet
Obeo

Ed Merks a
Re: EMF Compare -- Compare two model instances [message #620130 is a reply to message #127317] Sun, 20 July 2008 18:17 Go to previous message
Thomas Rheker is currently offline Thomas RhekerFriend
Messages: 8
Registered: July 2009
Junior Member
Laurent,

laurent Goubet schrieb:
> This snippet seems fine as is. Are you sure the two models you're
> comparing by code are the same as those you compare from the GUI?

Yes, they are the same.

> If so,
> did you check that all the compare options are set to their default
> value when comparing from GUI (Window => Preferences => EMF Compare)?
> You'll need to set them programmatically if needed (see
> org.eclipse.emf.compare.util.MatchOptions).

The compare options are all default, as they are in the code.

Also, when comparing differing files of the same meta model (or of
another meta model) in the GUI, all I get is an empty panel. This works
fine if I start another Eclipse instance though. There seems to be
something wrong with my Compare installation.
I will try reinstalling Eclipse and come back to you if necessary.

Greetings,
Thomas Rheker
Re: EMF Compare -- Compare two model instances [message #620148 is a reply to message #127341] Fri, 25 July 2008 17:06 Go to previous message
Thomas Rheker is currently offline Thomas RhekerFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

I still have problems comparing the two resources. I changed my code
according to Laurent's advice:

> Resource compareInstance1 = loadEMFInstanceFromFile(emfInput);
> Resource compareInstance2 = loadEMFInstanceFromFile(emfOutput);
>
> MatchModel match = null;
> try {
> Map compareOptions = new HashMap();
> match = MatchService.doResourceMatch(compareInstance1,
> compareInstance2, compareOptions);
> } catch (InterruptedException e1) { // TODO Auto-generated catch block
> e1.printStackTrace();
> }
> DiffModel diff = DiffService.doDiff(match);

But still diff contains an Addition element, although the input files
are definitely the same. This is all excecuted as a JUnit Plugin Test.

Maybe the problem lies somewhere in the loadEMFInstanceFromFile-method?

> public static Resource loadEMFInstanceFromFile(String pathToFile) {
> Resource resource;
> resource = null;
> File file = new File(pathToFile);
> URI fileURI = URI.createFileURI(file.getAbsolutePath());
> try {
> resource = EMFRESOURCESET.getResource(fileURI, true);
> System.out.println("Loaded emf instance " + fileURI);
> } catch (Exception e) {
> System.out.println("Couldn't load emf instance " + fileURI);
> System.out.print(e);
> System.exit(1234);
> }
> return resource;
> }

EMFRESOURCESET is a static final ResourceSetImpl. Is there a way to
access a ResourceSet of the Eclipse instance running the plugin? There,
the meta model would be known which may be where my problem stems from.

Greetings,
Thomas
Re: EMF Compare -- Compare two model instances [message #620150 is a reply to message #127551] Sat, 26 July 2008 21:04 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080905080900010607050309
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Thomas,

Well we use pretty much the same thing to load our models. You can take
a look at org.eclipse.utils.ModelUtils, it can be used standalone so you
can try delegating the model loading to it.

I fail to see what could cause the differences you get when comparing
from code. Could you provide us with the models you are comparing?
Preferably through a new bugzilla entry against emft/compare.

Cheers

Laurent Goubet
Obeo

Thomas Rheker a
Previous Topic:[EMF Compare] How to deactivate
Next Topic:Re: org.eclipse.emf.mwe?
Goto Forum:
  


Current Time: Thu Apr 18 07:08:35 GMT 2024

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

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

Back to the top