Home » Archived » EMF-IncQuery » IncQuery for RCP Applications
IncQuery for RCP Applications [message #1686262] |
Thu, 19 March 2015 01:41  |
Eclipse User |
|
|
|
Hello,
I am working on project where I have several ecore model files. The ecore files are used to create model instances called artifacts which make up the core part of an RCP application. My objective is to query the artifacts of a running RCP application using Incquery.
I followed the following URLs on how to use Incquery for RCP applications.
incquery.net/node/110
wiki.eclipse.org/EMFIncQuery/UserDocumentation/API
Following is the code snippet which causes the error
URI fileURI = URI.createFileURI(modelPath);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(fileURI, true);
IncQueryEngine engine = IncQueryEngine.on(resource);
PicklistObjectMatcher matcher = PicklistObjectMatcher.on(engine);
PicklistObjectMatcher is the auto-generated class.
modelpath variable = Tried by passing the path ecore file and the path of the xml file of the ecore instance.
However, as soon as I run the above code I face the following Exception.
77890 [main] FATAL org.eclipse.incquery.runtime.1079648883 - EMF-IncQuery Base encountered an error while traversing the EMF model to gather new information.
org.eclipse.incquery.runtime.rete.construction.RetePatternBuildException: Error during constructing Rete pattern matcher; please review Error Log and consult developers
at org.eclipse.incquery.runtime.internal.matcherbuilder.EPMBuilder.construct(EPMBuilder.java:59)
at org.eclipse.incquery.runtime.internal.matcherbuilder.EPMBuilder.construct(EPMBuilder.java:1)
at org.eclipse.incquery.runtime.rete.boundary.ReteBoundary.construct(ReteBoundary.java:524)
at org.eclipse.incquery.runtime.rete.boundary.ReteBoundary.accessProduction(ReteBoundary.java:456)
at org.eclipse.incquery.runtime.rete.matcher.ReteEngine$1.call(ReteEngine.java:177)
at org.eclipse.incquery.runtime.rete.matcher.ReteEngine$1.call(ReteEngine.java:1)
at org.eclipse.incquery.runtime.base.core.NavigationHelperImpl.coalesceTraversals(NavigationHelperImpl.java:938)
at org.eclipse.incquery.runtime.internal.EMFPatternMatcherRuntimeContext.coalesceTraversals(EMFPatternMatcherRuntimeContext.java:194)
at org.eclipse.incquery.runtime.rete.matcher.ReteEngine.constructionWrapper(ReteEngine.java:225)
at org.eclipse.incquery.runtime.rete.matcher.ReteEngine.accessMatcher(ReteEngine.java:173)
at org.eclipse.incquery.runtime.api.impl.BaseMatcher.accessMatcher(BaseMatcher.java:76)
at org.eclipse.incquery.runtime.api.impl.BaseMatcher.<init>(BaseMatcher.java:65)
at uitemplate.PicklistObjectMatcher.<init>(PicklistObjectMatcher.java:91)
at uitemplate.PicklistObjectMatcher.on(PicklistObjectMatcher.java:55)
at com.emc.xcp.query.engine.plugin.IncQueryHeadless.executeDemo(IncQueryHeadless.java:70)
at com.emc.xcp.query.engine.plugin.RunnerHandler.execute(RunnerHandler.java:58)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at internal.com.emc.xcp.builder.ui.workbench.XcpApplication.start(XcpApplication.java:29)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
I have tried various ways to create the matcher but unfortunately did not succeed.
I have the following doubts:
(1). Can you help me understand why am I not able to instantiate the matcher and facing these exceptions ?
(2).
URI fileURI = URI.createFileURI(modelPath);
Resource resource = resourceSet.getResource(fileURI, true);
In the above snippet, modelPath refers to the ecore file of the model or the model instance i.e. the xml file ?
(3). In the example found in the documentation, a parameter called patternFNQ is used.
Can you tell what is parameter is ?
And why pattern explicitly needs to be passed since the autogenerated matcher class is created out of the pattern only ?
Link of example where pattern is used: incquery.net/node/110
|
|
|
Re: IncQuery for RCP Applications [message #1687038 is a reply to message #1686262] |
Thu, 19 March 2015 09:18   |
Eclipse User |
|
|
|
Hi,
(1) in general, the code snippet you have shown should be working, unless there is something unexpected in either the (compiled) pattern definition or the model. I would like you to look whether there is anything the either EMF-IncQuery itself reports in the development environment, or there is some more detailed log available from your application. There can be multiple causes that might result in this feature not working, but it is almost certainly either a configuration or compilation error. I can try helping figuring out, what happened, but I need some additional information, e.g. more detailed log, or source code that reproduces the issue itself, the version of EMF-IncQuery used.
(2) Yes, modelPath refers to the instance model file.
(3) In the incquery.net page, that uses an older version of EMF-IncQuery, the example there is not up-to-date. Use instead the Headless example from the wiki, that uses the generated patterns. The goal of using the fqn is to define generic code that handles different queries together generically; but if you want only to use specific queries, the generated API is a much better solution.
Cheers,
Zoltán
|
|
| |
Re: IncQuery for RCP Applications [message #1687262 is a reply to message #1687222] |
Thu, 19 March 2015 11:29   |
Eclipse User |
|
|
|
Hi,
(1) that discussion concerns with EMF-IncQuery versions prior to 0.8.0, as since that release it is possible to execute queries with EMF-IncQuery; however in case of RCP applications it should work out-of-the-box with EMF-IncQuery 0.7.0 as well.
(2) This trace is much more helpful, as it contains the root cause: for some reason, an EReference is found that has no EPackage attribute set, which means more than likely there is an issue with accessing the metamodel. I would check the following things:
a) Is the metamodel project added to your RCP application?
b) Is your metamodel correctly registered? More specifically, in the plugin.xml of your metamodel project, there should be an extension of the extension point "org.eclipse.emf.ecore.generated_package"; please check whether its parameters are set up correctly, e.g. in synch with the metamodel itself (in case of moving the generated metamodel code, or changing the nsURI this often gets incorrect).
c) Is there any error message present in the log related to unloadable plug-ins (e.g. missing dependencies).
Finally, I would like to ask whether there is a reason for using version 0.7.0 of EMF-IncQuery, instead of 0.8 (released in June 2014) or 0.9 (relesed in Feb 2015), that feature several performance and usability enhancements over the 0.7 series (relesed in June 2013). If not, I would recommend updating it to a more current version.
Cheers,
Zoltán
|
|
| |
Re: IncQuery for RCP Applications [message #1689441 is a reply to message #1689430] |
Mon, 23 March 2015 11:33   |
Eclipse User |
|
|
|
Hi,
about the original problem, I am out of ideas without seeing/debugging the code, sorry. However, if you could either provide me with the code, or give a reproducible example, I would be glad to look into it.
About the update issues, we changed the runtime API quite a bit in 0.8.0, but provided an updater tool for existing projects. Basically, right-click your IncQuery project, and select "Update/Add EMF-IncQuery Nature" from the "Configure" submenu. See also https://wiki.eclipse.org/EMFIncQuery/Releases/MigrateTo0.8
Cheers,
Zoltán
|
|
|
Re: IncQuery for RCP Applications [message #1690085 is a reply to message #1689441] |
Wed, 25 March 2015 04:01   |
Eclipse User |
|
|
|
Hi,
I am using Incquery 0.8.1 with xText 2.6 and Eclipse Emf 2.10.2
The problem is the same as described above. As soon as I create a pattern, there are errors in the generated code.
I used the updater tool. But I created the project in Incquery 0.8.1 only and updater tool is used to migrate projects written using 0.7 version to 0.8 version. (Correct me if I'm wrong here)
Below is the link to the Incquey Project and ecore model.
github.com/Harkirat94/query-rcp-app
I have some doubts:
(1). Is generated class <patternname>QuerySpecification.java supposed to implement these methods ?
public IPatternMatch newEmptyMatch() { }
public IPatternMatch newMatch(Object... parameters) { }
public String getFullyQualifiedName() { }
public List<PParameter> getParameters() { }
protected Set<PBody> doGetContainedBodies() throws IncQueryException { }
If yes, then why they are not implemented ?
If it is not supposed to implement them, why the methods are declared in the base class?
(2). Methods getBundleName() and patternName() in the <patternname>QuerySpecification.java have @Override annotation but they are not declared in any of the Base classes. So they are reported as errors.
(3). I checked, the reference to the Base classes are done from proper Jars. (as in all base classes are referenced from jars of version 0.8.1).
I was not able to find the 0.9 version on the site. The integration build in the Eclipse site: www.eclipse.org/incquery/download.php is still an older version: 0.7.1
Could you suggest any particular stable working version I could use ?
Note 1: The same errors are reported in version 0.8.0 and 0.8.1. Only when these errors are resolved I will be able to proceed further to create the IncqueryEngine in which I faced the problem due to which I started this discussion.
Note 2: The RCP application I am working on is licensed. So, I have made a sample ecore model. Since, the problem concerns at the time of writing the pattern and at the time of auto-generated classes and ecore model is not traversed at this moment, so I don't think the complexity of ecore model is of concern. Correct me if I am wrong.
It would be very grateful if you could look into this matter and help me so that I could start working on querying model from within an RCP application.
Thank you.
[Updated on: Wed, 25 March 2015 04:05] by Moderator
|
|
|
Re: IncQuery for RCP Applications [message #1690737 is a reply to message #1690085] |
Mon, 30 March 2015 18:48   |
Eclipse User |
|
|
|
Hi,
first of all, I want to apologize for not getting back earlier, but I had some things to do in the meanwhile, and I almost forgotten about your post.
I downloaded your example in a new environment with EMF-IncQuery 0.8.1, and I was able to notice your issues. The missing method issues can be fixed by running the project updater: right click on the project, and select Configure/Update EMF-IncQuery nature. It changes the dependencies and builder settings a bit to accomodate for the new changes in version 0.8.0; for projects created in (or after) version 0.8.0, the new layout is used.
However, after that, some issues still remain: the code generator was having issues with the main EMF Package having the same name as the class referred by the query; more specifically, it was having trouble with the class 'Picklist.model.picklist.Picklist'. I have opened a bug for it in bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=463525; as a workaround I'd suggest renaming the 'base package' in the EMF generator model to 'picklist.model'; that solved the compile errors to me.
After compiling the project, I have adapted the headless application from the incquery example to run this single query, and it worked to me as expected. I have put my version of the projects online in a clone of your repository: https://github.com/ujhelyiz/query-rcp-app
Finally, thank you for reminding me of not putting out a downloadable zip file for IncQuery 0.9.0 onto the download site. We will get it out shortly.
I hope, these results are helpful, and sorry again for the answer to take this long.
Cheers,
Zoltán
|
|
| | |
Goto Forum:
Current Time: Wed Jul 16 10:33:02 EDT 2025
Powered by FUDForum. Page generated in 0.06970 seconds
|