Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Load Model from Enterprise Architect
Load Model from Enterprise Architect [message #472923] Mon, 21 May 2007 14:10 Go to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------020905000901050201070504
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi there,

I'm trying to load a XMI generate by Enterprise Architect in a
standalone application. With the help of the migration guide and the
"Getting Started"-article I tried to figure out, how my code must look
like. But I wasn't too successful. If I don't change the exported XMI
(as attached) I can't get the model (EcoreUtil.getObjectByType() returns
null), if I change the uml namespace to

xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"

I'm getting a "The class 'Type' is not a valid classifier" error.

Can anyone help please?

Since the xmi(uml) and my code isn't very big, I attached them. Hope
this is okay.

Thanks in advance,

Dominik Raymann

--------------020905000901050201070504
Content-Type: text/xml;
name="ea_export.uml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ea_export.uml"

<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
<ownedMember xmi:type="uml:Package" xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model" visibility="public">
<ownedMember xmi:type="uml:Package" xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage" visibility="public">
<ownedMember xmi:type="uml:Class" xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA" visibility="public">
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1" visibility="private" isDerived="false">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
<upperValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
</ownedAttribute>
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public" association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false" isDerived="false" isDerivedUnion="false" aggregation="none">
<type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
</ownedAttribute>
</ownedMember>
<ownedMember xmi:type="uml:Association" xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
<memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
<memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
<ownedEnd xmi:type="uml:Property" xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public" association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false" isDerived="false" isDerivedUnion="false" aggregation="none">
<type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
<upperValue xmi:type="uml:LiteralInteger" xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
</ownedEnd>
</ownedMember>
<ownedMember xmi:type="uml:Class" xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB" visibility="public">
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1" visibility="private" isDerived="false">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
<upperValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
</ownedAttribute>
</ownedMember>
<ownedMember xmi:type="uml:Class" xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC" visibility="public">
<ownedAttribute xmi:type="uml:Property" xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1" visibility="private" isDerived="false">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
<upperValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
</ownedAttribute>
<generalization xmi:type="uml:Generalization" xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F" general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
</ownedMember>
</ownedMember>
</ownedMember>
</uml:Model>
</xmi:XMI>

--------------020905000901050201070504
Content-Type: text/plain;
name="LoadUML.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="LoadUML.java"

/*
* Created on 21.05.2007
*
* (c) by Boxalino
*/
package zzz.test;

import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.resource.UML22UMLResource;
import org.eclipse.uml2.uml.resource.UMLResource;
import com.boxalino.log.ILogger;
import com.boxalino.log.Logger;

public class LoadUML {
static ILogger LOGGER = Logger.getLogger(LoadUML.class);

private Model _model = null;

public void load(String path) {

URI furi = URI.createFileURI(path);
registerPathmaps(URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml.resource s_2.0.3.v200702141227.jar!/ "));
registerPackages(RESOURCE_SET);
registerResourceFactories();

// For a stand alone application, it is necessary to map the platform
// plugin URI scheme to the workspace location.
URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/ "), URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 00702141227.jar!/ "));

Resource resource = null;
try {
resource = RESOURCE_SET.getResource(furi, true);
}
catch (Exception e) {
System.out.println(e.getMessage());
return;
}
_model = (Model) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.MODEL);

if (_model != null) {
System.out.println("ok");
}
else {
System.out.println("failed");
}
}


public static void main(String[] args) {
LoadUML uml2bom = new LoadUML();
uml2bom.load("c:\\temp\\ea_exportpart.uml2");
}

protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();

protected static void registerResourceFactories() {
Map extensionFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
extensionFactoryMap.put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION, Ecore2XMLResource.Factory.INSTANCE);
extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION, UML22UMLResource.Factory.INSTANCE);
}

protected static void registerPathmaps(URI umlResourcePluginURI) {
System.out.println(UMLResource.LIBRARIES_PATHMAP);
URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP), umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP), umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP), umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
}

protected static void registerPackages(ResourceSet resourceSet) {
Map packageRegistry = resourceSet.getPackageRegistry();
packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
}


}

--------------020905000901050201070504--
Re: Load Model from Enterprise Architect [message #472929 is a reply to message #472923] Tue, 22 May 2007 16:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: swt.stanford.edu

Hi,

I am getting the same error when I import EA's XMI files. When I raised
the issue with EA support, I received the following response. Does it
make sense to the Eclipse UML gurus?


>
> Thanks for the note and the sample file.
>
> EA is a UML tool which describes its UML models based on MOF ( Meta
> Object Facility ). Whereas, Eclipse describes its UML models based on
> EMF ( Eclipse Modelling Framework ).
> When serializing in XMI, the XMI for an UML model based on MOF will vary
> from a model based on EMF. Hence the error when you tried to import the
> XMI of a MOF based UML model into an EMF based tool.
> Unfortunately, there is no workaround this issue currently.
>
> I am sorry that I cannot offer further assistance regarding this issue
> at this stage . If you have any further queries, feel free to write-in.
>
> Best Regards,
>
> Vimal Kumar
> Sparx Systems Pty Ltd
> support@sparxsystems.com.au
> http://www.sparxsystems.com.au



Dominik Raymann wrote:
> Hi there,
>
> I'm trying to load a XMI generate by Enterprise Architect in a
> standalone application. With the help of the migration guide and the
> "Getting Started"-article I tried to figure out, how my code must look
> like. But I wasn't too successful. If I don't change the exported XMI
> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
> null), if I change the uml namespace to
>
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>
> I'm getting a "The class 'Type' is not a valid classifier" error.
>
> Can anyone help please?
>
> Since the xmi(uml) and my code isn't very big, I attached them. Hope
> this is okay.
>
> Thanks in advance,
>
> Dominik Raymann
Re: Load Model from Enterprise Architect [message #472931 is a reply to message #472923] Tue, 22 May 2007 21:56 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Dominik,

Can you give this a quick try ...

Simply try changing the nsURI to the older version ie. 1.0.0 ( not
2.0.0 ).
That should trigger a migration and should work then.

Let me know if that works.

Regards,

- James.


"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f2s99h$np6$1@build.eclipse.org...
> Hi there,
>
> I'm trying to load a XMI generate by Enterprise Architect in a
> standalone application. With the help of the migration guide and the
> "Getting Started"-article I tried to figure out, how my code must look
> like. But I wasn't too successful. If I don't change the exported XMI
> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
> null), if I change the uml namespace to
>
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>
> I'm getting a "The class 'Type' is not a valid classifier" error.
>
> Can anyone help please?
>
> Since the xmi(uml) and my code isn't very big, I attached them. Hope
> this is okay.
>
> Thanks in advance,
>
> Dominik Raymann
>


------------------------------------------------------------ ----------------
----


> <?xml version="1.0" encoding="windows-1252"?>
> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
> <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
> <ownedMember xmi:type="uml:Package"
xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
visibility="public">
> <ownedMember xmi:type="uml:Package"
xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
visibility="public">
> <ownedMember xmi:type="uml:Class"
xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
visibility="public">
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> </ownedAttribute>
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Association"
xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <ownedEnd xmi:type="uml:Property"
xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> </ownedEnd>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
visibility="public">
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
visibility="public">
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
> </ownedAttribute>
> <generalization xmi:type="uml:Generalization"
xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> </ownedMember>
> </ownedMember>
> </ownedMember>
> </uml:Model>
> </xmi:XMI>
>


------------------------------------------------------------ ----------------
----


> /*
> * Created on 21.05.2007
> *
> * (c) by Boxalino
> */
> package zzz.test;
>
> import java.util.Map;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.URIConverter;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.util.EcoreUtil;
> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
> import org.eclipse.uml2.uml.Model;
> import org.eclipse.uml2.uml.UMLPackage;
> import org.eclipse.uml2.uml.resource.UML22UMLResource;
> import org.eclipse.uml2.uml.resource.UMLResource;
> import com.boxalino.log.ILogger;
> import com.boxalino.log.Logger;
>
> public class LoadUML {
> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>
> private Model _model = null;
>
> public void load(String path) {
>
> URI furi = URI.createFileURI(path);
>
registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
ml2.uml.resources_2.0.3.v200702141227.jar!/"));
> registerPackages(RESOURCE_SET);
> registerResourceFactories();
>
> // For a stand alone application, it is necessary to map the platform
> // plugin URI scheme to the workspace location.
>
URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
l/"),
URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
0702141227.jar!/"));
>
> Resource resource = null;
> try {
> resource = RESOURCE_SET.getResource(furi, true);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> return;
> }
> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.MODEL);
>
> if (_model != null) {
> System.out.println("ok");
> }
> else {
> System.out.println("failed");
> }
> }
>
>
> public static void main(String[] args) {
> LoadUML uml2bom = new LoadUML();
> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
> }
>
> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>
> protected static void registerResourceFactories() {
> Map extensionFactoryMap =
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
Ecore2XMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
UML22UMLResource.Factory.INSTANCE);
> }
>
> protected static void registerPathmaps(URI umlResourcePluginURI) {
> System.out.println(UMLResource.LIBRARIES_PATHMAP);
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
> }
>
> protected static void registerPackages(ResourceSet resourceSet) {
> Map packageRegistry = resourceSet.getPackageRegistry();
> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
> packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
> }
>
>
> }
>
Re: Load Model from Enterprise Architect [message #472974 is a reply to message #472931] Wed, 23 May 2007 07:12 Go to previous messageGo to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi James,

thanks for your help. Unfortunately it didn't help (I tried both
"http://www.eclipse.org/uml2/1.0.0/UML" and
"http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.

Greets,

Dominik

James Bruck schrieb:
> Hi Dominik,
>
> Can you give this a quick try ...
>
> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
> 2.0.0 ).
> That should trigger a migration and should work then.
>
> Let me know if that works.
>
> Regards,
>
> - James.
>
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f2s99h$np6$1@build.eclipse.org...
>> Hi there,
>>
>> I'm trying to load a XMI generate by Enterprise Architect in a
>> standalone application. With the help of the migration guide and the
>> "Getting Started"-article I tried to figure out, how my code must look
>> like. But I wasn't too successful. If I don't change the exported XMI
>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>> null), if I change the uml namespace to
>>
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>
>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>
>> Can anyone help please?
>>
>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>> this is okay.
>>
>> Thanks in advance,
>>
>> Dominik Raymann
>>
>
>
> ------------------------------------------------------------ ----------------
> ----
>
>
>> <?xml version="1.0" encoding="windows-1252"?>
>> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>> <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
> visibility="public">
>> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
> visibility="public">
>> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> </ownedAttribute>
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Association"
> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <ownedEnd xmi:type="uml:Property"
> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> </ownedEnd>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> </ownedAttribute>
>> <generalization xmi:type="uml:Generalization"
> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> </ownedMember>
>> </ownedMember>
>> </ownedMember>
>> </uml:Model>
>> </xmi:XMI>
>>
>
>
> ------------------------------------------------------------ ----------------
> ----
>
>
>> /*
>> * Created on 21.05.2007
>> *
>> * (c) by Boxalino
>> */
>> package zzz.test;
>>
>> import java.util.Map;
>> import org.eclipse.emf.common.util.URI;
>> import org.eclipse.emf.ecore.EcorePackage;
>> import org.eclipse.emf.ecore.resource.Resource;
>> import org.eclipse.emf.ecore.resource.ResourceSet;
>> import org.eclipse.emf.ecore.resource.URIConverter;
>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>> import org.eclipse.emf.ecore.util.EcoreUtil;
>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>> import org.eclipse.uml2.uml.Model;
>> import org.eclipse.uml2.uml.UMLPackage;
>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>> import org.eclipse.uml2.uml.resource.UMLResource;
>> import com.boxalino.log.ILogger;
>> import com.boxalino.log.Logger;
>>
>> public class LoadUML {
>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>
>> private Model _model = null;
>>
>> public void load(String path) {
>>
>> URI furi = URI.createFileURI(path);
>>
> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>> registerPackages(RESOURCE_SET);
>> registerResourceFactories();
>>
>> // For a stand alone application, it is necessary to map the platform
>> // plugin URI scheme to the workspace location.
>>
> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
> l/"),
> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
> 0702141227.jar!/"));
>> Resource resource = null;
>> try {
>> resource = RESOURCE_SET.getResource(furi, true);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> return;
>> }
>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.MODEL);
>> if (_model != null) {
>> System.out.println("ok");
>> }
>> else {
>> System.out.println("failed");
>> }
>> }
>>
>>
>> public static void main(String[] args) {
>> LoadUML uml2bom = new LoadUML();
>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>> }
>>
>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>
>> protected static void registerResourceFactories() {
>> Map extensionFactoryMap =
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
> Ecore2XMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
> UML22UMLResource.Factory.INSTANCE);
>> }
>>
>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>> }
>>
>> protected static void registerPackages(ResourceSet resourceSet) {
>> Map packageRegistry = resourceSet.getPackageRegistry();
>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>> packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>> }
>>
>>
>> }
>>
>
>
Re: Load Model from Enterprise Architect [message #473000 is a reply to message #472923] Fri, 25 May 2007 19:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: carrasco.ModelDrivenDevelopment.co.uk

Yeah, it?s a shame the undelying Eclipse metametamodel is not the truly
standard MOF...
it is so close!


"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f2s99h$np6$1@build.eclipse.org...
> Hi there,
>
> I'm trying to load a XMI generate by Enterprise Architect in a
> standalone application. With the help of the migration guide and the
> "Getting Started"-article I tried to figure out, how my code must look
> like. But I wasn't too successful. If I don't change the exported XMI
> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
> null), if I change the uml namespace to
>
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>
> I'm getting a "The class 'Type' is not a valid classifier" error.
>
> Can anyone help please?
>
> Since the xmi(uml) and my code isn't very big, I attached them. Hope
> this is okay.
>
> Thanks in advance,
>
> Dominik Raymann
>


------------------------------------------------------------ --------------------


> <?xml version="1.0" encoding="windows-1252"?>
> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
> <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
> visibility="public">
> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
> visibility="public">
> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
> visibility="public">
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
> visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> </ownedAttribute>
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Association"
> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <ownedEnd xmi:type="uml:Property"
> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> </ownedEnd>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
> visibility="public">
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
> visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
> visibility="public">
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
> visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
> </ownedAttribute>
> <generalization xmi:type="uml:Generalization"
> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> </ownedMember>
> </ownedMember>
> </ownedMember>
> </uml:Model>
> </xmi:XMI>
>


