Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » href="http://schema.omg.org/spec/UML/2.1/uml.xml#Integer"/> to EInt
href="http://schema.omg.org/spec/UML/2.1/uml.xml#Integer"/> to EInt [message #886426] Thu, 14 June 2012 22:40 Go to next message
max power is currently offline max powerFriend
Messages: 9
Registered: May 2012
Junior Member
Hi all!

I have an xmi file with an uml class diagram.

Some attributes have following types:
<type xmi:type="uml:PrimitiveType" href="http:||schema.omg.org/spec/UML/2.1/uml.xml#Integer"/>


After the import these attributes have the type PrimitiveTypeImpl.

ToString of the variable "type" returns:
org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@6d23f66c (eProxyURI: http:||schema.omg.org/spec/UML/2.1/uml.xml#Integer)


When I programmatically convert the uml model to ecore, the attributes have the type: EDataTypeImpl.

BUT: when I import the xmi file into an EMF Project via UI the resulting model contains attributes with type EInt. This is what I want to do programmatically, too.

I am using following code for import and conversion to ecore:

ResourceSet resourceSet = new ResourceSetImpl();
Registry packageRegistry = resourceSet.getPackageRegistry();

packageRegistry.put("http:||schema.omg.org/spec/XMI/2.1", UMLPackage.eINSTANCE);
packageRegistry.put("http:||schema.omg.org/spec/UML/2.1", UMLPackage.eINSTANCE);

Map<String, Object> extensionToFactoryMap = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, new UMLResourceFactoryImpl());
resourceSet.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);

URI uri = URI.createURI("model.xmi");

Package root = UML2Util.load(resourceSet, uri, UMLPackage.Literals.PACKAGE);

Set<EPackage> result = Sets.newHashSet();
result.addAll(UMLUtil.convertToEcore(root, null));



Am I doing something wrong?

Re: href=&quot;http://schema.omg.org/spec/UML/2.1/uml.xml#Integer&quot;/&gt; to EInt [message #886647 is a reply to message #886426] Fri, 15 June 2012 11:03 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi
> Am I doing something wrong?
Yes. Your ability to workaround the misleading MDT/UML2 documentation is
indequate.

Loading a UML resource is a non-trivial activity, since there is support
for more than one UML namespace (version) and you must register the
appropriate content types to ensure that the appropriate resources and
converters are used. You also need to define path-map URI mappings for
profiles.

I have just added a "load" step to the canned solution to
http://wiki.eclipse.org/MDT/UML2/Getting_Started_with_UML2. You may find
it as https://bugs.eclipse.org/bugs/attachment.cgi?id=217415 to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=382342.

Apologies for difficulties.

Regards

Ed Willink
Previous Topic:how to load int generals from Integer
Next Topic:UML2 Tools and Indigo
Goto Forum:
  


Current Time: Thu Nov 27 11:06:04 GMT 2014

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

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