[ATL] Problem when loading UML Profile programmatically for ATL transformation [message #533754] |
Sun, 16 May 2010 18:03 |
Eclipse User |
|
|
|
Hi,
I've a problem with my source code for starting an ATL transformation programmatically whithin Eclipse.
The basis for the transformation is simply an input model which is a UML Profile.
This is the code I currently have:
public class Test {
public static void main(String[] args){
// Initial Setup
try {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
//ILauncher launcher = CoreService.getLauncher("Regular VM (with debugger)");
ILauncher launcher = new EMFVMLauncher();
//ModelFactory factory = CoreService.createModelFactory(launcher.getDefaultModelFactoryName());
ModelFactory factory = new EMFModelFactory();
//IInjector injector = CoreService.getInjector(factory.getDefaultInjectorName());
IInjector injector = new EMFInjector();
//IExtractor extractor = CoreService.getExtractor(factory.getDefaultExtractorName());
//metamodels
final IReferenceModel umlMetamodel = factory.newReferenceModel();
injector.inject(umlMetamodel, "http://www.eclipse.org/uml2/3.0.0/UML");
// final IReferenceModel mpMetaModel = factory.newReferenceModel();
// Creating models
IModel eadlProfile = factory.newModel(umlMetamodel);
IModel myEadl = factory.newModel(umlMetamodel);
//load the input-file
injector.inject(eadlProfile, "file:/C:/east.profile.uml");
Map<String, Object> options = new HashMap<String, Object>();
options.put("allowInterModelReferences", "true");
options.put("profile", "true");
options.put("supportUML2Stereotypes", "true");
// Getting launcher
launcher.initialize(options);
// Launching
launcher.addInModel(eadlProfile,"IN2","EADLPROFILE");
launcher.addOutModel(myEadl, "OUT", "MYEADL");
//launcher.addLibrary("HelperFunctions", launcher.loadModule(asmF));
IFile currentAtlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromOSString("C:/rif2eadl.asm"));
InputStream asmInputStream = null;
try {
asmInputStream = currentAtlFile.getContents();
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStream[] modules = new InputStream[1];
modules[0] = asmInputStream;
launcher.launch(ILauncher.RUN_MODE,
new NullProgressMonitor(),
options,
(Object[])modules);
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
}
}
}
The problem is that the main method stops with an error at the line, where the east.profile.uml file will be loaded/injected.
The error message is:
Quote: |
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/uml2/schemas/Ecore/5' not found. (file:/C:/east.profile.uml, 8029, 198)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2590)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2421)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
... 4 more
|
When I start the ATL transformation via the Eclipse ATL Launch Configuration Wizard, the problem does not occur.
Does anyone know, how to solve the problem? If more informations are needed, please ask me.
Thanks in advance, Helko
|
|
|
|
|
Re: [ATL] Problem when loading UML Profile programmatically for ATL transformation [message #534480 is a reply to message #533754] |
Wed, 19 May 2010 10:30 |
Eclipse User |
|
|
|
Hello,
I've solved the problem:
ResourceSet rss = ((EMFModelFactory)umlMetamodel.getModelFactory()).getResourceSet();
rss.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
rss.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI, URI> uriMap2 = rss.getURIConverter().getURIMap();
URI uri = URI.createURI("jar:file:/D:/.../eclipse/plugins/org.eclipse.uml2.uml.resources_3.0.0.v200906011111.jar!/");
uriMap2.put(
URI.createURI(UMLResource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));
uriMap2.put(
URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));
uriMap2.put(
URI.createURI(UMLResource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));
rss.getPackageRegistry().put(EastadlPackage.eNS_URI,EastadlPackage.eINSTANCE);
rss.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Hope that helps.
But know, I have a pfroblem with applying UML Profile Stereotypes to UML elements ... see my new post (in a few minutes
Best regards, Helko
|
|
|
Powered by
FUDForum. Page generated in 0.03445 seconds