Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [query2] How may I do a query on attribute values using regexp?([query2] How may I do a query on attribute values using regexp?)
[query2] How may I do a query on attribute values using regexp? [message #656179] Thu, 24 February 2011 13:22 Go to next message
Fabrizio Casali is currently offline Fabrizio CasaliFriend
Messages: 2
Registered: February 2011
Junior Member
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 #656317 is a reply to message #656179] Fri, 25 February 2011 05:43 Go to previous messageGo to next message
manasa  is currently offline manasa Friend
Messages: 32
Registered: October 2010
Member
Hi,

You can do a search on string attribute values using an SQL like syntax using wild characters in query editor like below.

AllPersonNoJoinsAndNoNests:
from Person withoutsubtypes as p
select p where p.name like 'kolb*'.

Also the characters within single quotes are case sensitive.

Also the same can be achieved in object based query format, using the operation like,

WhereString whereClause =  new WhereString("title",org.eclipse.emf.query2.Operation.LIKE, 'Linus Made*');
		LocalWhereEntry localWhereEntry = new LocalWhereEntry("m", whereClause);


Hope this helps for your issue.

Regards,
Manasa

Re: [query2] How may I do a query on attribute values using regexp? [message #656320 is a reply to message #656179] Fri, 25 February 2011 05:55 Go to previous messageGo to next message
manasa  is currently offline manasa Friend
Messages: 32
Registered: October 2010
Member
Hi,

You can do a search on string attribute values using an SQL like syntax using wild characters in query editor like below.

AllPersonNoJoinsAndNoNests:
from Person withoutsubtypes as p
select p where p.name like 'kolb*'.

Also the characters within single quotes are case sensitive.

Also the same can be achieved in object based query format, using the operation like,

WhereString whereClause =  new WhereString("title",org.eclipse.emf.query2.Operation.LIKE, 'Linus Made*');
		LocalWhereEntry localWhereEntry = new LocalWhereEntry("m", whereClause);


Hope this helps for your issue.

Regards,
Manasa
Re: [query2] How may I do a query on attribute values using regexp? [message #656351 is a reply to message #656317] Fri, 25 February 2011 09:19 Go to previous messageGo to next message
Fabrizio Casali is currently offline Fabrizio CasaliFriend
Messages: 2
Registered: February 2011
Junior Member
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? If so how can I use it?

What wild-char are supported other then *?

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?

Regards

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 10:10 Go to previous message
manasa  is currently offline manasa Friend
Messages: 32
Registered: October 2010
Member
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 10:13]

Report message to a moderator

Previous Topic:Turn of generatation of PDE artifacts?
Next Topic:[TENEO] Integratind EMF and GMF generated editors
Goto Forum:
  


Current Time: Tue Oct 15 04:44:30 GMT 2019

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

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

Back to the top