[query2] How may I do a query on attribute values using regexp? [message #656179] |
Thu, 24 February 2011 08:22  |
Eclipse User |
|
|
|
Hi all
I'm new on modeling with EMF .
I need to do a search on string attribute values using regexp and case sensitive flag.
I have discovered the Model Query2 framework but from its guide (http://wiki.eclipse.org/EMF/Query2/DevGuide) I cannot figure out how to use regular expressions.
It seems that the Model Query framework has a regexp support and from Query2 project page (http://www.eclipse.org/modeling/emf/?project=query2) I read:
Quote: |
Query2 supports multiple ways to specify queries.
1. User can use APIs for the basic EObject based Condition objects that are used to formulate queries for EMF models.
|
Unfortunately I haven't found a way to use Condition objects along with the index support.
Any suggestion about using Query2 for searching strings using regexp?
Thanx
Fabrizio
|
|
|
|
|
|
Re: [query2] How may I do a query on attribute values using regexp? [message #656365 is a reply to message #656351] |
Fri, 25 February 2011 05:10  |
Eclipse User |
|
|
|
Fabrizio Casali wrote on Fri, 25 February 2011 04:19 | Thank you for your kind reply.
It's a useful hint, but it raises new questions.
You have mentioned a "query editor": do you mean that the Query2 plugin comes with its own editor?
| Yes
Quote: | If so how can I use it?
| You can create a .query file in your workspace, provided the following plugins are present in your development workspace.
org.eclipse.emf.query2.stringsyntax.ui
org.eclipse.emf.query2.stringsyntax.tools.ui
org.eclipse.emf.query2.stringsyntax
You could then import your the namespace URI of the epackage, as the first line, which will be followed by queries, like below
import "http://eclipse.org/modeling/emf/query/1.0.0"
AllPersonNoJoinsAndNoNests:
from Person withoutsubtypes as p
select p where p.name like 'kolb*'
You could then run the query using the context menu, and selecting the query---->Run Query.
Alternatively you could open Query View where all the queries will be listed, you can execute the queries from there.
Quote: | What wild-char are supported other then *?
|
Presently only * is supported.
Quote: |
I need to generate queries dynamically. If I opt for the object base query format I cannot use patterns delimited by single quotes, so how can I switch to and from a case sensitive query? Alternatively, the sql format allows parameters in queries?
|
Sorry, that was a mistake from my side, in the object based query format,
you will have to specify the pattern within double quotes.
Also, it is possible to use parameters in queries, and replace them accordingly in your implementation.
You could refer to the below link for details on it.
http://www.eclipse.org/forums/index.php?t=msg&th=198593& amp; amp;start=0&S=6611ff721c0273e3462494026d3f04e9
Regards,
Manasa
[Updated on: Fri, 25 February 2011 05:13] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04644 seconds