Executing query standalone mode and retrieve results [message #1809487] |
Tue, 16 July 2019 18:37 |
Daniel San Martín Messages: 45 Registered: October 2012 |
Member |
|
|
Hello,
I am trying to perform a simple transformation in standalone mode but nothing happens. This is my code:
//Load XMI
URI uri = URI.createFileURI("Resource/XYZ.xmi");
KdmPackage.eINSTANCE.eClass();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(uri);
resource.load(null);
//Load qvto file and execute the transformation
URI transformationURI = URI.createFileURI(new File("QVT/queries.qvto").getAbsolutePath());
TransformationExecutor executor = new TransformationExecutor(transformationURI);
EList<EObject> inObjects = resource.getContents();
ModelExtent input = new BasicModelExtent(inObjects);
ModelExtent output = new BasicModelExtent();
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("modelName", new String("Model_Name"));
ExecutionDiagnostic result = executor.execute(context, input, output);
if(result.getSeverity() == Diagnostic.OK)
{
List<EObject> outObjects = output.getContents();
System.out.println(outObjects);
}else
System.out.println(result.getSeverity());
The .qvto file:
modeltype kdm "strict" uses kdm('http://www.eclipse.org/MoDisco/kdm/kdm');
modeltype code "strict" uses code('http://www.eclipse.org/MoDisco/kdm/code');
modeltype action "strict" uses action('http://www.eclipse.org/MoDisco/kdm/action');
modeltype source "strict" uses source('http://www.eclipse.org/MoDisco/kdm/source');
modeltype structure "strict" uses structure('http://www.eclipse.org/MoDisco/kdm/structure');
transformation ModelCode(in sourceModel:kdm, out targetModel:kdm);
main() {
sourceModel.objectsOfType(StructureModel)-> getListOfComponent();
}
query StructureModel::getListOfComponent() : Set(Component) {
return Component.allInstances();
}
How can I manipulate the results of the qvto query in java?
Regards,
Daniel.
[Updated on: Tue, 16 July 2019 19:59] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05617 seconds