------------------------------------------------------------ --------------------


> /*
> * Created on 21.05.2007
> *
> * (c) by Boxalino
> */
> package zzz.test;
>
> import java.util.Map;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.URIConverter;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.util.EcoreUtil;
> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
> import org.eclipse.uml2.uml.Model;
> import org.eclipse.uml2.uml.UMLPackage;
> import org.eclipse.uml2.uml.resource.UML22UMLResource;
> import org.eclipse.uml2.uml.resource.UMLResource;
> import com.boxalino.log.ILogger;
> import com.boxalino.log.Logger;
>
> public class LoadUML {
> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>
> private Model _model = null;
>
> public void load(String path) {
>
> URI furi = URI.createFileURI(path);
> registerPathmaps(URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml.resource s_2.0.3.v200702141227.jar!/ "));
> registerPackages(RESOURCE_SET);
> registerResourceFactories();
>
> // For a stand alone application, it is necessary to map the platform
> // plugin URI scheme to the workspace location.
> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/ "),
> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 00702141227.jar!/ "));
>
> Resource resource = null;
> try {
> resource = RESOURCE_SET.getResource(furi, true);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> return;
> }
> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.MODEL);
>
> if (_model != null) {
> System.out.println("ok");
> }
> else {
> System.out.println("failed");
> }
> }
>
>
> public static void main(String[] args) {
> LoadUML uml2bom = new LoadUML();
> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
> }
>
> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>
> protected static void registerResourceFactories() {
> Map extensionFactoryMap =
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
> Ecore2XMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
> UML22UMLResource.Factory.INSTANCE);
> }
>
> protected static void registerPathmaps(URI umlResourcePluginURI) {
> System.out.println(UMLResource.LIBRARIES_PATHMAP);
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
> }
>
> protected static void registerPackages(ResourceSet resourceSet) {
> Map packageRegistry = resourceSet.getPackageRegistry();
> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
> packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
> }
>
>
> }
>
Re: Load Model from Enterprise Architect [message #473001 is a reply to message #473000] Fri, 25 May 2007 19:35 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Antonio,

While the in-memory representation may not be purely MOF-based (being based
on Ecore instead of EMOF), UML2 does support interchange via the official
OMG format for UML 2.1.1 models (in addition to its own "proprietary" format
which includes "Eclipse-isms")...

Kenn

"Antonio Carrasco" <carrasco@ModelDrivenDevelopment.co.uk> wrote in message
news:f37cit$ohj$1@build.eclipse.org...
> Yeah, it?s a shame the undelying Eclipse metametamodel is not the truly
> standard MOF...
> it is so close!
>
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f2s99h$np6$1@build.eclipse.org...
>> Hi there,
>>
>> I'm trying to load a XMI generate by Enterprise Architect in a
>> standalone application. With the help of the migration guide and the
>> "Getting Started"-article I tried to figure out, how my code must look
>> like. But I wasn't too successful. If I don't change the exported XMI
>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>> null), if I change the uml namespace to
>>
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>
>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>
>> Can anyone help please?
>>
>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>> this is okay.
>>
>> Thanks in advance,
>>
>> Dominik Raymann
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> <?xml version="1.0" encoding="windows-1252"?>
>> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>> <xmi:Documentation exporter="Enterprise Architect"
>> exporterVersion="6.5"/>
>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>> visibility="public">
>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>> visibility="public">
>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> </ownedAttribute>
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Association"
>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <ownedEnd xmi:type="uml:Property"
>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> </ownedEnd>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> </ownedAttribute>
>> <generalization xmi:type="uml:Generalization"
>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> </ownedMember>
>> </ownedMember>
>> </ownedMember>
>> </uml:Model>
>> </xmi:XMI>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> /*
>> * Created on 21.05.2007
>> *
>> * (c) by Boxalino
>> */
>> package zzz.test;
>>
>> import java.util.Map;
>> import org.eclipse.emf.common.util.URI;
>> import org.eclipse.emf.ecore.EcorePackage;
>> import org.eclipse.emf.ecore.resource.Resource;
>> import org.eclipse.emf.ecore.resource.ResourceSet;
>> import org.eclipse.emf.ecore.resource.URIConverter;
>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>> import org.eclipse.emf.ecore.util.EcoreUtil;
>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>> import org.eclipse.uml2.uml.Model;
>> import org.eclipse.uml2.uml.UMLPackage;
>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>> import org.eclipse.uml2.uml.resource.UMLResource;
>> import com.boxalino.log.ILogger;
>> import com.boxalino.log.Logger;
>>
>> public class LoadUML {
>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>
>> private Model _model = null;
>>
>> public void load(String path) {
>>
>> URI furi = URI.createFileURI(path);
>> registerPathmaps(URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml.resource s_2.0.3.v200702141227.jar!/ "));
>> registerPackages(RESOURCE_SET);
>> registerResourceFactories();
>>
>> // For a stand alone application, it is necessary to map the platform
>> // plugin URI scheme to the workspace location.
>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/ "),
>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 00702141227.jar!/ "));
>>
>> Resource resource = null;
>> try {
>> resource = RESOURCE_SET.getResource(furi, true);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> return;
>> }
>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>> UMLPackage.Literals.MODEL);
>>
>> if (_model != null) {
>> System.out.println("ok");
>> }
>> else {
>> System.out.println("failed");
>> }
>> }
>>
>>
>> public static void main(String[] args) {
>> LoadUML uml2bom = new LoadUML();
>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>> }
>>
>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>
>> protected static void registerResourceFactories() {
>> Map extensionFactoryMap =
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>> Ecore2XMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>> UML22UMLResource.Factory.INSTANCE);
>> }
>>
>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>> }
>>
>> protected static void registerPackages(ResourceSet resourceSet) {
>> Map packageRegistry = resourceSet.getPackageRegistry();
>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>> Ecore2XMLPackage.eINSTANCE);
>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>> }
>>
>>
>> }
>>
>
>
Re: Load Model from Enterprise Architect [message #473002 is a reply to message #472929] Fri, 25 May 2007 19:41 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Samson,

There is only one official standard format for UML models, so regardless of
whether a given implementation is based on MOF or EMF, the interchange
format should be the same... unfortunately, problems tend to arise when
different tool vendors interpret the MOF and/or UML specifications
differently. :(

UML2 supports interchange using both its "native" format (based on EMF) and
"official" OMG format, so it should be able to handle models from a tool
that also supports the "official" OMG format. I will try to take a look at
the file and see where the discrepancy lies.

Kenn

"Samson Tu" <swt@stanford.edu> wrote in message
news:f2v52d$6g6$1@build.eclipse.org...
> Hi,
>
> I am getting the same error when I import EA's XMI files. When I raised
> the issue with EA support, I received the following response. Does it make
> sense to the Eclipse UML gurus?
>
>
>>
>> Thanks for the note and the sample file.
>>
>> EA is a UML tool which describes its UML models based on MOF ( Meta
>> Object Facility ). Whereas, Eclipse describes its UML models based on
>> EMF ( Eclipse Modelling Framework ).
>> When serializing in XMI, the XMI for an UML model based on MOF will vary
>> from a model based on EMF. Hence the error when you tried to import the
>> XMI of a MOF based UML model into an EMF based tool.
>> Unfortunately, there is no workaround this issue currently.
>>
>> I am sorry that I cannot offer further assistance regarding this issue
>> at this stage . If you have any further queries, feel free to write-in.
>>
>> Best Regards,
>>
>> Vimal Kumar
>> Sparx Systems Pty Ltd
>> support@sparxsystems.com.au
>> http://www.sparxsystems.com.au
>
>
>
> Dominik Raymann wrote:
>> Hi there,
>>
>> I'm trying to load a XMI generate by Enterprise Architect in a standalone
>> application. With the help of the migration guide and the "Getting
>> Started"-article I tried to figure out, how my code must look like. But I
>> wasn't too successful. If I don't change the exported XMI (as attached) I
>> can't get the model (EcoreUtil.getObjectByType() returns null), if I
>> change the uml namespace to
>>
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>
>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>
>> Can anyone help please?
>>
>> Since the xmi(uml) and my code isn't very big, I attached them. Hope this
>> is okay.
>>
>> Thanks in advance,
>>
>> Dominik Raymann
Re: Load Model from Enterprise Architect [message #473003 is a reply to message #472974] Fri, 25 May 2007 20:00 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

I was able to successfuly load this model into the UML editor by changing
the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
resource had an extension of ".uml2". This suggests to me that it should be
possible to load it programmatically by adding a URI converter mapping from
http://schema.omg.org/spec/UML/2.0 to http://www.eclipse.org/uml2/1.0.0/UML
and ensuring the UML22UML resource factory is registered against whatever
file extension you give the resource. Please try this and let us know if it
works for you.

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f30ph5$mhb$1@build.eclipse.org...
> Hi James,
>
> thanks for your help. Unfortunately it didn't help (I tried both
> "http://www.eclipse.org/uml2/1.0.0/UML" and
> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>
> Greets,
>
> Dominik
>
> James Bruck schrieb:
>> Hi Dominik,
>>
>> Can you give this a quick try ...
>>
>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>> 2.0.0 ).
>> That should trigger a migration and should work then.
>>
>> Let me know if that works.
>>
>> Regards,
>>
>> - James.
>>
>>
>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>> news:f2s99h$np6$1@build.eclipse.org...
>>> Hi there,
>>>
>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>> standalone application. With the help of the migration guide and the
>>> "Getting Started"-article I tried to figure out, how my code must look
>>> like. But I wasn't too successful. If I don't change the exported XMI
>>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>>> null), if I change the uml namespace to
>>>
>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>
>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>
>>> Can anyone help please?
>>>
>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>> this is okay.
>>>
>>> Thanks in advance,
>>>
>>> Dominik Raymann
>>>
>>
>>
>> ------------------------------------------------------------ ----------------
>> ----
>>
>>
>>> <?xml version="1.0" encoding="windows-1252"?>
>>> <xmi:XMI xmi:version="2.1"
>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>> <xmi:Documentation exporter="Enterprise Architect"
>>> exporterVersion="6.5"/>
>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>> visibility="public">
>>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>> visibility="public">
>>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>> visibility="public">
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>> visibility="private" isDerived="false">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>> </ownedAttribute>
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>> </ownedAttribute>
>>> </ownedMember>
>>> <ownedMember xmi:type="uml:Association"
>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>> <ownedEnd xmi:type="uml:Property"
>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>> </ownedEnd>
>>> </ownedMember>
>>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>> visibility="public">
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>> visibility="private" isDerived="false">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>> </ownedAttribute>
>>> </ownedMember>
>>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>> visibility="public">
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>> visibility="private" isDerived="false">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>> </ownedAttribute>
>>> <generalization xmi:type="uml:Generalization"
>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>> </ownedMember>
>>> </ownedMember>
>>> </ownedMember>
>>> </uml:Model>
>>> </xmi:XMI>
>>>
>>
>>
>> ------------------------------------------------------------ ----------------
>> ----
>>
>>
>>> /*
>>> * Created on 21.05.2007
>>> *
>>> * (c) by Boxalino
>>> */
>>> package zzz.test;
>>>
>>> import java.util.Map;
>>> import org.eclipse.emf.common.util.URI;
>>> import org.eclipse.emf.ecore.EcorePackage;
>>> import org.eclipse.emf.ecore.resource.Resource;
>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>> import org.eclipse.uml2.uml.Model;
>>> import org.eclipse.uml2.uml.UMLPackage;
>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>> import com.boxalino.log.ILogger;
>>> import com.boxalino.log.Logger;
>>>
>>> public class LoadUML {
>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>
>>> private Model _model = null;
>>>
>>> public void load(String path) {
>>>
>>> URI furi = URI.createFileURI(path);
>>>
>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>> registerPackages(RESOURCE_SET);
>>> registerResourceFactories();
>>>
>>> // For a stand alone application, it is necessary to map the platform
>>> // plugin URI scheme to the workspace location.
>>>
>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>> l/"),
>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>> 0702141227.jar!/"));
>>> Resource resource = null;
>>> try {
>>> resource = RESOURCE_SET.getResource(furi, true);
>>> }
>>> catch (Exception e) {
>>> System.out.println(e.getMessage());
>>> return;
>>> }
>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>> UMLPackage.Literals.MODEL);
>>> if (_model != null) {
>>> System.out.println("ok");
>>> }
>>> else {
>>> System.out.println("failed");
>>> }
>>> }
>>>
>>>
>>> public static void main(String[] args) {
>>> LoadUML uml2bom = new LoadUML();
>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>> }
>>>
>>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>>
>>> protected static void registerResourceFactories() {
>>> Map extensionFactoryMap =
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>> Ecore2XMLResource.Factory.INSTANCE);
>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>> UML22UMLResource.Factory.INSTANCE);
>>> }
>>>
>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>> }
>>>
>>> protected static void registerPackages(ResourceSet resourceSet) {
>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>> Ecore2XMLPackage.eINSTANCE);
>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>> }
>>>
>>>
>>> }
>>>
>>
Re: Load Model from Enterprise Architect [message #473022 is a reply to message #473003] Tue, 29 May 2007 07:10 Go to previous messageGo to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Kenn,

thanks for your help. When I change the URL of the uml-Namespace in the
exported file manually to your suggested value, I'm getting the same
error as before (see stack trace below). When I add an URI Converter

URIConverter.URI_MAP.put(URI.createURI("http://schema.omg.org/spec/UML/2.0"),
URI.createURI("http://www.eclipse.org/uml2/1.0.0/UML"));

the resource loads but I'm unable to get the model (same behaviour as if
I don't change the exported file and don't add this uriconverter). This
suggests to me that my code doesn't really do what I want (because I'd
expect the same error as in the first case). Do you see anything wrong
in my code?

Thanks a lot,

Dominik

stack trace:

java.lang.IllegalArgumentException: The class 'Type' is not a valid
classifier
at
org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.create(UML FactoryImpl.java:679)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:784)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:832)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1933)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:1907)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1783)
at
org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.creat eObject(UML22UMLHandler.java:67)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1561)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:881)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
Source)
at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:900)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
at zzz.test.LoadUML.load(LoadUML.java:46)
at zzz.test.LoadUML.main(LoadUML.java:73)




