Performing queries in KDM with OCL [message #1748398] |
Tue, 22 November 2016 13:01  |
Eclipse User |
|
|
|
Hello,
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;
then,
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?
Thanks,
Daniel
|
|
|
Re: Performing queries in KDM with OCL [message #1748399 is a reply to message #1748398] |
Tue, 22 November 2016 13:12  |
Eclipse User |
|
|
|
Hi
If you are already using Xtend, I cannot really recommend that you add non-trivial complexity to your project by using OCL as well. You should really identify why you cannot solve the problem with Xtend, or more simply just Java. You seem to be running away from a 2-hour debugging problem by introducing a 2-week familiarization/releng problem.
Of course, if you need OCL for other reasons, ignore the criticism above. You may find it helpful to use OCLinEcore to enrich your metamodel internally or Complete OCL externally. Read the tutorials. Whichever, I would recommend the new PIvot-based OCL that amongst many other improvements avoids the needs for long Java template parameter lists.
Regards
Ed Willink
|
|
|
Powered by
FUDForum. Page generated in 0.19866 seconds