RMF is currently not able to resolve proxies if the ReqIFResource is not contained in a ReqIFResourceSetImpl.
Please note, that RMF doesn't resolve proxies during load time: RMF uses lazy proxy resolution (resolve proxies when non-containment references are actually navigated).
I have created a small example that demonstrates how to invoke a QVTO transformation on a ReqIF model. Please invoke as JUnit plugin test.
(The original code was found on the QVT Operational Wiki page).
In addition to the code given in this email, please find attached a working example project (Eclipse Juno) that translates all SpecObjects of a reqif file to EClasses.
package org.eclipse.rmf.qvto.tests;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.m2m.qvt.oml.BasicModelExtent;
import org.eclipse.m2m.qvt.oml.ExecutionContextImpl;
import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
import org.eclipse.m2m.qvt.oml.ModelExtent;
import org.eclipse.m2m.qvt.oml.TransformationExecutor;
import org.eclipse.rmf.serialization.ReqIFResourceSetImpl;
import org.junit.Test;
public class TransformationTests {
@Test
public void test() throws IOException {
// Refer to an existing transformation via URI
URI transformationURI = URI.createPlatformPluginURI("/org.eclipse.rmf.qvto.tests/transforms/Transformation.qvto",true);
// create executor for the given transformation
TransformationExecutor executor = new TransformationExecutor(transformationURI);
// define the transformation input
// Remark: we take the objects from a resource, however
// a list of arbitrary in-memory EObjects may be passed
ResourceSet resourceSet = new ReqIFResourceSetImpl();
Resource inResource = resourceSet.getResource(
URI.createFileURI("input/input.reqif"), true);
EList<EObject> inObjects = inResource.getContents();
// create the input extent with its initial contents
ModelExtent input = new BasicModelExtent(inObjects);
// create an empty extent to catch the output
ModelExtent output = new BasicModelExtent();
// setup the execution environment details ->
// configuration properties, logger, monitor object etc.
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("keepModeling", true);
// run the transformation assigned to the executor with the given
// input and output and execution context -> ChangeTheWorld(in, out)
// Remark: variable arguments count is supported
ExecutionDiagnostic result = executor.execute(context, input, output);
// check the result for success
if(result.getSeverity() == Diagnostic.OK) {
// the output objects got captured in the output extent
List<EObject> outObjects = output.getContents();
// let's persist them using a resource
ResourceSet resourceSet2 = new ResourceSetImpl();
Resource outResource = resourceSet2.createResource(
URI.createFileURI("output/output.ecore"));
outResource.getContents().addAll(outObjects);
outResource.save(Collections.emptyMap());
} else {
// turn the result diagnostic into status and send it to error log
IStatus status = BasicDiagnostic.toIStatus(result);
System.err.println(status.toString());
}
}
}