Kenn Hussey schrieb:
> Dominik,
>
> I was able to successfuly load this model into the UML editor by changing
> the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
> resource had an extension of ".uml2". This suggests to me that it should be
> possible to load it programmatically by adding a URI converter mapping from
> http://schema.omg.org/spec/UML/2.0 to http://www.eclipse.org/uml2/1.0.0/UML
> and ensuring the UML22UML resource factory is registered against whatever
> file extension you give the resource. Please try this and let us know if it
> works for you.
>
> Kenn
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f30ph5$mhb$1@build.eclipse.org...
>> Hi James,
>>
>> thanks for your help. Unfortunately it didn't help (I tried both
>> "http://www.eclipse.org/uml2/1.0.0/UML" and
>> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>>
>> Greets,
>>
>> Dominik
>>
>> James Bruck schrieb:
>>> Hi Dominik,
>>>
>>> Can you give this a quick try ...
>>>
>>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>>> 2.0.0 ).
>>> That should trigger a migration and should work then.
>>>
>>> Let me know if that works.
>>>
>>> Regards,
>>>
>>> - James.
>>>
>>>
>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>> news:f2s99h$np6$1@build.eclipse.org...
>>>> Hi there,
>>>>
>>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>>> standalone application. With the help of the migration guide and the
>>>> "Getting Started"-article I tried to figure out, how my code must look
>>>> like. But I wasn't too successful. If I don't change the exported XMI
>>>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>>>> null), if I change the uml namespace to
>>>>
>>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>>
>>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>>
>>>> Can anyone help please?
>>>>
>>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>>> this is okay.
>>>>
>>>> Thanks in advance,
>>>>
>>>> Dominik Raymann
>>>>
>>>
>>> ------------------------------------------------------------ ----------------
>>> ----
>>>
>>>
>>>> <?xml version="1.0" encoding="windows-1252"?>
>>>> <xmi:XMI xmi:version="2.1"
>>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>>> <xmi:Documentation exporter="Enterprise Architect"
>>>> exporterVersion="6.5"/>
>>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>>> <ownedMember xmi:type="uml:Package"
>>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>>> visibility="public">
>>>> <ownedMember xmi:type="uml:Package"
>>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>>> visibility="public">
>>>> <ownedMember xmi:type="uml:Class"
>>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>>> visibility="public">
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>>> visibility="private" isDerived="false">
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>> </ownedAttribute>
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>>> </ownedAttribute>
>>>> </ownedMember>
>>>> <ownedMember xmi:type="uml:Association"
>>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>> <ownedEnd xmi:type="uml:Property"
>>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>> </ownedEnd>
>>>> </ownedMember>
>>>> <ownedMember xmi:type="uml:Class"
>>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>>> visibility="public">
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>>> visibility="private" isDerived="false">
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>> </ownedAttribute>
>>>> </ownedMember>
>>>> <ownedMember xmi:type="uml:Class"
>>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>>> visibility="public">
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>>> visibility="private" isDerived="false">
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>> </ownedAttribute>
>>>> <generalization xmi:type="uml:Generalization"
>>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>> </ownedMember>
>>>> </ownedMember>
>>>> </ownedMember>
>>>> </uml:Model>
>>>> </xmi:XMI>
>>>>
>>>
>>> ------------------------------------------------------------ ----------------
>>> ----
>>>
>>>
>>>> /*
>>>> * Created on 21.05.2007
>>>> *
>>>> * (c) by Boxalino
>>>> */
>>>> package zzz.test;
>>>>
>>>> import java.util.Map;
>>>> import org.eclipse.emf.common.util.URI;
>>>> import org.eclipse.emf.ecore.EcorePackage;
>>>> import org.eclipse.emf.ecore.resource.Resource;
>>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>>> import org.eclipse.uml2.uml.Model;
>>>> import org.eclipse.uml2.uml.UMLPackage;
>>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>>> import com.boxalino.log.ILogger;
>>>> import com.boxalino.log.Logger;
>>>>
>>>> public class LoadUML {
>>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>>
>>>> private Model _model = null;
>>>>
>>>> public void load(String path) {
>>>>
>>>> URI furi = URI.createFileURI(path);
>>>>
>>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>>> registerPackages(RESOURCE_SET);
>>>> registerResourceFactories();
>>>>
>>>> // For a stand alone application, it is necessary to map the platform
>>>> // plugin URI scheme to the workspace location.
>>>>
>>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>>> l/"),
>>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>>> 0702141227.jar!/"));
>>>> Resource resource = null;
>>>> try {
>>>> resource = RESOURCE_SET.getResource(furi, true);
>>>> }
>>>> catch (Exception e) {
>>>> System.out.println(e.getMessage());
>>>> return;
>>>> }
>>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>>> UMLPackage.Literals.MODEL);
>>>> if (_model != null) {
>>>> System.out.println("ok");
>>>> }
>>>> else {
>>>> System.out.println("failed");
>>>> }
>>>> }
>>>>
>>>>
>>>> public static void main(String[] args) {
>>>> LoadUML uml2bom = new LoadUML();
>>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>>> }
>>>>
>>>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>>>
>>>> protected static void registerResourceFactories() {
>>>> Map extensionFactoryMap =
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>>> UMLResource.Factory.INSTANCE);
>>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>>> Ecore2XMLResource.Factory.INSTANCE);
>>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>>> UML22UMLResource.Factory.INSTANCE);
>>>> }
>>>>
>>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>>> }
>>>>
>>>> protected static void registerPackages(ResourceSet resourceSet) {
>>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>>> Ecore2XMLPackage.eINSTANCE);
>>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>>> }
>>>>
>>>>
>>>> }
>>>>
>
Re: Load Model from Enterprise Architect [message #473030 is a reply to message #473022] Tue, 29 May 2007 21:31 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

I just tried your code (with the additional URI mapping mentioned below)
using both UML2 2.0.3 and the latest UML2 build (2.1 RC1), and was able to
successfully load the model (the result was "ok")... I don't really know
what to suggest at this point other than to try using the debugger to see
what might be happening... :(

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f3gjm8$3on$1@build.eclipse.org...
> Kenn,
>
> thanks for your help. When I change the URL of the uml-Namespace in the
> exported file manually to your suggested value, I'm getting the same error
> as before (see stack trace below). When I add an URI Converter
>
> URIConverter.URI_MAP.put(URI.createURI("http://schema.omg.org/spec/UML/2.0"),
> URI.createURI("http://www.eclipse.org/uml2/1.0.0/UML"));
>
> the resource loads but I'm unable to get the model (same behaviour as if I
> don't change the exported file and don't add this uriconverter). This
> suggests to me that my code doesn't really do what I want (because I'd
> expect the same error as in the first case). Do you see anything wrong in
> my code?
>
> Thanks a lot,
>
> Dominik
>
> stack trace:
>
> java.lang.IllegalArgumentException: The class 'Type' is not a valid
> classifier
> at
> org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.create(UML FactoryImpl.java:679)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:784)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:832)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1933)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:1907)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1783)
> at
> org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.creat eObject(UML22UMLHandler.java:67)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1561)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:881)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
> Source)
> at
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:900)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
> at zzz.test.LoadUML.load(LoadUML.java:46)
> at zzz.test.LoadUML.main(LoadUML.java:73)
>
>
>
>
> Kenn Hussey schrieb:
>> Dominik,
>>
>> I was able to successfuly load this model into the UML editor by changing
>> the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
>> resource had an extension of ".uml2". This suggests to me that it should
>> be possible to load it programmatically by adding a URI converter mapping
>> from http://schema.omg.org/spec/UML/2.0 to
>> http://www.eclipse.org/uml2/1.0.0/UML and ensuring the UML22UML resource
>> factory is registered against whatever file extension you give the
>> resource. Please try this and let us know if it works for you.
>>
>> Kenn
>>
>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>> news:f30ph5$mhb$1@build.eclipse.org...
>>> Hi James,
>>>
>>> thanks for your help. Unfortunately it didn't help (I tried both
>>> "http://www.eclipse.org/uml2/1.0.0/UML" and
>>> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>>>
>>> Greets,
>>>
>>> Dominik
>>>
>>> James Bruck schrieb:
>>>> Hi Dominik,
>>>>
>>>> Can you give this a quick try ...
>>>>
>>>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>>>> 2.0.0 ).
>>>> That should trigger a migration and should work then.
>>>>
>>>> Let me know if that works.
>>>>
>>>> Regards,
>>>>
>>>> - James.
>>>>
>>>>
>>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>>> news:f2s99h$np6$1@build.eclipse.org...
>>>>> Hi there,
>>>>>
>>>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>>>> standalone application. With the help of the migration guide and the
>>>>> "Getting Started"-article I tried to figure out, how my code must look
>>>>> like. But I wasn't too successful. If I don't change the exported XMI
>>>>> (as attached) I can't get the model (EcoreUtil.getObjectByType()
>>>>> returns
>>>>> null), if I change the uml namespace to
>>>>>
>>>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>>>
>>>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>>>
>>>>> Can anyone help please?
>>>>>
>>>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>>>> this is okay.
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Dominik Raymann
>>>>>
>>>>
>>>> ------------------------------------------------------------ ----------------
>>>> ----
>>>>
>>>>
>>>>> <?xml version="1.0" encoding="windows-1252"?>
>>>>> <xmi:XMI xmi:version="2.1"
>>>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>>>> <xmi:Documentation exporter="Enterprise Architect"
>>>>> exporterVersion="6.5"/>
>>>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>>>> <ownedMember xmi:type="uml:Package"
>>>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>>>> visibility="public">
>>>>> <ownedMember xmi:type="uml:Package"
>>>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>>>> visibility="public">
>>>>> <ownedMember xmi:type="uml:Class"
>>>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>>>> visibility="public">
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>>>> visibility="private" isDerived="false">
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>> </ownedAttribute>
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>> isOrdered="false"
>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>>>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>>>> </ownedAttribute>
>>>>> </ownedMember>
>>>>> <ownedMember xmi:type="uml:Association"
>>>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>> <ownedEnd xmi:type="uml:Property"
>>>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>> isOrdered="false"
>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>> </ownedEnd>
>>>>> </ownedMember>
>>>>> <ownedMember xmi:type="uml:Class"
>>>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>>>> visibility="public">
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>>>> visibility="private" isDerived="false">
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>> </ownedAttribute>
>>>>> </ownedMember>
>>>>> <ownedMember xmi:type="uml:Class"
>>>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>>>> visibility="public">
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>>>> visibility="private" isDerived="false">
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>> </ownedAttribute>
>>>>> <generalization xmi:type="uml:Generalization"
>>>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>>>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>> </ownedMember>
>>>>> </ownedMember>
>>>>> </ownedMember>
>>>>> </uml:Model>
>>>>> </xmi:XMI>
>>>>>
>>>>
>>>> ------------------------------------------------------------ ----------------
>>>> ----
>>>>
>>>>
>>>>> /*
>>>>> * Created on 21.05.2007
>>>>> *
>>>>> * (c) by Boxalino
>>>>> */
>>>>> package zzz.test;
>>>>>
>>>>> import java.util.Map;
>>>>> import org.eclipse.emf.common.util.URI;
>>>>> import org.eclipse.emf.ecore.EcorePackage;
>>>>> import org.eclipse.emf.ecore.resource.Resource;
>>>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>>>> import org.eclipse.uml2.uml.Model;
>>>>> import org.eclipse.uml2.uml.UMLPackage;
>>>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>>>> import com.boxalino.log.ILogger;
>>>>> import com.boxalino.log.Logger;
>>>>>
>>>>> public class LoadUML {
>>>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>>>
>>>>> private Model _model = null;
>>>>>
>>>>> public void load(String path) {
>>>>>
>>>>> URI furi = URI.createFileURI(path);
>>>>>
>>>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>>>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>>>> registerPackages(RESOURCE_SET);
>>>>> registerResourceFactories();
>>>>>
>>>>> // For a stand alone application, it is necessary to map the platform
>>>>> // plugin URI scheme to the workspace location.
>>>>>
>>>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>>>> l/"),
>>>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>>>> 0702141227.jar!/"));
>>>>> Resource resource = null;
>>>>> try {
>>>>> resource = RESOURCE_SET.getResource(furi, true);
>>>>> }
>>>>> catch (Exception e) {
>>>>> System.out.println(e.getMessage());
>>>>> return;
>>>>> }
>>>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>>>> UMLPackage.Literals.MODEL);
>>>>> if (_model != null) {
>>>>> System.out.println("ok");
>>>>> }
>>>>> else {
>>>>> System.out.println("failed");
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> public static void main(String[] args) {
>>>>> LoadUML uml2bom = new LoadUML();
>>>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>>>> }
>>>>>
>>>>> protected static final ResourceSet RESOURCE_SET = new
>>>>> ResourceSetImpl();
>>>>>
>>>>> protected static void registerResourceFactories() {
>>>>> Map extensionFactoryMap =
>>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>>>> UMLResource.Factory.INSTANCE);
>>>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>>>> Ecore2XMLResource.Factory.INSTANCE);
>>>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>>>> UML22UMLResource.Factory.INSTANCE);
>>>>> }
>>>>>
>>>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>>>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>>>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>>>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>>>> }
>>>>>
>>>>> protected static void registerPackages(ResourceSet resourceSet) {
>>>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>>>> Ecore2XMLPackage.eINSTANCE);
>>>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>>>> }
>>>>>
>>>>>
>>>>> }
>>>>>
>>
Re: Load Model from Enterprise Architect [message #473035 is a reply to message #473030] Wed, 30 May 2007 07:25 Go to previous messageGo to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi Kenn,

thank you very much for your efforts. It's wonderful to have such
dedicated people in a community.

I finally got the code to work. Knowing that the code works I
concentrated on the environment. I started all over, downloaded the
latest UML2 build and dependencies, copied them to a folder outside my
eclipse installation and changed my build path accordingly - et voilà -
I got an "ok".

I think I had some improper (i.e. non matching) libraries in my build
path previously, because I had two different UML2 builds (and EMF) in my
plugins directory (gosh, this directory is quite confusing).

Once more thanks to Kenn,

Dominik

Kenn Hussey schrieb:
> Dominik,
>
> I just tried your code (with the additional URI mapping mentioned below)
> using both UML2 2.0.3 and the latest UML2 build (2.1 RC1), and was able to
> successfully load the model (the result was "ok")... I don't really know
> what to suggest at this point other than to try using the debugger to see
> what might be happening... :(
>
> Kenn
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f3gjm8$3on$1@build.eclipse.org...
>> Kenn,
>>
>> thanks for your help. When I change the URL of the uml-Namespace in the
>> exported file manually to your suggested value, I'm getting the same error
>> as before (see stack trace below). When I add an URI Converter
>>
>> URIConverter.URI_MAP.put(URI.createURI("http://schema.omg.org/spec/UML/2.0"),
>> URI.createURI("http://www.eclipse.org/uml2/1.0.0/UML"));
>>
>> the resource loads but I'm unable to get the model (same behaviour as if I
>> don't change the exported file and don't add this uriconverter). This
>> suggests to me that my code doesn't really do what I want (because I'd
>> expect the same error as in the first case). Do you see anything wrong in
>> my code?
>>
>> Thanks a lot,
>>
>> Dominik
>>
>> stack trace:
>>
>> java.lang.IllegalArgumentException: The class 'Type' is not a valid
>> classifier
>> at
>> org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.create(UML FactoryImpl.java:679)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:784)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:832)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1933)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:1907)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1783)
>> at
>> org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.creat eObject(UML22UMLHandler.java:67)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1561)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:881)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
>> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
>> Source)
>> at
>> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
>> Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>> at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:900)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
>> at zzz.test.LoadUML.load(LoadUML.java:46)
>> at zzz.test.LoadUML.main(LoadUML.java:73)
>>
>>
>>
>>
>> Kenn Hussey schrieb:
>>> Dominik,
>>>
>>> I was able to successfuly load this model into the UML editor by changing
>>> the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
>>> resource had an extension of ".uml2". This suggests to me that it should
>>> be possible to load it programmatically by adding a URI converter mapping
>>> from http://schema.omg.org/spec/UML/2.0 to
>>> http://www.eclipse.org/uml2/1.0.0/UML and ensuring the UML22UML resource
>>> factory is registered against whatever file extension you give the
>>> resource. Please try this and let us know if it works for you.
>>>
>>> Kenn
>>>
>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>> news:f30ph5$mhb$1@build.eclipse.org...
>>>> Hi James,
>>>>
>>>> thanks for your help. Unfortunately it didn't help (I tried both
>>>> "http://www.eclipse.org/uml2/1.0.0/UML" and
>>>> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>>>>
>>>> Greets,
>>>>
>>>> Dominik
>>>>
>>>> James Bruck schrieb:
>>>>> Hi Dominik,
>>>>>
>>>>> Can you give this a quick try ...
>>>>>
>>>>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>>>>> 2.0.0 ).
>>>>> That should trigger a migration and should work then.
>>>>>
>>>>> Let me know if that works.
>>>>>
>>>>> Regards,
>>>>>
>>>>> - James.
>>>>>
>>>>>
>>>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>>>> news:f2s99h$np6$1@build.eclipse.org...
>>>>>> Hi there,
>>>>>>
>>>>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>>>>> standalone application. With the help of the migration guide and the
>>>>>> "Getting Started"-article I tried to figure out, how my code must look
>>>>>> like. But I wasn't too successful. If I don't change the exported XMI
>>>>>> (as attached) I can't get the model (EcoreUtil.getObjectByType()
>>>>>> returns
>>>>>> null), if I change the uml namespace to
>>>>>>
>>>>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>>>>
>>>>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>>>>
>>>>>> Can anyone help please?
>>>>>>
>>>>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>>>>> this is okay.
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> Dominik Raymann
>>>>>>
>>>>> ------------------------------------------------------------ ----------------
>>>>> ----
>>>>>
>>>>>
>>>>>> <?xml version="1.0" encoding="windows-1252"?>
>>>>>> <xmi:XMI xmi:version="2.1"
>>>>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>>>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>>>>> <xmi:Documentation exporter="Enterprise Architect"
>>>>>> exporterVersion="6.5"/>
>>>>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>>>>> <ownedMember xmi:type="uml:Package"
>>>>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>>>>> visibility="public">
>>>>>> <ownedMember xmi:type="uml:Package"
>>>>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>>>>> visibility="public">
>>>>>> <ownedMember xmi:type="uml:Class"
>>>>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>>>>> visibility="public">
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>>>>> visibility="private" isDerived="false">
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>>> </ownedAttribute>
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>>> isOrdered="false"
>>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>>>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>>>>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>>>>> </ownedAttribute>
>>>>>> </ownedMember>
>>>>>> <ownedMember xmi:type="uml:Association"
>>>>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>>>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>>> <ownedEnd xmi:type="uml:Property"
>>>>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>>> isOrdered="false"
>>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>>> </ownedEnd>
>>>>>> </ownedMember>
>>>>>> <ownedMember xmi:type="uml:Class"
>>>>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>>>>> visibility="public">
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>>>>> visibility="private" isDerived="false">
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>>> </ownedAttribute>
>>>>>> </ownedMember>
>>>>>> <ownedMember xmi:type="uml:Class"
>>>>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>>>>> visibility="public">
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>>>>> visibility="private" isDerived="false">
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>>> </ownedAttribute>
>>>>>> <generalization xmi:type="uml:Generalization"
>>>>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>>>>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>>> </ownedMember>
>>>>>> </ownedMember>
>>>>>> </ownedMember>
>>>>>> </uml:Model>
>>>>>> </xmi:XMI>
>>>>>>
>>>>> ------------------------------------------------------------ ----------------
>>>>> ----
>>>>>
>>>>>
>>>>>> /*
>>>>>> * Created on 21.05.2007
>>>>>> *
>>>>>> * (c) by Boxalino
>>>>>> */
>>>>>> package zzz.test;
>>>>>>
>>>>>> import java.util.Map;
>>>>>> import org.eclipse.emf.common.util.URI;
>>>>>> import org.eclipse.emf.ecore.EcorePackage;
>>>>>> import org.eclipse.emf.ecore.resource.Resource;
>>>>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>>>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>>>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>>>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>>>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>>>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>>>>> import org.eclipse.uml2.uml.Model;
>>>>>> import org.eclipse.uml2.uml.UMLPackage;
>>>>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>>>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>>>>> import com.boxalino.log.ILogger;
>>>>>> import com.boxalino.log.Logger;
>>>>>>
>>>>>> public class LoadUML {
>>>>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>>>>
>>>>>> private Model _model = null;
>>>>>>
>>>>>> public void load(String path) {
>>>>>>
>>>>>> URI furi = URI.createFileURI(path);
>>>>>>
>>>>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>>>>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>>>>> registerPackages(RESOURCE_SET);
>>>>>> registerResourceFactories();
>>>>>>
>>>>>> // For a stand alone application, it is necessary to map the platform
>>>>>> // plugin URI scheme to the workspace location.
>>>>>>
>>>>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>>>>> l/"),
>>>>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>>>>> 0702141227.jar!/"));
>>>>>> Resource resource = null;
>>>>>> try {
>>>>>> resource = RESOURCE_SET.getResource(furi, true);
>>>>>> }
>>>>>> catch (Exception e) {
>>>>>> System.out.println(e.getMessage());
>>>>>> return;
>>>>>> }
>>>>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>>>>> UMLPackage.Literals.MODEL);
>>>>>> if (_model != null) {
>>>>>> System.out.println("ok");
>>>>>> }
>>>>>> else {
>>>>>> System.out.println("failed");
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> public static void main(String[] args) {
>>>>>> LoadUML uml2bom = new LoadUML();
>>>>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>>>>> }
>>>>>>
>>>>>> protected static final ResourceSet RESOURCE_SET = new
>>>>>> ResourceSetImpl();
>>>>>>
>>>>>> protected static void registerResourceFactories() {
>>>>>> Map extensionFactoryMap =
>>>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>>>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>>>>> UMLResource.Factory.INSTANCE);
>>>>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>>>>> Ecore2XMLResource.Factory.INSTANCE);
>>>>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>>>>> UML22UMLResource.Factory.INSTANCE);
>>>>>> }
>>>>>>
>>>>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>>>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>>>>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>>>>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>>>>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>>>>> }
>>>>>>
>>>>>> protected static void registerPackages(ResourceSet resourceSet) {
>>>>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>>>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>>>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>>>>> Ecore2XMLPackage.eINSTANCE);
>>>>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> }
>>>>>>
>
>
Re: Load Model from Enterprise Architect [message #473038 is a reply to message #473035] Wed, 30 May 2007 12:43 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

Glad to have been able to help the little that I did. Taking a second look
at what I did last night to get it to work, I realize that I had a changed
the namespace URI in the file to http://www.eclipse.org/uml2/1.0.0/UML (as
originally suggested by James), which means that the extra URI mapping isn't
needed after all (not sure why the mapping isn't consulted before looking up
the package)...

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f3j8uu$l94$1@build.eclipse.org...
> Hi Kenn,
>
> thank you very much for your efforts. It's wonderful to have such
> dedicated people in a community.
>
> I finally got the code to work. Knowing that the code works I concentrated
> on the environment. I started all over, downloaded the latest UML2 build
> and dependencies, copied them to a folder outside my eclipse installation
> and changed my build path accordingly - et voil
Re: Load Model from Enterprise Architect [message #473088 is a reply to message #473038] Mon, 04 June 2007 08:03 Go to previous messageGo to next message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi, it's me again :-)

two more questions:

Is it a bug that the additional URI-Mapper to
"http://www.eclipse.org/uml2/1.0.0/UML" isn't considered? Since I want
to import the XMI from EA automatically (without prior manual changes
needed), I now have to change the wrong namespace by opening the file
and replacing the uri (which isn't exactly very elegant). So someone
should report this as a bug?

Secondly, EA inserts an extension to the XMI, which is introduced by

<xmi:Extension extender="Enterprise Architect" extenderID="6.5">

If the XMI contains this tag, I get the following error:

org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'null' is not
legal. (file:/c:/temp/tempXMI.uml2, 130, 18)

(with 130, 18 being in the extension section)

I think the extension tag should be read (and re-written if saved again)
without any further parsing so I dont't understand this exception.

Dominik

Kenn Hussey schrieb:
> Dominik,
>
> Glad to have been able to help the little that I did. Taking a second look
> at what I did last night to get it to work, I realize that I had a changed
> the namespace URI in the file to http://www.eclipse.org/uml2/1.0.0/UML (as
> originally suggested by James), which means that the extra URI mapping isn't
> needed after all (not sure why the mapping isn't consulted before looking up
> the package)...
>
> Kenn
>
Re: Load Model from Enterprise Architect [message #473198 is a reply to message #473088] Wed, 13 June 2007 14:06 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

Sorry for the delayed response.

I'm not sure it's a bug that a package URI isn't normalized before the
extended metadata is used to look it up in the package registry... but it
might make sense to enhance EMF to do this, so feel free to open an
enhancement request against EMF for the next release.

I would have expected the XMLResource.OPTION_RECORD_UNKNOWN_FEATURE load
option (which is set by default for UML2 resources) to handle extensions as
unrecognized data... I know that this handling of extensions works for the
XMI interchange resource implementation in UML2, but it only supports
interchange based on UML 2.1.1. It should be possible to take what's
provided in UML2 (a combination of resource and extended metadata
implementations) and modify/enhance it for your situation. The problem here
is that you're trying to do two things at once - interchange (from a
"standard" format for UML 2.0) and migration (from UML2 1.x to 2.x)...

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f40h0l$3t8$1@build.eclipse.org...
> Hi, it's me again :-)
>
> two more questions:
>
> Is it a bug that the additional URI-Mapper to
> "http://www.eclipse.org/uml2/1.0.0/UML" isn't considered? Since I want to
> import the XMI from EA automatically (without prior manual changes
> needed), I now have to change the wrong namespace by opening the file and
> replacing the uri (which isn't exactly very elegant). So someone should
> report this as a bug?
>
> Secondly, EA inserts an extension to the XMI, which is introduced by
>
> <xmi:Extension extender="Enterprise Architect" extenderID="6.5">
>
> If the XMI contains this tag, I get the following error:
>
> org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'null' is not
> legal. (file:/c:/temp/tempXMI.uml2, 130, 18)
>
> (with 130, 18 being in the extension section)
>
> I think the extension tag should be read (and re-written if saved again)
> without any further parsing so I dont't understand this exception.
>
> Dominik
>
> Kenn Hussey schrieb:
>> Dominik,
>>
>> Glad to have been able to help the little that I did. Taking a second
>> look at what I did last night to get it to work, I realize that I had a
>> changed the namespace URI in the file to
>> http://www.eclipse.org/uml2/1.0.0/UML (as originally suggested by James),
>> which means that the extra URI mapping isn't needed after all (not sure
>> why the mapping isn't consulted before looking up the package)...
>>
>> Kenn
>>
Re: Load Model from Enterprise Architect [message #617176 is a reply to message #472923] Tue, 22 May 2007 16:17 Go to previous message
Eclipse UserFriend
Originally posted by: swt.stanford.edu

Hi,

I am getting the same error when I import EA's XMI files. When I raised
the issue with EA support, I received the following response. Does it
make sense to the Eclipse UML gurus?


>
> Thanks for the note and the sample file.
>
> EA is a UML tool which describes its UML models based on MOF ( Meta
> Object Facility ). Whereas, Eclipse describes its UML models based on
> EMF ( Eclipse Modelling Framework ).
> When serializing in XMI, the XMI for an UML model based on MOF will vary
> from a model based on EMF. Hence the error when you tried to import the
> XMI of a MOF based UML model into an EMF based tool.
> Unfortunately, there is no workaround this issue currently.
>
> I am sorry that I cannot offer further assistance regarding this issue
> at this stage . If you have any further queries, feel free to write-in.
>
> Best Regards,
>
> Vimal Kumar
> Sparx Systems Pty Ltd
> support@sparxsystems.com.au
> http://www.sparxsystems.com.au



Dominik Raymann wrote:
> Hi there,
>
> I'm trying to load a XMI generate by Enterprise Architect in a
> standalone application. With the help of the migration guide and the
> "Getting Started"-article I tried to figure out, how my code must look
> like. But I wasn't too successful. If I don't change the exported XMI
> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
> null), if I change the uml namespace to
>
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>
> I'm getting a "The class 'Type' is not a valid classifier" error.
>
> Can anyone help please?
>
> Since the xmi(uml) and my code isn't very big, I attached them. Hope
> this is okay.
>
> Thanks in advance,
>
> Dominik Raymann
Re: Load Model from Enterprise Architect [message #617178 is a reply to message #472923] Tue, 22 May 2007 21:56 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Dominik,

Can you give this a quick try ...

Simply try changing the nsURI to the older version ie. 1.0.0 ( not
2.0.0 ).
That should trigger a migration and should work then.

Let me know if that works.

Regards,

- James.


"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f2s99h$np6$1@build.eclipse.org...
> Hi there,
>
> I'm trying to load a XMI generate by Enterprise Architect in a
> standalone application. With the help of the migration guide and the
> "Getting Started"-article I tried to figure out, how my code must look
> like. But I wasn't too successful. If I don't change the exported XMI
> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
> null), if I change the uml namespace to
>
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>
> I'm getting a "The class 'Type' is not a valid classifier" error.
>
> Can anyone help please?
>
> Since the xmi(uml) and my code isn't very big, I attached them. Hope
> this is okay.
>
> Thanks in advance,
>
> Dominik Raymann
>


------------------------------------------------------------ ----------------
----


> <?xml version="1.0" encoding="windows-1252"?>
> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
> <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
> <ownedMember xmi:type="uml:Package"
xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
visibility="public">
> <ownedMember xmi:type="uml:Package"
xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
visibility="public">
> <ownedMember xmi:type="uml:Class"
xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
visibility="public">
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> </ownedAttribute>
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Association"
xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <ownedEnd xmi:type="uml:Property"
xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> </ownedEnd>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
visibility="public">
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
visibility="public">
> <ownedAttribute xmi:type="uml:Property"
xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
> </ownedAttribute>
> <generalization xmi:type="uml:Generalization"
xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> </ownedMember>
> </ownedMember>
> </ownedMember>
> </uml:Model>
> </xmi:XMI>
>


------------------------------------------------------------ ----------------
----


> /*
> * Created on 21.05.2007
> *
> * (c) by Boxalino
> */
> package zzz.test;
>
> import java.util.Map;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.URIConverter;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.util.EcoreUtil;
> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
> import org.eclipse.uml2.uml.Model;
> import org.eclipse.uml2.uml.UMLPackage;
> import org.eclipse.uml2.uml.resource.UML22UMLResource;
> import org.eclipse.uml2.uml.resource.UMLResource;
> import com.boxalino.log.ILogger;
> import com.boxalino.log.Logger;
>
> public class LoadUML {
> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>
> private Model _model = null;
>
> public void load(String path) {
>
> URI furi = URI.createFileURI(path);
>
registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
ml2.uml.resources_2.0.3.v200702141227.jar!/"));
> registerPackages(RESOURCE_SET);
> registerResourceFactories();
>
> // For a stand alone application, it is necessary to map the platform
> // plugin URI scheme to the workspace location.
>
URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
l/"),
URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
0702141227.jar!/"));
>
> Resource resource = null;
> try {
> resource = RESOURCE_SET.getResource(furi, true);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> return;
> }
> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.MODEL);
>
> if (_model != null) {
> System.out.println("ok");
> }
> else {
> System.out.println("failed");
> }
> }
>
>
> public static void main(String[] args) {
> LoadUML uml2bom = new LoadUML();
> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
> }
>
> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>
> protected static void registerResourceFactories() {
> Map extensionFactoryMap =
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
Ecore2XMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
UML22UMLResource.Factory.INSTANCE);
> }
>
> protected static void registerPathmaps(URI umlResourcePluginURI) {
> System.out.println(UMLResource.LIBRARIES_PATHMAP);
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
> }
>
> protected static void registerPackages(ResourceSet resourceSet) {
> Map packageRegistry = resourceSet.getPackageRegistry();
> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
> packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
> }
>
>
> }
>
Re: Load Model from Enterprise Architect [message #617181 is a reply to message #472931] Wed, 23 May 2007 07:12 Go to previous message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi James,

thanks for your help. Unfortunately it didn't help (I tried both
"http://www.eclipse.org/uml2/1.0.0/UML" and
"http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.

Greets,

Dominik

James Bruck schrieb:
> Hi Dominik,
>
> Can you give this a quick try ...
>
> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
> 2.0.0 ).
> That should trigger a migration and should work then.
>
> Let me know if that works.
>
> Regards,
>
> - James.
>
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f2s99h$np6$1@build.eclipse.org...
>> Hi there,
>>
>> I'm trying to load a XMI generate by Enterprise Architect in a
>> standalone application. With the help of the migration guide and the
>> "Getting Started"-article I tried to figure out, how my code must look
>> like. But I wasn't too successful. If I don't change the exported XMI
>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>> null), if I change the uml namespace to
>>
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>
>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>
>> Can anyone help please?
>>
>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>> this is okay.
>>
>> Thanks in advance,
>>
>> Dominik Raymann
>>
>
>
> ------------------------------------------------------------ ----------------
> ----
>
>
>> <?xml version="1.0" encoding="windows-1252"?>
>> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>> <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
> visibility="public">
>> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
> visibility="public">
>> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> </ownedAttribute>
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Association"
> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <ownedEnd xmi:type="uml:Property"
> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> </ownedEnd>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> </ownedAttribute>
>> <generalization xmi:type="uml:Generalization"
> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> </ownedMember>
>> </ownedMember>
>> </ownedMember>
>> </uml:Model>
>> </xmi:XMI>
>>
>
>
> ------------------------------------------------------------ ----------------
> ----
>
>
>> /*
>> * Created on 21.05.2007
>> *
>> * (c) by Boxalino
>> */
>> package zzz.test;
>>
>> import java.util.Map;
>> import org.eclipse.emf.common.util.URI;
>> import org.eclipse.emf.ecore.EcorePackage;
>> import org.eclipse.emf.ecore.resource.Resource;
>> import org.eclipse.emf.ecore.resource.ResourceSet;
>> import org.eclipse.emf.ecore.resource.URIConverter;
>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>> import org.eclipse.emf.ecore.util.EcoreUtil;
>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>> import org.eclipse.uml2.uml.Model;
>> import org.eclipse.uml2.uml.UMLPackage;
>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>> import org.eclipse.uml2.uml.resource.UMLResource;
>> import com.boxalino.log.ILogger;
>> import com.boxalino.log.Logger;
>>
>> public class LoadUML {
>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>
>> private Model _model = null;
>>
>> public void load(String path) {
>>
>> URI furi = URI.createFileURI(path);
>>
> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>> registerPackages(RESOURCE_SET);
>> registerResourceFactories();
>>
>> // For a stand alone application, it is necessary to map the platform
>> // plugin URI scheme to the workspace location.
>>
> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
> l/"),
> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
> 0702141227.jar!/"));
>> Resource resource = null;
>> try {
>> resource = RESOURCE_SET.getResource(furi, true);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> return;
>> }
>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.MODEL);
>> if (_model != null) {
>> System.out.println("ok");
>> }
>> else {
>> System.out.println("failed");
>> }
>> }
>>
>>
>> public static void main(String[] args) {
>> LoadUML uml2bom = new LoadUML();
>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>> }
>>
>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>
>> protected static void registerResourceFactories() {
>> Map extensionFactoryMap =
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
> Ecore2XMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
> UML22UMLResource.Factory.INSTANCE);
>> }
>>
>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>> }
>>
>> protected static void registerPackages(ResourceSet resourceSet) {
>> Map packageRegistry = resourceSet.getPackageRegistry();
>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>> packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>> }
>>
>>
>> }
>>
>
>
Re: Load Model from Enterprise Architect [message #618126 is a reply to message #472923] Fri, 25 May 2007 19:14 Go to previous message
Eclipse UserFriend
Originally posted by: carrasco.ModelDrivenDevelopment.co.uk

Yeah, it?s a shame the undelying Eclipse metametamodel is not the truly
standard MOF...
it is so close!


"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f2s99h$np6$1@build.eclipse.org...
> Hi there,
>
> I'm trying to load a XMI generate by Enterprise Architect in a
> standalone application. With the help of the migration guide and the
> "Getting Started"-article I tried to figure out, how my code must look
> like. But I wasn't too successful. If I don't change the exported XMI
> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
> null), if I change the uml namespace to
>
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>
> I'm getting a "The class 'Type' is not a valid classifier" error.
>
> Can anyone help please?
>
> Since the xmi(uml) and my code isn't very big, I attached them. Hope
> this is okay.
>
> Thanks in advance,
>
> Dominik Raymann
>


