Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Compare]Writing a DiffModel as .uml
[EMF Compare]Writing a DiffModel as .uml [message #90732] Thu, 19 July 2007 11:58 Go to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 90
Registered: July 2009
Member
Hello NG,
today I found the Compare-Framework and I think that's the thing what I
am always was looking for ;)
Well, I had some tries. I have two Models represented by .uml-files. So
loaded them:


EObject genObject = ModelUtils.load(generatedModelURI);
EObject refObject = ModelUtils.load(referenceModelURI);


Now I want to look if they are equal(means: if they represent the same
model):


MatchModel match = new MatchService().doMatch(genObject, refObject, new
NullProgressMonitor());
DiffModel diff = new DiffMaker().doDiff(match);

To simply use the UML Model Editor to compare the difference between
both it would be fine if there is a possibility to write the diff into
an .uml-file or make a org.eclipse.uml2.uml.Model out of it. Is it possible?

greets
J.R.
Re: [EMF Compare]Writing a DiffModel as .uml [message #90750 is a reply to message #90732] Thu, 19 July 2007 12:03 Go to previous message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 90
Registered: July 2009
Member
Well, I had a try but it didn't work how I imagined. Here is my code:


public void testModelsAreEqual(){
EObject genObject;
EObject refObject;
try {
genObject = ModelUtils.load(generatedModelURI);
refObject = ModelUtils.load(referenceModelURI);

MatchModel match = new MatchService().doMatch(genObject, refObject,
new NullProgressMonitor());

DiffModel diff = new DiffMaker().doDiff(match);

String diffFile = "filename.uml";
URI diffUri = URI.createFileURI(diffFile);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(diffUri);

EList<EObject> contents = resource.getContents();

contents.add(diff);

Iterator<Element> allContents = diff.getOwnedElements().iterator();

while (allContents.hasNext()) {

EObject eObject = (EObject) allContents.next();
if (eObject instanceof Element) {
contents.addAll(((Element) eObject).getStereotypeApplications());
}
}
resource.save(null);
assertNull("Generated Model and Reference Model are not equal", diff);
} catch (IOException e) {
System.out.println("Loading models to compare failed");
} catch (InterruptedException e) {
System.out.println("Error while trying to match the models");
}
}


Well my filename.uml is written to disk but it doesn't look like I
expected. Means that it is no uml:Model but an diff:DiffModel. Is it
possible to convert it in any way? Hope you can understand me.

greets
J.R.
Re: [EMF Compare]Writing a DiffModel as .uml [message #608810 is a reply to message #90732] Thu, 19 July 2007 12:03 Go to previous message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 90
Registered: July 2009
Member
Well, I had a try but it didn't work how I imagined. Here is my code:


public void testModelsAreEqual(){
EObject genObject;
EObject refObject;
try {
genObject = ModelUtils.load(generatedModelURI);
refObject = ModelUtils.load(referenceModelURI);

MatchModel match = new MatchService().doMatch(genObject, refObject,
new NullProgressMonitor());

DiffModel diff = new DiffMaker().doDiff(match);

String diffFile = "filename.uml";
URI diffUri = URI.createFileURI(diffFile);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(diffUri);

EList<EObject> contents = resource.getContents();

contents.add(diff);

Iterator<Element> allContents = diff.getOwnedElements().iterator();

while (allContents.hasNext()) {

EObject eObject = (EObject) allContents.next();
if (eObject instanceof Element) {
contents.addAll(((Element) eObject).getStereotypeApplications());
}
}
resource.save(null);
assertNull("Generated Model and Reference Model are not equal", diff);
} catch (IOException e) {
System.out.println("Loading models to compare failed");
} catch (InterruptedException e) {
System.out.println("Error while trying to match the models");
}
}


Well my filename.uml is written to disk but it doesn't look like I
expected. Means that it is no uml:Model but an diff:DiffModel. Is it
possible to convert it in any way? Hope you can understand me.

greets
J.R.
Previous Topic:[EMF Compare]Writing a DiffModel as .uml
Next Topic:[TENEO] No annotated model element present
Goto Forum:
  


Current Time: Sat Aug 13 00:18:14 GMT 2022

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

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

Back to the top