Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Executing query standalone mode and retrieve results(Get empty List)
Executing query standalone mode and retrieve results [message #1809487] Tue, 16 July 2019 18:37 Go to next message
Daniel San Martín is currently offline Daniel San MartínFriend
Messages: 44
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

Re: Executing query standalone mode and retrieve results [message #1809756 is a reply to message #1809487] Mon, 22 July 2019 16:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6934
Registered: July 2009
Senior Member
Hi

If you want help, you really need to provide a complete project so that I can see all the things that you might have done wrong. You should also simplify it to avoid using metamodels that anyone trying to help you may not have available. I do not have Modisco installed.

Possibly you have no input model or no Component instances in your input model. I see no reason why the result of your query that is invoked as a mapping should work. It is usually appropriate to assign something to some form of result/return object. I suggest you study Simpleuml_To_Rdb.qvto.

(As a general principle, use of allInstances() is nearly always the least efficient approach to solving a problem with typical practical OCL tooling.)

Regards

Ed Willink

Re: Executing query standalone mode and retrieve results [message #1810203 is a reply to message #1809756] Sun, 04 August 2019 03:26 Go to previous message
Daniel San Martín is currently offline Daniel San MartínFriend
Messages: 44
Registered: October 2012
Member
Thank you Ed. This issue was resolved.
Previous Topic:Announce QVTo 3.9.2
Next Topic:UML activity diagram to Simulink
Goto Forum:
  


Current Time: Mon Nov 30 01:21:28 GMT 2020

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

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

Back to the top