Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Executing QVTo Programmatically
Executing QVTo Programmatically [message #1407011] Mon, 11 August 2014 16:55
Sama Elrawy is currently offline Sama ElrawyFriend
Messages: 9
Registered: February 2014
Junior Member

I'm trying to execute a QVTo transformation using Java where I have 2 xmi files as an input and another xmi file as an output.

My problem is how to define 2 input xmi files? and how to register the xmi package?

For example, If I'm registering UML, I should use this line of code:
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

What about XMI?

Here is the full code that I currently have:
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put("", new XMIResourceFactoryImpl());
		ExecutionContextImpl context= new ExecutionContextImpl();
		context.setConfigProperty("keepModeling", true);
		URI transformationURI = URI.createURI("file:///C:/Users/sama.elrawy/EclipsJEEworkspace/Multi_project/transforms/multi_generation.qvto");
		TransformationExecutor executor = new TransformationExecutor(transformationURI);
		ResourceSet resourceSet = new ResourceSetImpl();

		resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
		Resource inResource = resourceSet.getResource(URI.createURI("file:///C:/Users/sama.elrawy/EclipsJEEworkspace/Multi_project/models/input1.xmi"), true);		
		EList<EObject> inObjects = inResource.getContents();
		ModelExtent input = new BasicModelExtent(inObjects);		
		ModelExtent output = new BasicModelExtent();
		ExecutionDiagnostic result = executor.execute(context, input, output);

		if(result.getSeverity() == Diagnostic.OK) {
			List<EObject> outObjects = output.getContents();
		        ResourceSet resourceSet2 = new ResourceSetImpl();
			Resource outResource = resourceSet2.getResource(
			URI.createURI("file:///C:/Users/sama.elrawy/EclipsJEEworkspace/Multi_project/models/output.xmi"), true);
Previous Topic:Executing QVTo Programmatically
Next Topic:Executing QVTo in java
Goto Forum:

Current Time: Sun Jul 14 02:04:43 GMT 2024

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

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

Back to the top