[EMF Compare]Writing a DiffModel as .uml [message #90732] |
Thu, 19 July 2007 07:58  |
Eclipse User |
|
|
|
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 08:03  |
Eclipse User |
|
|
|
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 08:03  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.07070 seconds