|Performing queries in KDM with OCL [message #1748398]
||Tue, 22 November 2016 18:01
| Daniel San Martín
Registered: October 2012
I want to generate java code from a KDM model (ECore type) with xtend. I can do that with this method in xtext project.
override doGenerate(Resource resource, IFileSystemAccess fsa)
Nevertheless, the KDM model has an hierarchical structure so I cannot access to certain elements of the model, for example ClassUnits elements.
I thought to use this line:
for (ClassUnit classUnit : resource.contents.filter(typeof(ClassUnit)))
but returns null. Thus, I think to performs queries over the model. I think the best solution is to use OCL but i have some problems to setup it in my plugin.
My idea is to perform the query by using resource variable because it contains the model, but I do not how to do this.
I tried some codes from eclipse help
private OCL ocl;
private OCLHelper<EClassifier, ?, ?, Constraint> helper;
this.ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
this.helper = ocl.createOCLHelper();
I have problem with this.. I tried with EcorePackage.eINSTANCE but does not work..
How can I run OCL queries by taking into account my resources variable with the model in memory?
Powered by FUDForum
. Page generated in 0.01630 seconds