Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Compare] Comparing models without resources
[EMF Compare] Comparing models without resources [message #136716] Sun, 24 May 2009 03:27 Go to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Cheers,

I wonder if it is at all possible to compare just two in-memory models with EMF Compare?
Regarding the API, it should be, since MatchService.doMatch takes EObjects and not Resources.
However, the match engine uses the resources (which are not set in the example below) to perform the comparison.

My use case is a comparison of partial models, i.e. the compared EObjects are contained in another, larger model.
For example, two sub-packages in a UML model.

Any suggestions and comments are appreciated.
Patrick



// this creates two simple EObjects for comparison, but a NullPointer is raised because the resources are not set
MatchService.doMatch(createDynamicObject("a"), createDynamicObject("b"), Collections.<String, Object> emptyMap());

/** Just to create a simple EObject just having a name. */
private EObject createDynamicObject(String name) {
// create the wrapper containment reference
final EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute();
attr.setName("name");
attr.setEType(EcorePackage.Literals.ESTRING);

// create the wrapper class
final EClass namedClass = EcoreFactory.eINSTANCE.createEClass();
namedClass.setName("DynamicNamedElement");
namedClass.getEStructuralFeatures().add(attr);

// create a package for our wrapper class
final EPackage simplePackage = EcoreFactory.eINSTANCE.createEPackage();
simplePackage.setName("dynamic");
simplePackage.setNsPrefix("dynamic");
simplePackage.setNsURI("http://www.example.org/dynamic");
simplePackage.getEClassifiers().add(namedClass);

// validate what we just created
if (Diagnostician.INSTANCE.validate(simplePackage).getCode() == Diagnostic.OK) {

// instantiate our class, fill the children and return it
final EObject namedClassInstance = simplePackage.getEFactoryInstance().create(namedClass);
namedClassInstance.eSet(attr, name);
return namedClassInstance;
} else {
return null; // TODO: better error handling required here
}
}
Re: [EMF Compare] Comparing models without resources [message #136955 is a reply to message #136716] Thu, 04 June 2009 15:10 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.
--------------000704040904090303020207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Patrick,

I'll simply quote the javadoc :

MatchService.doMatch : "Matches two models and returns the corresponding
matching model."

=> what is meant here is : regardless of the EObjects passed as
arguments, we'll compare their containing resources.

MatchService.doContentMatch : "Matches two objects along with their
content, then return the corresponding match model."

=> this is what you seek to do.

Laurent Goubet
Obeo

Patrick K
Re: [EMF Compare] Comparing models without resources [message #136991 is a reply to message #136955] Tue, 09 June 2009 08:20 Go to previous messageGo to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Thanks Laurent and forgive my blindness ;-)


On 04-06-2009 17:10, laurent Goubet wrote:
> Hi Patrick,
>
> I'll simply quote the javadoc :
>
> MatchService.doMatch : "Matches two models and returns the corresponding
> matching model."
>
> => what is meant here is : regardless of the EObjects passed as
> arguments, we'll compare their containing resources.
>
> MatchService.doContentMatch : "Matches two objects along with their
> content, then return the corresponding match model."
>
> => this is what you seek to do.
>
> Laurent Goubet
> Obeo
>
> Patrick Könemann a écrit :
>> Cheers,
>>
>> I wonder if it is at all possible to compare just two in-memory models
>> with EMF Compare?
>> Regarding the API, it should be, since MatchService.doMatch takes
>> EObjects and not Resources.
>> However, the match engine uses the resources (which are not set in the
>> example below) to perform the comparison.
>>
>> My use case is a comparison of partial models, i.e. the compared
>> EObjects are contained in another, larger model.
>> For example, two sub-packages in a UML model.
>>
>> Any suggestions and comments are appreciated.
>> Patrick
>>
>>
>>
>> // this creates two simple EObjects for comparison, but a NullPointer
>> is raised because the resources are not set
>> MatchService.doMatch(createDynamicObject("a"),
>> createDynamicObject("b"), Collections.<String, Object> emptyMap());
>>
>> /** Just to create a simple EObject just having a name. */
>> private EObject createDynamicObject(String name) {
>> // create the wrapper containment reference
>> final EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute();
>> attr.setName("name");
>> attr.setEType(EcorePackage.Literals.ESTRING);
>>
>> // create the wrapper class
>> final EClass namedClass = EcoreFactory.eINSTANCE.createEClass();
>> namedClass.setName("DynamicNamedElement");
>> namedClass.getEStructuralFeatures().add(attr);
>>
>> // create a package for our wrapper class
>> final EPackage simplePackage = EcoreFactory.eINSTANCE.createEPackage();
>> simplePackage.setName("dynamic");
>> simplePackage.setNsPrefix("dynamic");
>> simplePackage.setNsURI("http://www.example.org/dynamic");
>> simplePackage.getEClassifiers().add(namedClass);
>>
>> // validate what we just created
>> if (Diagnostician.INSTANCE.validate(simplePackage).getCode() ==
>> Diagnostic.OK) {
>> // instantiate our class, fill the children and return it
>> final EObject namedClassInstance =
>> simplePackage.getEFactoryInstance().create(namedClass);
>> namedClassInstance.eSet(attr, name);
>> return namedClassInstance;
>> } else {
>> return null; // TODO: better error handling required here
>> }
>> }
>
Re: [EMF Compare] Comparing models without resources [message #137052 is a reply to message #136991] Tue, 09 June 2009 16:17 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.
--------------060905010900090007010000
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

Or the javadoc needs to be rewrote with a little less copy/pasting so
that people know it does contain interesting things to read :D.

Laurent Goubet
Obeo

Patrick K
Re: [EMF Compare] Comparing models without resources [message #620995 is a reply to message #136716] Thu, 04 June 2009 15:10 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.
--------------000704040904090303020207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Patrick,

I'll simply quote the javadoc :

MatchService.doMatch : "Matches two models and returns the corresponding
matching model."

=> what is meant here is : regardless of the EObjects passed as
arguments, we'll compare their containing resources.

MatchService.doContentMatch : "Matches two objects along with their
content, then return the corresponding match model."

=> this is what you seek to do.

Laurent Goubet
Obeo

Patrick K
Re: [EMF Compare] Comparing models without resources [message #620998 is a reply to message #136955] Tue, 09 June 2009 08:20 Go to previous message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
Thanks Laurent and forgive my blindness ;-)


On 04-06-2009 17:10, laurent Goubet wrote:
> Hi Patrick,
>
> I'll simply quote the javadoc :
>
> MatchService.doMatch : "Matches two models and returns the corresponding
> matching model."
>
> => what is meant here is : regardless of the EObjects passed as
> arguments, we'll compare their containing resources.
>
> MatchService.doContentMatch : "Matches two objects along with their
> content, then return the corresponding match model."
>
> => this is what you seek to do.
>
> Laurent Goubet
> Obeo
>
> Patrick Könemann a écrit :
>> Cheers,
>>
>> I wonder if it is at all possible to compare just two in-memory models
>> with EMF Compare?
>> Regarding the API, it should be, since MatchService.doMatch takes
>> EObjects and not Resources.
>> However, the match engine uses the resources (which are not set in the
>> example below) to perform the comparison.
>>
>> My use case is a comparison of partial models, i.e. the compared
>> EObjects are contained in another, larger model.
>> For example, two sub-packages in a UML model.
>>
>> Any suggestions and comments are appreciated.
>> Patrick
>>
>>
>>
>> // this creates two simple EObjects for comparison, but a NullPointer
>> is raised because the resources are not set
>> MatchService.doMatch(createDynamicObject("a"),
>> createDynamicObject("b"), Collections.<String, Object> emptyMap());
>>
>> /** Just to create a simple EObject just having a name. */
>> private EObject createDynamicObject(String name) {
>> // create the wrapper containment reference
>> final EAttribute attr = EcoreFactory.eINSTANCE.createEAttribute();
>> attr.setName("name");
>> attr.setEType(EcorePackage.Literals.ESTRING);
>>
>> // create the wrapper class
>> final EClass namedClass = EcoreFactory.eINSTANCE.createEClass();
>> namedClass.setName("DynamicNamedElement");
>> namedClass.getEStructuralFeatures().add(attr);
>>
>> // create a package for our wrapper class
>> final EPackage simplePackage = EcoreFactory.eINSTANCE.createEPackage();
>> simplePackage.setName("dynamic");
>> simplePackage.setNsPrefix("dynamic");
>> simplePackage.setNsURI("http://www.example.org/dynamic");
>> simplePackage.getEClassifiers().add(namedClass);
>>
>> // validate what we just created
>> if (Diagnostician.INSTANCE.validate(simplePackage).getCode() ==
>> Diagnostic.OK) {
>> // instantiate our class, fill the children and return it
>> final EObject namedClassInstance =
>> simplePackage.getEFactoryInstance().create(namedClass);
>> namedClassInstance.eSet(attr, name);
>> return namedClassInstance;
>> } else {
>> return null; // TODO: better error handling required here
>> }
>> }
>
Re: [EMF Compare] Comparing models without resources [message #621003 is a reply to message #136991] Tue, 09 June 2009 16:17 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.
--------------060905010900090007010000
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

Or the javadoc needs to be rewrote with a little less copy/pasting so
that people know it does contain interesting things to read :D.

Laurent Goubet
Obeo

Patrick K
Previous Topic:[Announce] EMFT MWE 0.7.0RC4 is available
Next Topic:Teneo 1.0.1 does not support Lazy-Loading of Many-to-One and One-to-One
Goto Forum:
  


Current Time: Sat Jul 27 10:05:32 GMT 2024

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

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

Back to the top