------------------------------------------------------------ --------------------


> <?xml version="1.0" encoding="windows-1252"?>
> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
> <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
> visibility="public">
> <ownedMember xmi:type="uml:Package"
> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
> visibility="public">
> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
> visibility="public">
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
> visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
> </ownedAttribute>
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Association"
> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
> <ownedEnd xmi:type="uml:Property"
> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
> isDerived="false" isDerivedUnion="false" aggregation="none">
> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
> </ownedEnd>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
> visibility="public">
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
> visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
> </ownedAttribute>
> </ownedMember>
> <ownedMember xmi:type="uml:Class"
> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
> visibility="public">
> <ownedAttribute xmi:type="uml:Property"
> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
> visibility="private" isDerived="false">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
> <upperValue xmi:type="uml:LiteralInteger"
> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
> </ownedAttribute>
> <generalization xmi:type="uml:Generalization"
> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
> </ownedMember>
> </ownedMember>
> </ownedMember>
> </uml:Model>
> </xmi:XMI>
>


------------------------------------------------------------ --------------------


> /*
> * Created on 21.05.2007
> *
> * (c) by Boxalino
> */
> package zzz.test;
>
> import java.util.Map;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.URIConverter;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.util.EcoreUtil;
> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
> import org.eclipse.uml2.uml.Model;
> import org.eclipse.uml2.uml.UMLPackage;
> import org.eclipse.uml2.uml.resource.UML22UMLResource;
> import org.eclipse.uml2.uml.resource.UMLResource;
> import com.boxalino.log.ILogger;
> import com.boxalino.log.Logger;
>
> public class LoadUML {
> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>
> private Model _model = null;
>
> public void load(String path) {
>
> URI furi = URI.createFileURI(path);
> registerPathmaps(URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml.resource s_2.0.3.v200702141227.jar!/ "));
> registerPackages(RESOURCE_SET);
> registerResourceFactories();
>
> // For a stand alone application, it is necessary to map the platform
> // plugin URI scheme to the workspace location.
> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/ "),
> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 00702141227.jar!/ "));
>
> Resource resource = null;
> try {
> resource = RESOURCE_SET.getResource(furi, true);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> return;
> }
> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.MODEL);
>
> if (_model != null) {
> System.out.println("ok");
> }
> else {
> System.out.println("failed");
> }
> }
>
>
> public static void main(String[] args) {
> LoadUML uml2bom = new LoadUML();
> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
> }
>
> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>
> protected static void registerResourceFactories() {
> Map extensionFactoryMap =
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
> Ecore2XMLResource.Factory.INSTANCE);
> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
> UML22UMLResource.Factory.INSTANCE);
> }
>
> protected static void registerPathmaps(URI umlResourcePluginURI) {
> System.out.println(UMLResource.LIBRARIES_PATHMAP);
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
> }
>
> protected static void registerPackages(ResourceSet resourceSet) {
> Map packageRegistry = resourceSet.getPackageRegistry();
> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
> packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
> }
>
>
> }
>
Re: Load Model from Enterprise Architect [message #618128 is a reply to message #473000] Fri, 25 May 2007 19:35 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Antonio,

While the in-memory representation may not be purely MOF-based (being based
on Ecore instead of EMOF), UML2 does support interchange via the official
OMG format for UML 2.1.1 models (in addition to its own "proprietary" format
which includes "Eclipse-isms")...

Kenn

"Antonio Carrasco" <carrasco@ModelDrivenDevelopment.co.uk> wrote in message
news:f37cit$ohj$1@build.eclipse.org...
> Yeah, it?s a shame the undelying Eclipse metametamodel is not the truly
> standard MOF...
> it is so close!
>
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f2s99h$np6$1@build.eclipse.org...
>> Hi there,
>>
>> I'm trying to load a XMI generate by Enterprise Architect in a
>> standalone application. With the help of the migration guide and the
>> "Getting Started"-article I tried to figure out, how my code must look
>> like. But I wasn't too successful. If I don't change the exported XMI
>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>> null), if I change the uml namespace to
>>
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>
>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>
>> Can anyone help please?
>>
>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>> this is okay.
>>
>> Thanks in advance,
>>
>> Dominik Raymann
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> <?xml version="1.0" encoding="windows-1252"?>
>> <xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>> <xmi:Documentation exporter="Enterprise Architect"
>> exporterVersion="6.5"/>
>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>> visibility="public">
>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>> visibility="public">
>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>> </ownedAttribute>
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Association"
>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>> <ownedEnd xmi:type="uml:Property"
>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>> </ownedEnd>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>> </ownedAttribute>
>> </ownedMember>
>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>> visibility="public">
>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>> visibility="private" isDerived="false">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>> </ownedAttribute>
>> <generalization xmi:type="uml:Generalization"
>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>> </ownedMember>
>> </ownedMember>
>> </ownedMember>
>> </uml:Model>
>> </xmi:XMI>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> /*
>> * Created on 21.05.2007
>> *
>> * (c) by Boxalino
>> */
>> package zzz.test;
>>
>> import java.util.Map;
>> import org.eclipse.emf.common.util.URI;
>> import org.eclipse.emf.ecore.EcorePackage;
>> import org.eclipse.emf.ecore.resource.Resource;
>> import org.eclipse.emf.ecore.resource.ResourceSet;
>> import org.eclipse.emf.ecore.resource.URIConverter;
>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>> import org.eclipse.emf.ecore.util.EcoreUtil;
>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>> import org.eclipse.uml2.uml.Model;
>> import org.eclipse.uml2.uml.UMLPackage;
>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>> import org.eclipse.uml2.uml.resource.UMLResource;
>> import com.boxalino.log.ILogger;
>> import com.boxalino.log.Logger;
>>
>> public class LoadUML {
>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>
>> private Model _model = null;
>>
>> public void load(String path) {
>>
>> URI furi = URI.createFileURI(path);
>> registerPathmaps(URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml.resource s_2.0.3.v200702141227.jar!/ "));
>> registerPackages(RESOURCE_SET);
>> registerResourceFactories();
>>
>> // For a stand alone application, it is necessary to map the platform
>> // plugin URI scheme to the workspace location.
>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/ "),
>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 00702141227.jar!/ "));
>>
>> Resource resource = null;
>> try {
>> resource = RESOURCE_SET.getResource(furi, true);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> return;
>> }
>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>> UMLPackage.Literals.MODEL);
>>
>> if (_model != null) {
>> System.out.println("ok");
>> }
>> else {
>> System.out.println("failed");
>> }
>> }
>>
>>
>> public static void main(String[] args) {
>> LoadUML uml2bom = new LoadUML();
>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>> }
>>
>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>
>> protected static void registerResourceFactories() {
>> Map extensionFactoryMap =
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>> Ecore2XMLResource.Factory.INSTANCE);
>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>> UML22UMLResource.Factory.INSTANCE);
>> }
>>
>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>> }
>>
>> protected static void registerPackages(ResourceSet resourceSet) {
>> Map packageRegistry = resourceSet.getPackageRegistry();
>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>> Ecore2XMLPackage.eINSTANCE);
>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>> }
>>
>>
>> }
>>
>
>
Re: Load Model from Enterprise Architect [message #618130 is a reply to message #472929] Fri, 25 May 2007 19:41 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Samson,

There is only one official standard format for UML models, so regardless of
whether a given implementation is based on MOF or EMF, the interchange
format should be the same... unfortunately, problems tend to arise when
different tool vendors interpret the MOF and/or UML specifications
differently. :(

UML2 supports interchange using both its "native" format (based on EMF) and
"official" OMG format, so it should be able to handle models from a tool
that also supports the "official" OMG format. I will try to take a look at
the file and see where the discrepancy lies.

Kenn

"Samson Tu" <swt@stanford.edu> wrote in message
news:f2v52d$6g6$1@build.eclipse.org...
> Hi,
>
> I am getting the same error when I import EA's XMI files. When I raised
> the issue with EA support, I received the following response. Does it make
> sense to the Eclipse UML gurus?
>
>
>>
>> Thanks for the note and the sample file.
>>
>> EA is a UML tool which describes its UML models based on MOF ( Meta
>> Object Facility ). Whereas, Eclipse describes its UML models based on
>> EMF ( Eclipse Modelling Framework ).
>> When serializing in XMI, the XMI for an UML model based on MOF will vary
>> from a model based on EMF. Hence the error when you tried to import the
>> XMI of a MOF based UML model into an EMF based tool.
>> Unfortunately, there is no workaround this issue currently.
>>
>> I am sorry that I cannot offer further assistance regarding this issue
>> at this stage . If you have any further queries, feel free to write-in.
>>
>> Best Regards,
>>
>> Vimal Kumar
>> Sparx Systems Pty Ltd
>> support@sparxsystems.com.au
>> http://www.sparxsystems.com.au
>
>
>
> Dominik Raymann wrote:
>> Hi there,
>>
>> I'm trying to load a XMI generate by Enterprise Architect in a standalone
>> application. With the help of the migration guide and the "Getting
>> Started"-article I tried to figure out, how my code must look like. But I
>> wasn't too successful. If I don't change the exported XMI (as attached) I
>> can't get the model (EcoreUtil.getObjectByType() returns null), if I
>> change the uml namespace to
>>
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>
>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>
>> Can anyone help please?
>>
>> Since the xmi(uml) and my code isn't very big, I attached them. Hope this
>> is okay.
>>
>> Thanks in advance,
>>
>> Dominik Raymann
Re: Load Model from Enterprise Architect [message #618132 is a reply to message #472974] Fri, 25 May 2007 20:00 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

I was able to successfuly load this model into the UML editor by changing
the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
resource had an extension of ".uml2". This suggests to me that it should be
possible to load it programmatically by adding a URI converter mapping from
http://schema.omg.org/spec/UML/2.0 to http://www.eclipse.org/uml2/1.0.0/UML
and ensuring the UML22UML resource factory is registered against whatever
file extension you give the resource. Please try this and let us know if it
works for you.

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f30ph5$mhb$1@build.eclipse.org...
> Hi James,
>
> thanks for your help. Unfortunately it didn't help (I tried both
> "http://www.eclipse.org/uml2/1.0.0/UML" and
> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>
> Greets,
>
> Dominik
>
> James Bruck schrieb:
>> Hi Dominik,
>>
>> Can you give this a quick try ...
>>
>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>> 2.0.0 ).
>> That should trigger a migration and should work then.
>>
>> Let me know if that works.
>>
>> Regards,
>>
>> - James.
>>
>>
>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>> news:f2s99h$np6$1@build.eclipse.org...
>>> Hi there,
>>>
>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>> standalone application. With the help of the migration guide and the
>>> "Getting Started"-article I tried to figure out, how my code must look
>>> like. But I wasn't too successful. If I don't change the exported XMI
>>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>>> null), if I change the uml namespace to
>>>
>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>
>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>
>>> Can anyone help please?
>>>
>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>> this is okay.
>>>
>>> Thanks in advance,
>>>
>>> Dominik Raymann
>>>
>>
>>
>> ------------------------------------------------------------ ----------------
>> ----
>>
>>
>>> <?xml version="1.0" encoding="windows-1252"?>
>>> <xmi:XMI xmi:version="2.1"
>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>> <xmi:Documentation exporter="Enterprise Architect"
>>> exporterVersion="6.5"/>
>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>> visibility="public">
>>> <ownedMember xmi:type="uml:Package"
>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>> visibility="public">
>>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>> visibility="public">
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>> visibility="private" isDerived="false">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>> </ownedAttribute>
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>> </ownedAttribute>
>>> </ownedMember>
>>> <ownedMember xmi:type="uml:Association"
>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>> <ownedEnd xmi:type="uml:Property"
>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>> </ownedEnd>
>>> </ownedMember>
>>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>> visibility="public">
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>> visibility="private" isDerived="false">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>> </ownedAttribute>
>>> </ownedMember>
>>> <ownedMember xmi:type="uml:Class"
>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>> visibility="public">
>>> <ownedAttribute xmi:type="uml:Property"
>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>> visibility="private" isDerived="false">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>> <upperValue xmi:type="uml:LiteralInteger"
>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>> </ownedAttribute>
>>> <generalization xmi:type="uml:Generalization"
>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>> </ownedMember>
>>> </ownedMember>
>>> </ownedMember>
>>> </uml:Model>
>>> </xmi:XMI>
>>>
>>
>>
>> ------------------------------------------------------------ ----------------
>> ----
>>
>>
>>> /*
>>> * Created on 21.05.2007
>>> *
>>> * (c) by Boxalino
>>> */
>>> package zzz.test;
>>>
>>> import java.util.Map;
>>> import org.eclipse.emf.common.util.URI;
>>> import org.eclipse.emf.ecore.EcorePackage;
>>> import org.eclipse.emf.ecore.resource.Resource;
>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>> import org.eclipse.uml2.uml.Model;
>>> import org.eclipse.uml2.uml.UMLPackage;
>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>> import com.boxalino.log.ILogger;
>>> import com.boxalino.log.Logger;
>>>
>>> public class LoadUML {
>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>
>>> private Model _model = null;
>>>
>>> public void load(String path) {
>>>
>>> URI furi = URI.createFileURI(path);
>>>
>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>> registerPackages(RESOURCE_SET);
>>> registerResourceFactories();
>>>
>>> // For a stand alone application, it is necessary to map the platform
>>> // plugin URI scheme to the workspace location.
>>>
>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>> l/"),
>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>> 0702141227.jar!/"));
>>> Resource resource = null;
>>> try {
>>> resource = RESOURCE_SET.getResource(furi, true);
>>> }
>>> catch (Exception e) {
>>> System.out.println(e.getMessage());
>>> return;
>>> }
>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>> UMLPackage.Literals.MODEL);
>>> if (_model != null) {
>>> System.out.println("ok");
>>> }
>>> else {
>>> System.out.println("failed");
>>> }
>>> }
>>>
>>>
>>> public static void main(String[] args) {
>>> LoadUML uml2bom = new LoadUML();
>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>> }
>>>
>>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>>
>>> protected static void registerResourceFactories() {
>>> Map extensionFactoryMap =
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>> Ecore2XMLResource.Factory.INSTANCE);
>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>> UML22UMLResource.Factory.INSTANCE);
>>> }
>>>
>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>> }
>>>
>>> protected static void registerPackages(ResourceSet resourceSet) {
>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>> Ecore2XMLPackage.eINSTANCE);
>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>> }
>>>
>>>
>>> }
>>>
>>
Re: Load Model from Enterprise Architect [message #618170 is a reply to message #473003] Tue, 29 May 2007 07:10 Go to previous message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Kenn,

thanks for your help. When I change the URL of the uml-Namespace in the
exported file manually to your suggested value, I'm getting the same
error as before (see stack trace below). When I add an URI Converter

URIConverter.URI_MAP.put(URI.createURI("http://schema.omg.org/spec/UML/2.0"),
URI.createURI("http://www.eclipse.org/uml2/1.0.0/UML"));

the resource loads but I'm unable to get the model (same behaviour as if
I don't change the exported file and don't add this uriconverter). This
suggests to me that my code doesn't really do what I want (because I'd
expect the same error as in the first case). Do you see anything wrong
in my code?

