Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Problem when loading UML Profile programmatically for ATL transformation
[ATL] Problem when loading UML Profile programmatically for ATL transformation [message #533754] Sun, 16 May 2010 18:03 Go to next message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009

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);
			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());
		final IReferenceModel umlMetamodel = factory.newReferenceModel();
		injector.inject(umlMetamodel, "");
//		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
		// Launching
		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
		InputStream[] modules = new InputStream[1];
		modules[0] = asmInputStream;
						new NullProgressMonitor(), 
		} catch (Exception e) {

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:


Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri '' not found. (file:/C:/east.profile.uml, 8029, 198)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa
at .startElement(Unknown Source)
at ntParser.emptyElement(Unknown Source)
at Impl.scanStartElement(Unknown Source)
at cannerImpl$ Source)
at Source)
at Source)
at cannerImpl.scanDocument(Unknown Source)
at n.parse(Unknown Source)
at n.parse(Unknown Source)
at nknown Source)
at .parse(Unknown Source)
at$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
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(
... 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 #534444 is a reply to message #533754] Wed, 19 May 2010 08:49 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member

HI, Helko

Did you soleve your problem, because i have the same, its like the programmedont know the Eoperation stuff, its transform just the Eattribute. Sad

Re: [ATL] Problem when loading UML Profile programmatically for ATL transformation [message #534451 is a reply to message #533754] Wed, 19 May 2010 09:16 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Have you tried to inject the UML metamodel as an EMF resource ?

injector.inject(umlMetamodel, resourceSet.getResource(URI.createURI(""), false));
icon14.gif  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 Go to previous message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009

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!/");
		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 Smile

Best regards, Helko
Previous Topic:QVT-R Resource Implementation
Next Topic:[QVTo] How to determine <unset> Integer
Goto Forum:

Current Time: Wed Apr 21 22:05:44 GMT 2021

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

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

Back to the top