Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Re: EMF Compare
Re: EMF Compare [message #528601] Wed, 21 April 2010 04:47
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010402050203040005070607
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I've answered this on your bugzilla :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=308926 .

As mentionned in my answer, you need both the registration of a factory
with
Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMa p().put(XMI2UMLResource.UML_2_1_1_CONTENT_TYPE_IDENTIFIER,
XMI212UMLResource.Factory.INSTANCE);
_and_ a fix in EMF Compare that will not appear before M7 (it has been
commited on HEAD, you could check out the source code of EMF Compare to
benefit from it).

I've added the UML2 newsgroup to the CC list of this answer, there might
be a way to have an "xmi" resource to be loaded within an
"XMI212UMLResource" implementation without using the content-type (The
needed fix for EMF Compare is to take the "contentTypeToFactoryMap" into
account); but I wouldn't bet on it. Maybe you could use

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xmi",
XMI212UMLResource.Factory.INSTANCE);

To force loading of any "xmi" file as an OMG UML file ... but this
really seems overkill to me.

Laurent Goubet
Obeo

fatih.ok@gmx.de wrote:
> Hello Everybody,
>
> i want to compare two UML-XMI files. Running the following code results
> in the error:
>
>
> Loading resources.
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
> uri 'http://www.omg.org/XMI' not found.
> (file:/C:/Users/sekemitekken/workspace3/xmidiff/Kuchenrezept Altova_unv.xmi,
> 3, 101)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:83)
>
>
>
>
>
> public void startDiff() {
>
>
> Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMa p().put(
> XMI2UMLResource.UML_METAMODEL_2_1_NS_URI,
> XMI212UMLResource.Factory.INSTANCE);
>
> // Creates the resourceSets where we'll load the models
> final ResourceSet resourceSet1 = new ResourceSetImpl();
> final ResourceSet resourceSet2 = new ResourceSetImpl();
>
> try {
> System.out.println("Loading resources.\n"); //$NON-NLS-1$
> // Loads the two models passed as arguments
> final EObject model1 = ModelUtils.load(new
> File(" C:\\Users\\sekemitekken\\workspace3\\xmidiff\\KuchenrezeptAl tova_unv.xmi "),
> resourceSet1);
> final EObject model2 = ModelUtils.load(new
> File(" C:\\Users\\sekemitekken\\workspace3\\xmidiff\\KuchenrezeptGr Gen_orig.xmi "),
> resourceSet2);
>
> // Creates the match then the diff model for those two
> models
> System.out.println("Matching models.\n"); //$NON-NLS-1$
> final MatchModel match = MatchService.doMatch(model1,
> model2, Collections
> .<String, Object> emptyMap());
> System.out.println("Differencing models.\n"); //$NON-NLS-1$
> final DiffModel diff = DiffService.doDiff(match, false);
>
> System.out.println("Merging difference to args[1].\n");
> //$NON-NLS-1$
> final List<DiffElement> differences = new
> ArrayList<DiffElement>(diff.getOwnedElements());
> // This will merge all references to the right model
> (second argument).
> MergeService.merge(differences, true);
>
> // Prints the results
> try {
> System.out.println("MatchModel :\n"); //$NON-NLS-1$
> System.out.println(ModelUtils.serialize(match));
> System.out.println("DiffModel :\n"); //$NON-NLS-1$
> System.out.println(ModelUtils.serialize(diff));
> } catch (final IOException e) {
> e.printStackTrace();
> }
>
> // Serializes the result as "result.emfdiff" in the
> directory this class has been called from.
> System.out.println("saving emfdiff as
> \"result.emfdiff\""); //$NON-NLS-1$
> final ComparisonResourceSnapshot snapshot =
> DiffFactory.eINSTANCE
> .createComparisonResourceSnapshot();
> snapshot.setDate(Calendar.getInstance().getTime());
> snapshot.setMatch(match);
> snapshot.setDiff(diff);
> ModelUtils.save(snapshot, "result.emfdiff"); //$NON-NLS-1$
> } catch (final IOException e) {
> // shouldn't be thrown
> e.printStackTrace();
> } catch (final InterruptedException e) {
> e.printStackTrace();
> }
> }
>
>
> The XMI file that is parsed begins like this and is a valid XML format:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmi:version="2.1">
> <xmi:Documentation contact="www.altova.com" exporter="Altova
> UModel2008sp1" exporterVersion="2.2"/>
> <uml:Package xmi:id="U00000001-7510-11d9-86f2-000476a22f44"
> name="Root" visibility="public">
> <packagedElement xmi:type="uml:Package"
> xmi:id="U00000003-7510-11d9-86f2-000476a22f44" name="Component View"
> visibility="public"/>
>
> .....
>
>


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

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------010402050203040005070607--
Previous Topic:UML Profile
Next Topic:Re: EMF Compare
Goto Forum:
  


Current Time: Thu Aug 28 01:30:16 EDT 2014

Powered by FUDForum. Page generated in 0.01724 seconds