Thanks a lot,

Dominik

stack trace:

java.lang.IllegalArgumentException: The class 'Type' is not a valid
classifier
at
org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.create(UML FactoryImpl.java:679)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:784)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:832)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1933)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:1907)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1783)
at
org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.creat eObject(UML22UMLHandler.java:67)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1561)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:881)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
Source)
at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:900)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
at zzz.test.LoadUML.load(LoadUML.java:46)
at zzz.test.LoadUML.main(LoadUML.java:73)




Kenn Hussey schrieb:
> Dominik,
>
> I was able to successfuly load this model into the UML editor by changing
> the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
> resource had an extension of ".uml2". This suggests to me that it should be
> possible to load it programmatically by adding a URI converter mapping from
> http://schema.omg.org/spec/UML/2.0 to http://www.eclipse.org/uml2/1.0.0/UML
> and ensuring the UML22UML resource factory is registered against whatever
> file extension you give the resource. Please try this and let us know if it
> works for you.
>
> Kenn
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f30ph5$mhb$1@build.eclipse.org...
>> Hi James,
>>
>> thanks for your help. Unfortunately it didn't help (I tried both
>> "http://www.eclipse.org/uml2/1.0.0/UML" and
>> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>>
>> Greets,
>>
>> Dominik
>>
>> James Bruck schrieb:
>>> Hi Dominik,
>>>
>>> Can you give this a quick try ...
>>>
>>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>>> 2.0.0 ).
>>> That should trigger a migration and should work then.
>>>
>>> Let me know if that works.
>>>
>>> Regards,
>>>
>>> - James.
>>>
>>>
>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>> news:f2s99h$np6$1@build.eclipse.org...
>>>> Hi there,
>>>>
>>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>>> standalone application. With the help of the migration guide and the
>>>> "Getting Started"-article I tried to figure out, how my code must look
>>>> like. But I wasn't too successful. If I don't change the exported XMI
>>>> (as attached) I can't get the model (EcoreUtil.getObjectByType() returns
>>>> null), if I change the uml namespace to
>>>>
>>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>>
>>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>>
>>>> Can anyone help please?
>>>>
>>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>>> this is okay.
>>>>
>>>> Thanks in advance,
>>>>
>>>> Dominik Raymann
>>>>
>>>
>>> ------------------------------------------------------------ ----------------
>>> ----
>>>
>>>
>>>> <?xml version="1.0" encoding="windows-1252"?>
>>>> <xmi:XMI xmi:version="2.1"
>>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>>> <xmi:Documentation exporter="Enterprise Architect"
>>>> exporterVersion="6.5"/>
>>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>>> <ownedMember xmi:type="uml:Package"
>>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>>> visibility="public">
>>>> <ownedMember xmi:type="uml:Package"
>>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>>> visibility="public">
>>>> <ownedMember xmi:type="uml:Class"
>>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>>> visibility="public">
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>>> visibility="private" isDerived="false">
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>> </ownedAttribute>
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>>> </ownedAttribute>
>>>> </ownedMember>
>>>> <ownedMember xmi:type="uml:Association"
>>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>> <ownedEnd xmi:type="uml:Property"
>>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" isOrdered="false"
>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>> </ownedEnd>
>>>> </ownedMember>
>>>> <ownedMember xmi:type="uml:Class"
>>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>>> visibility="public">
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>>> visibility="private" isDerived="false">
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>> </ownedAttribute>
>>>> </ownedMember>
>>>> <ownedMember xmi:type="uml:Class"
>>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>>> visibility="public">
>>>> <ownedAttribute xmi:type="uml:Property"
>>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>>> visibility="private" isDerived="false">
>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>> <upperValue xmi:type="uml:LiteralInteger"
>>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>> </ownedAttribute>
>>>> <generalization xmi:type="uml:Generalization"
>>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>> </ownedMember>
>>>> </ownedMember>
>>>> </ownedMember>
>>>> </uml:Model>
>>>> </xmi:XMI>
>>>>
>>>
>>> ------------------------------------------------------------ ----------------
>>> ----
>>>
>>>
>>>> /*
>>>> * Created on 21.05.2007
>>>> *
>>>> * (c) by Boxalino
>>>> */
>>>> package zzz.test;
>>>>
>>>> import java.util.Map;
>>>> import org.eclipse.emf.common.util.URI;
>>>> import org.eclipse.emf.ecore.EcorePackage;
>>>> import org.eclipse.emf.ecore.resource.Resource;
>>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>>> import org.eclipse.uml2.uml.Model;
>>>> import org.eclipse.uml2.uml.UMLPackage;
>>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>>> import com.boxalino.log.ILogger;
>>>> import com.boxalino.log.Logger;
>>>>
>>>> public class LoadUML {
>>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>>
>>>> private Model _model = null;
>>>>
>>>> public void load(String path) {
>>>>
>>>> URI furi = URI.createFileURI(path);
>>>>
>>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>>> registerPackages(RESOURCE_SET);
>>>> registerResourceFactories();
>>>>
>>>> // For a stand alone application, it is necessary to map the platform
>>>> // plugin URI scheme to the workspace location.
>>>>
>>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>>> l/"),
>>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>>> 0702141227.jar!/"));
>>>> Resource resource = null;
>>>> try {
>>>> resource = RESOURCE_SET.getResource(furi, true);
>>>> }
>>>> catch (Exception e) {
>>>> System.out.println(e.getMessage());
>>>> return;
>>>> }
>>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>>> UMLPackage.Literals.MODEL);
>>>> if (_model != null) {
>>>> System.out.println("ok");
>>>> }
>>>> else {
>>>> System.out.println("failed");
>>>> }
>>>> }
>>>>
>>>>
>>>> public static void main(String[] args) {
>>>> LoadUML uml2bom = new LoadUML();
>>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>>> }
>>>>
>>>> protected static final ResourceSet RESOURCE_SET = new ResourceSetImpl();
>>>>
>>>> protected static void registerResourceFactories() {
>>>> Map extensionFactoryMap =
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>>> UMLResource.Factory.INSTANCE);
>>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>>> Ecore2XMLResource.Factory.INSTANCE);
>>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>>> UML22UMLResource.Factory.INSTANCE);
>>>> }
>>>>
>>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>>> }
>>>>
>>>> protected static void registerPackages(ResourceSet resourceSet) {
>>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>>> Ecore2XMLPackage.eINSTANCE);
>>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>>> }
>>>>
>>>>
>>>> }
>>>>
>
Re: Load Model from Enterprise Architect [message #618178 is a reply to message #473022] Tue, 29 May 2007 21:31 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

I just tried your code (with the additional URI mapping mentioned below)
using both UML2 2.0.3 and the latest UML2 build (2.1 RC1), and was able to
successfully load the model (the result was "ok")... I don't really know
what to suggest at this point other than to try using the debugger to see
what might be happening... :(

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f3gjm8$3on$1@build.eclipse.org...
> Kenn,
>
> thanks for your help. When I change the URL of the uml-Namespace in the
> exported file manually to your suggested value, I'm getting the same error
> as before (see stack trace below). When I add an URI Converter
>
> URIConverter.URI_MAP.put(URI.createURI("http://schema.omg.org/spec/UML/2.0"),
> URI.createURI("http://www.eclipse.org/uml2/1.0.0/UML"));
>
> the resource loads but I'm unable to get the model (same behaviour as if I
> don't change the exported file and don't add this uriconverter). This
> suggests to me that my code doesn't really do what I want (because I'd
> expect the same error as in the first case). Do you see anything wrong in
> my code?
>
> Thanks a lot,
>
> Dominik
>
> stack trace:
>
> java.lang.IllegalArgumentException: The class 'Type' is not a valid
> classifier
> at
> org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.create(UML FactoryImpl.java:679)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:784)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:832)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1933)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:1907)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1783)
> at
> org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.creat eObject(UML22UMLHandler.java:67)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1561)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:881)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
> Source)
> at
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:900)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
> at zzz.test.LoadUML.load(LoadUML.java:46)
> at zzz.test.LoadUML.main(LoadUML.java:73)
>
>
>
>
> Kenn Hussey schrieb:
>> Dominik,
>>
>> I was able to successfuly load this model into the UML editor by changing
>> the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
>> resource had an extension of ".uml2". This suggests to me that it should
>> be possible to load it programmatically by adding a URI converter mapping
>> from http://schema.omg.org/spec/UML/2.0 to
>> http://www.eclipse.org/uml2/1.0.0/UML and ensuring the UML22UML resource
>> factory is registered against whatever file extension you give the
>> resource. Please try this and let us know if it works for you.
>>
>> Kenn
>>
>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>> news:f30ph5$mhb$1@build.eclipse.org...
>>> Hi James,
>>>
>>> thanks for your help. Unfortunately it didn't help (I tried both
>>> "http://www.eclipse.org/uml2/1.0.0/UML" and
>>> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>>>
>>> Greets,
>>>
>>> Dominik
>>>
>>> James Bruck schrieb:
>>>> Hi Dominik,
>>>>
>>>> Can you give this a quick try ...
>>>>
>>>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>>>> 2.0.0 ).
>>>> That should trigger a migration and should work then.
>>>>
>>>> Let me know if that works.
>>>>
>>>> Regards,
>>>>
>>>> - James.
>>>>
>>>>
>>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>>> news:f2s99h$np6$1@build.eclipse.org...
>>>>> Hi there,
>>>>>
>>>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>>>> standalone application. With the help of the migration guide and the
>>>>> "Getting Started"-article I tried to figure out, how my code must look
>>>>> like. But I wasn't too successful. If I don't change the exported XMI
>>>>> (as attached) I can't get the model (EcoreUtil.getObjectByType()
>>>>> returns
>>>>> null), if I change the uml namespace to
>>>>>
>>>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>>>
>>>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>>>
>>>>> Can anyone help please?
>>>>>
>>>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>>>> this is okay.
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Dominik Raymann
>>>>>
>>>>
>>>> ------------------------------------------------------------ ----------------
>>>> ----
>>>>
>>>>
>>>>> <?xml version="1.0" encoding="windows-1252"?>
>>>>> <xmi:XMI xmi:version="2.1"
>>>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>>>> <xmi:Documentation exporter="Enterprise Architect"
>>>>> exporterVersion="6.5"/>
>>>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>>>> <ownedMember xmi:type="uml:Package"
>>>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>>>> visibility="public">
>>>>> <ownedMember xmi:type="uml:Package"
>>>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>>>> visibility="public">
>>>>> <ownedMember xmi:type="uml:Class"
>>>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>>>> visibility="public">
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>>>> visibility="private" isDerived="false">
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>> </ownedAttribute>
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>> isOrdered="false"
>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>>>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>>>> </ownedAttribute>
>>>>> </ownedMember>
>>>>> <ownedMember xmi:type="uml:Association"
>>>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>> <ownedEnd xmi:type="uml:Property"
>>>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>> isOrdered="false"
>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>> </ownedEnd>
>>>>> </ownedMember>
>>>>> <ownedMember xmi:type="uml:Class"
>>>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>>>> visibility="public">
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>>>> visibility="private" isDerived="false">
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>> </ownedAttribute>
>>>>> </ownedMember>
>>>>> <ownedMember xmi:type="uml:Class"
>>>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>>>> visibility="public">
>>>>> <ownedAttribute xmi:type="uml:Property"
>>>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>>>> visibility="private" isDerived="false">
>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>> </ownedAttribute>
>>>>> <generalization xmi:type="uml:Generalization"
>>>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>>>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>> </ownedMember>
>>>>> </ownedMember>
>>>>> </ownedMember>
>>>>> </uml:Model>
>>>>> </xmi:XMI>
>>>>>
>>>>
>>>> ------------------------------------------------------------ ----------------
>>>> ----
>>>>
>>>>
>>>>> /*
>>>>> * Created on 21.05.2007
>>>>> *
>>>>> * (c) by Boxalino
>>>>> */
>>>>> package zzz.test;
>>>>>
>>>>> import java.util.Map;
>>>>> import org.eclipse.emf.common.util.URI;
>>>>> import org.eclipse.emf.ecore.EcorePackage;
>>>>> import org.eclipse.emf.ecore.resource.Resource;
>>>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>>>> import org.eclipse.uml2.uml.Model;
>>>>> import org.eclipse.uml2.uml.UMLPackage;
>>>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>>>> import com.boxalino.log.ILogger;
>>>>> import com.boxalino.log.Logger;
>>>>>
>>>>> public class LoadUML {
>>>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>>>
>>>>> private Model _model = null;
>>>>>
>>>>> public void load(String path) {
>>>>>
>>>>> URI furi = URI.createFileURI(path);
>>>>>
>>>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>>>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>>>> registerPackages(RESOURCE_SET);
>>>>> registerResourceFactories();
>>>>>
>>>>> // For a stand alone application, it is necessary to map the platform
>>>>> // plugin URI scheme to the workspace location.
>>>>>
>>>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>>>> l/"),
>>>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>>>> 0702141227.jar!/"));
>>>>> Resource resource = null;
>>>>> try {
>>>>> resource = RESOURCE_SET.getResource(furi, true);
>>>>> }
>>>>> catch (Exception e) {
>>>>> System.out.println(e.getMessage());
>>>>> return;
>>>>> }
>>>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>>>> UMLPackage.Literals.MODEL);
>>>>> if (_model != null) {
>>>>> System.out.println("ok");
>>>>> }
>>>>> else {
>>>>> System.out.println("failed");
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> public static void main(String[] args) {
>>>>> LoadUML uml2bom = new LoadUML();
>>>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>>>> }
>>>>>
>>>>> protected static final ResourceSet RESOURCE_SET = new
>>>>> ResourceSetImpl();
>>>>>
>>>>> protected static void registerResourceFactories() {
>>>>> Map extensionFactoryMap =
>>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>>>> UMLResource.Factory.INSTANCE);
>>>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>>>> Ecore2XMLResource.Factory.INSTANCE);
>>>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>>>> UML22UMLResource.Factory.INSTANCE);
>>>>> }
>>>>>
>>>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>>>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>>>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>>>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>>>> }
>>>>>
>>>>> protected static void registerPackages(ResourceSet resourceSet) {
>>>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>>>> Ecore2XMLPackage.eINSTANCE);
>>>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>>>> }
>>>>>
>>>>>
>>>>> }
>>>>>
>>
Re: Load Model from Enterprise Architect [message #618183 is a reply to message #473030] Wed, 30 May 2007 07:25 Go to previous message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi Kenn,

thank you very much for your efforts. It's wonderful to have such
dedicated people in a community.

I finally got the code to work. Knowing that the code works I
concentrated on the environment. I started all over, downloaded the
latest UML2 build and dependencies, copied them to a folder outside my
eclipse installation and changed my build path accordingly - et voilà -
I got an "ok".

I think I had some improper (i.e. non matching) libraries in my build
path previously, because I had two different UML2 builds (and EMF) in my
plugins directory (gosh, this directory is quite confusing).

Once more thanks to Kenn,

Dominik

Kenn Hussey schrieb:
> Dominik,
>
> I just tried your code (with the additional URI mapping mentioned below)
> using both UML2 2.0.3 and the latest UML2 build (2.1 RC1), and was able to
> successfully load the model (the result was "ok")... I don't really know
> what to suggest at this point other than to try using the debugger to see
> what might be happening... :(
>
> Kenn
>
> "Dominik Raymann" <raymi@gmx.ch> wrote in message
> news:f3gjm8$3on$1@build.eclipse.org...
>> Kenn,
>>
>> thanks for your help. When I change the URL of the uml-Namespace in the
>> exported file manually to your suggested value, I'm getting the same error
>> as before (see stack trace below). When I add an URI Converter
>>
>> URIConverter.URI_MAP.put(URI.createURI("http://schema.omg.org/spec/UML/2.0"),
>> URI.createURI("http://www.eclipse.org/uml2/1.0.0/UML"));
>>
>> the resource loads but I'm unable to get the model (same behaviour as if I
>> don't change the exported file and don't add this uriconverter). This
>> suggests to me that my code doesn't really do what I want (because I'd
>> expect the same error as in the first case). Do you see anything wrong in
>> my code?
>>
>> Thanks a lot,
>>
>> Dominik
>>
>> stack trace:
>>
>> java.lang.IllegalArgumentException: The class 'Type' is not a valid
>> classifier
>> at
>> org.eclipse.uml2.uml.internal.impl.UMLFactoryImpl.create(UML FactoryImpl.java:679)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:784)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createObject(XM LHelperImpl.java:832)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:1933)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:1907)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1783)
>> at
>> org.eclipse.uml2.uml.internal.resource.UML22UMLHandler.creat eObject(UML22UMLHandler.java:67)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1561)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:881)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
>> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
>> Source)
>> at
>> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyEle ment(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
>> Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>> at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1094)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:900)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
>> at zzz.test.LoadUML.load(LoadUML.java:46)
>> at zzz.test.LoadUML.main(LoadUML.java:73)
>>
>>
>>
>>
>> Kenn Hussey schrieb:
>>> Dominik,
>>>
>>> I was able to successfuly load this model into the UML editor by changing
>>> the namespace to http://www.eclipse.org/uml2/1.0.0/UML and ensuring the
>>> resource had an extension of ".uml2". This suggests to me that it should
>>> be possible to load it programmatically by adding a URI converter mapping
>>> from http://schema.omg.org/spec/UML/2.0 to
>>> http://www.eclipse.org/uml2/1.0.0/UML and ensuring the UML22UML resource
>>> factory is registered against whatever file extension you give the
>>> resource. Please try this and let us know if it works for you.
>>>
>>> Kenn
>>>
>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>> news:f30ph5$mhb$1@build.eclipse.org...
>>>> Hi James,
>>>>
>>>> thanks for your help. Unfortunately it didn't help (I tried both
>>>> "http://www.eclipse.org/uml2/1.0.0/UML" and
>>>> "http://schema.omg.org/spec/UML/1.0.0"). The same errors occured.
>>>>
>>>> Greets,
>>>>
>>>> Dominik
>>>>
>>>> James Bruck schrieb:
>>>>> Hi Dominik,
>>>>>
>>>>> Can you give this a quick try ...
>>>>>
>>>>> Simply try changing the nsURI to the older version ie. 1.0.0 ( not
>>>>> 2.0.0 ).
>>>>> That should trigger a migration and should work then.
>>>>>
>>>>> Let me know if that works.
>>>>>
>>>>> Regards,
>>>>>
>>>>> - James.
>>>>>
>>>>>
>>>>> "Dominik Raymann" <raymi@gmx.ch> wrote in message
>>>>> news:f2s99h$np6$1@build.eclipse.org...
>>>>>> Hi there,
>>>>>>
>>>>>> I'm trying to load a XMI generate by Enterprise Architect in a
>>>>>> standalone application. With the help of the migration guide and the
>>>>>> "Getting Started"-article I tried to figure out, how my code must look
>>>>>> like. But I wasn't too successful. If I don't change the exported XMI
>>>>>> (as attached) I can't get the model (EcoreUtil.getObjectByType()
>>>>>> returns
>>>>>> null), if I change the uml namespace to
>>>>>>
>>>>>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>>>>>>
>>>>>> I'm getting a "The class 'Type' is not a valid classifier" error.
>>>>>>
>>>>>> Can anyone help please?
>>>>>>
>>>>>> Since the xmi(uml) and my code isn't very big, I attached them. Hope
>>>>>> this is okay.
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> Dominik Raymann
>>>>>>
>>>>> ------------------------------------------------------------ ----------------
>>>>> ----
>>>>>
>>>>>
>>>>>> <?xml version="1.0" encoding="windows-1252"?>
>>>>>> <xmi:XMI xmi:version="2.1"
>>>>>> xmlns:uml="http://schema.omg.org/spec/UML/2.0"
>>>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
>>>>>> <xmi:Documentation exporter="Enterprise Architect"
>>>>>> exporterVersion="6.5"/>
>>>>>> <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
>>>>>> <ownedMember xmi:type="uml:Package"
>>>>> xmi:id="EAPK_3C702D62_7A9C_4374_993C_489493F30393" name="Model"
>>>>> visibility="public">
>>>>>> <ownedMember xmi:type="uml:Package"
>>>>> xmi:id="EAPK_D9F8706D_994D_4abb_A84B_032E407411C2" name="thePackage"
>>>>> visibility="public">
>>>>>> <ownedMember xmi:type="uml:Class"
>>>>> xmi:id="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826" name="ClassA"
>>>>> visibility="public">
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_9FAD0E08_0BE7_44bb_AD19_777E72C1571C" name="attribute1"
>>>>> visibility="private" isDerived="false">
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000001_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000002_0BE7_44bb_AD19_777E72C1571C" value="1"/>
>>>>>> </ownedAttribute>
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>>> isOrdered="false"
>>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>>> <type xmi:idref="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_DL000000_5457_4e06_89BE_8FCC155FA0C2" value="0"/>
>>>>>> <upperValue xmi:type="uml:LiteralUnlimitedNatural"
>>>>> xmi:id="EAID_DU000000_5457_4e06_89BE_8FCC155FA0C2" value="-1"/>
>>>>>> </ownedAttribute>
>>>>>> </ownedMember>
>>>>>> <ownedMember xmi:type="uml:Association"
>>>>> xmi:id="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public">
>>>>>> <memberEnd xmi:idref="EAID_dstE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>>> <memberEnd xmi:idref="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2"/>
>>>>>> <ownedEnd xmi:type="uml:Property"
>>>>> xmi:id="EAID_srcE9493D_5457_4e06_89BE_8FCC155FA0C2" visibility="public"
>>>>> association="EAID_BCE9493D_5457_4e06_89BE_8FCC155FA0C2"
>>>>> isOrdered="false"
>>>>> isDerived="false" isDerivedUnion="false" aggregation="none">
>>>>>> <type xmi:idref="EAID_8CD5082A_DFBA_450c_9B13_A3259054C826"/>
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_SL000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_SU000000_5457_4e06_89BE_8FCC155FA0C2" value="1"/>
>>>>>> </ownedEnd>
>>>>>> </ownedMember>
>>>>>> <ownedMember xmi:type="uml:Class"
>>>>> xmi:id="EAID_B429490C_F81D_4dc6_8566_749BD14313E3" name="ClassB"
>>>>> visibility="public">
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_672B99D6_50A7_4d53_AD15_58F2F563FDB2" name="attr1"
>>>>> visibility="private" isDerived="false">
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000003_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000004_50A7_4d53_AD15_58F2F563FDB2" value="1"/>
>>>>>> </ownedAttribute>
>>>>>> </ownedMember>
>>>>>> <ownedMember xmi:type="uml:Class"
>>>>> xmi:id="EAID_B0416A9C_D9F9_425d_A9F1_52936EBA268C" name="ClassC"
>>>>> visibility="public">
>>>>>> <ownedAttribute xmi:type="uml:Property"
>>>>> xmi:id="EAID_73846665_A62D_4e9a_82F8_95C30104300F" name="a1"
>>>>> visibility="private" isDerived="false">
>>>>>> <lowerValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000005_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>>> <upperValue xmi:type="uml:LiteralInteger"
>>>>> xmi:id="EAID_LI000006_A62D_4e9a_82F8_95C30104300F" value="1"/>
>>>>>> </ownedAttribute>
>>>>>> <generalization xmi:type="uml:Generalization"
>>>>> xmi:id="EAID_ED04335C_AA06_4a1d_AFEB_8D70163D850F"
>>>>> general="EAID_B429490C_F81D_4dc6_8566_749BD14313E3"/>
>>>>>> </ownedMember>
>>>>>> </ownedMember>
>>>>>> </ownedMember>
>>>>>> </uml:Model>
>>>>>> </xmi:XMI>
>>>>>>
>>>>> ------------------------------------------------------------ ----------------
>>>>> ----
>>>>>
>>>>>
>>>>>> /*
>>>>>> * Created on 21.05.2007
>>>>>> *
>>>>>> * (c) by Boxalino
>>>>>> */
>>>>>> package zzz.test;
>>>>>>
>>>>>> import java.util.Map;
>>>>>> import org.eclipse.emf.common.util.URI;
>>>>>> import org.eclipse.emf.ecore.EcorePackage;
>>>>>> import org.eclipse.emf.ecore.resource.Resource;
>>>>>> import org.eclipse.emf.ecore.resource.ResourceSet;
>>>>>> import org.eclipse.emf.ecore.resource.URIConverter;
>>>>>> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
>>>>>> import org.eclipse.emf.ecore.util.EcoreUtil;
>>>>>> import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
>>>>>> import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLResource;
>>>>>> import org.eclipse.uml2.uml.Model;
>>>>>> import org.eclipse.uml2.uml.UMLPackage;
>>>>>> import org.eclipse.uml2.uml.resource.UML22UMLResource;
>>>>>> import org.eclipse.uml2.uml.resource.UMLResource;
>>>>>> import com.boxalino.log.ILogger;
>>>>>> import com.boxalino.log.Logger;
>>>>>>
>>>>>> public class LoadUML {
>>>>>> static ILogger LOGGER = Logger.getLogger(LoadUML.class);
>>>>>>
>>>>>> private Model _model = null;
>>>>>>
>>>>>> public void load(String path) {
>>>>>>
>>>>>> URI furi = URI.createFileURI(path);
>>>>>>
>>>>> registerPathmaps(URI.createURI("jar:file:/c:/eclipse32/plugins/org.eclipse.u
>>>>> ml2.uml.resources_2.0.3.v200702141227.jar!/"));
>>>>>> registerPackages(RESOURCE_SET);
>>>>>> registerResourceFactories();
>>>>>>
>>>>>> // For a stand alone application, it is necessary to map the platform
>>>>>> // plugin URI scheme to the workspace location.
>>>>>>
>>>>> URIConverter.URI_MAP.put(URI.createURI("platform:/plugin/org.eclipse.uml2.um
>>>>> l/"),
>>>>> URI.createURI(" jar:file:/c:/eclipse32/plugins/org.eclipse.uml2.uml_2.0.3.v2 0
>>>>> 0702141227.jar!/"));
>>>>>> Resource resource = null;
>>>>>> try {
>>>>>> resource = RESOURCE_SET.getResource(furi, true);
>>>>>> }
>>>>>> catch (Exception e) {
>>>>>> System.out.println(e.getMessage());
>>>>>> return;
>>>>>> }
>>>>>> _model = (Model) EcoreUtil.getObjectByType(resource.getContents(),
>>>>> UMLPackage.Literals.MODEL);
>>>>>> if (_model != null) {
>>>>>> System.out.println("ok");
>>>>>> }
>>>>>> else {
>>>>>> System.out.println("failed");
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> public static void main(String[] args) {
>>>>>> LoadUML uml2bom = new LoadUML();
>>>>>> uml2bom.load("c:\\temp\\ea_exportpart.uml2");
>>>>>> }
>>>>>>
>>>>>> protected static final ResourceSet RESOURCE_SET = new
>>>>>> ResourceSetImpl();
>>>>>>
>>>>>> protected static void registerResourceFactories() {
>>>>>> Map extensionFactoryMap =
>>>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( );
>>>>>> extensionFactoryMap.put(UMLResource.FILE_EXTENSION,
>>>>> UMLResource.Factory.INSTANCE);
>>>>>> extensionFactoryMap.put(Ecore2XMLResource.FILE_EXTENSION,
>>>>> Ecore2XMLResource.Factory.INSTANCE);
>>>>>> extensionFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>>>>> UML22UMLResource.Factory.INSTANCE);
>>>>>> }
>>>>>>
>>>>>> protected static void registerPathmaps(URI umlResourcePluginURI) {
>>>>>> System.out.println(UMLResource.LIBRARIES_PATHMAP);
>>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
>>>>> umlResourcePluginURI.appendSegment("libraries").appendSegment( ""));
>>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
>>>>> umlResourcePluginURI.appendSegment("metamodels").appendSegment( ""));
>>>>>> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
>>>>> umlResourcePluginURI.appendSegment("profiles").appendSegment( ""));
>>>>>> }
>>>>>>
>>>>>> protected static void registerPackages(ResourceSet resourceSet) {
>>>>>> Map packageRegistry = resourceSet.getPackageRegistry();
>>>>>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>>>>>> packageRegistry.put(Ecore2XMLPackage.eNS_URI,
>>>>>> Ecore2XMLPackage.eINSTANCE);
>>>>>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> }
>>>>>>
>
>
Re: Load Model from Enterprise Architect [message #618308 is a reply to message #473035] Wed, 30 May 2007 12:43 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

Glad to have been able to help the little that I did. Taking a second look
at what I did last night to get it to work, I realize that I had a changed
the namespace URI in the file to http://www.eclipse.org/uml2/1.0.0/UML (as
originally suggested by James), which means that the extra URI mapping isn't
needed after all (not sure why the mapping isn't consulted before looking up
the package)...

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f3j8uu$l94$1@build.eclipse.org...
> Hi Kenn,
>
> thank you very much for your efforts. It's wonderful to have such
> dedicated people in a community.
>
> I finally got the code to work. Knowing that the code works I concentrated
> on the environment. I started all over, downloaded the latest UML2 build
> and dependencies, copied them to a folder outside my eclipse installation
> and changed my build path accordingly - et voil
Re: Load Model from Enterprise Architect [message #619676 is a reply to message #473038] Mon, 04 June 2007 08:03 Go to previous message
Dominik Raymann is currently offline Dominik RaymannFriend
Messages: 37
Registered: July 2009
Member
Hi, it's me again :-)

two more questions:

Is it a bug that the additional URI-Mapper to
"http://www.eclipse.org/uml2/1.0.0/UML" isn't considered? Since I want
to import the XMI from EA automatically (without prior manual changes
needed), I now have to change the wrong namespace by opening the file
and replacing the uri (which isn't exactly very elegant). So someone
should report this as a bug?

Secondly, EA inserts an extension to the XMI, which is introduced by

<xmi:Extension extender="Enterprise Architect" extenderID="6.5">

If the XMI contains this tag, I get the following error:

org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'null' is not
legal. (file:/c:/temp/tempXMI.uml2, 130, 18)

(with 130, 18 being in the extension section)

I think the extension tag should be read (and re-written if saved again)
without any further parsing so I dont't understand this exception.

Dominik

Kenn Hussey schrieb:
> Dominik,
>
> Glad to have been able to help the little that I did. Taking a second look
> at what I did last night to get it to work, I realize that I had a changed
> the namespace URI in the file to http://www.eclipse.org/uml2/1.0.0/UML (as
> originally suggested by James), which means that the extra URI mapping isn't
> needed after all (not sure why the mapping isn't consulted before looking up
> the package)...
>
> Kenn
>
Re: Load Model from Enterprise Architect [message #621667 is a reply to message #473088] Wed, 13 June 2007 14:06 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Dominik,

Sorry for the delayed response.

I'm not sure it's a bug that a package URI isn't normalized before the
extended metadata is used to look it up in the package registry... but it
might make sense to enhance EMF to do this, so feel free to open an
enhancement request against EMF for the next release.

I would have expected the XMLResource.OPTION_RECORD_UNKNOWN_FEATURE load
option (which is set by default for UML2 resources) to handle extensions as
unrecognized data... I know that this handling of extensions works for the
XMI interchange resource implementation in UML2, but it only supports
interchange based on UML 2.1.1. It should be possible to take what's
provided in UML2 (a combination of resource and extended metadata
implementations) and modify/enhance it for your situation. The problem here
is that you're trying to do two things at once - interchange (from a
"standard" format for UML 2.0) and migration (from UML2 1.x to 2.x)...

Kenn

"Dominik Raymann" <raymi@gmx.ch> wrote in message
news:f40h0l$3t8$1@build.eclipse.org...
> Hi, it's me again :-)
>
> two more questions:
>
> Is it a bug that the additional URI-Mapper to
> "http://www.eclipse.org/uml2/1.0.0/UML" isn't considered? Since I want to
> import the XMI from EA automatically (without prior manual changes
> needed), I now have to change the wrong namespace by opening the file and
> replacing the uri (which isn't exactly very elegant). So someone should
> report this as a bug?
>
> Secondly, EA inserts an extension to the XMI, which is introduced by
>
> <xmi:Extension extender="Enterprise Architect" extenderID="6.5">
>
> If the XMI contains this tag, I get the following error:
>
> org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'null' is not
> legal. (file:/c:/temp/tempXMI.uml2, 130, 18)
>
> (with 130, 18 being in the extension section)
>
> I think the extension tag should be read (and re-written if saved again)
> without any further parsing so I dont't understand this exception.
>
> Dominik
>
> Kenn Hussey schrieb:
>> Dominik,
>>
>> Glad to have been able to help the little that I did. Taking a second
>> look at what I did last night to get it to work, I realize that I had a
>> changed the namespace URI in the file to
>> http://www.eclipse.org/uml2/1.0.0/UML (as originally suggested by James),
>> which means that the extra URI mapping isn't needed after all (not sure
>> why the mapping isn't consulted before looking up the package)...
>>
>> Kenn
>>
Previous Topic:heavyweight extension in OMG specifications
Next Topic:How to specify those operations to be run in a transition?
Goto Forum:
  


Current Time: Thu Apr 18 23:15:42 GMT 2024

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

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

Back to the top