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 #617170] Mon, 21 May 2007 14:10
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--
Previous Topic:uml editor -> InstanceSpecification
Next Topic:Problem creating LinkEndData and LinkEndDestructionData
Goto Forum:
  


Current Time: Fri Apr 26 12:17:59 GMT 2024

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

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

Back to the top