Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Query 2] QueryContext
[EMF Query 2] QueryContext [message #675879] Wed, 01 June 2011 19:30 Go to next message
No real name is currently offline No real nameFriend
Messages: 11
Registered: May 2011
Junior Member
Hi (saurav),

i hope that fit Very Happy. For other the last two post in following topic: http://www.eclipse.org/forums/index.php/t/209676/. So, now to the content:

a) So today i tried a little bit with the QueryContext:
	private static QueryContext getQueryContext(final ResourceSet rs) {
		return new QueryContext() {

			public URI[] getResourceScope() {
				final List<URI> result = new ArrayList<URI>();
				index.executeQueryCommand(new QueryCommand() {
					public void execute(QueryExecutor queryExecutor) {
						ResourceQuery<ResourceDescriptor> resourceQuery = IndexQueryFactory.createResourceQuery();
						for (ResourceDescriptor desc : queryExecutor.execute(resourceQuery)) {
							result.add(desc.getURI());
						}
					}
				});
				return result.toArray(new URI[0]);
			}
			public ResourceSet getResourceSet() {
				return rs;
			}
		};
	}


And changed to:
	public QueryContext createQueryContext(final ResourceSet resourceSet, final URI... useURIs) {
		return new QueryContext() {
			@Override
			public URI[] getResourceScope() {
				URI[] result = new URI[useURIs.length];
				for (int x = 0; x < useURIs.length; x++) {
					result[x] = normalizer.normalize(useURIs[x]);
				}
				return result;
			}
			@Override
			public ResourceSet getResourceSet() {
				return resourceSet;
			}
		};
	}

	public QueryContext createQueryContextAll(final ResourceSet resourceSet) {
		return new QueryContext() {
			@Override
			public URI[] getResourceScope() {
				return indexedURIs.toArray(new URI[indexedURIs.size()]);
			}
			@Override
			public ResourceSet getResourceSet() {
				return resourceSet;
			}
		};
	}


The first construct (mean: everything in index.executeQueryCommand(...)) is only to get ALL indexed resources, right? First i thought this way is every time necessary.

c) Ok, i get URIs and when i need/want the EObjects i have to loaded with the URIs. That is what you mean, i think, or?

I split the handling of things around Query 2 in two classes:
- IndexQuery2Manager
- QueryCommandsManager

Make things a bit more clear for me and it make fun to work with Query 2. Now i have to take a closer look to the SQL like language.

Greetings,
littleRathi
Re: [EMF Query 2] QueryContext [message #675956 is a reply to message #675879] Thu, 02 June 2011 06:44 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Quote:
The first construct (mean: everything in index.executeQueryCommand(...)) is only to get ALL indexed resources, right? First i thought this way is every time necessary.

c) Ok, i get URIs and when i need/want the EObjects i have to loaded with the URIs. That is what you mean, i think, or?



Yes the first construct is to get all the resource indexed.You may chose to give some other URIs.

Then yes once you get the URIs you can load the resources or if you use attributes in your queries the resources are already
loaded and the attributes in the result are shown to you.
Quote:
I split the handling of things around Query 2 in two classes:
- IndexQuery2Manager
- QueryCommandsManager

Make things a bit more clear for me and it make fun to work with Query 2. Now i have to take a closer look to the SQL like language.



Its good to hear that you are liking to use Query2.You may wish to contribute your APIs back to Query2 if you feel it will help the community.

And yes go ahead with trying the SQL like language.Its pretty nice feature we have.
Would be awaiting for your comments/suggestions on that.

cheers,
Saurav


Re: [EMF Query 2] QueryContext [message #676268 is a reply to message #675956] Fri, 03 June 2011 13:15 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 11
Registered: May 2011
Junior Member
Hi saurav,

i could contribute them, but i don't know where/how and not sure that the two classes are worth. At time it is more experimental. However, i would do it.

Greetings,
littleRathi
Re: [EMF Query 2] QueryContext [message #676521 is a reply to message #676268] Sun, 05 June 2011 03:56 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi littleRathi,

You can open a bugzilla request at bugs.eclipse.org.
Lets discuss the code there and if we found anything of consequence
we would submit the code.

cheers,
Saurav


Re: [EMF Query 2] QueryContext [message #676570 is a reply to message #676521] Sun, 05 June 2011 10:07 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 11
Registered: May 2011
Junior Member
Hi saurav,

i thought bugs.eclipse.org is only for bugs ^^. Well, perhaps i can do that later that day, i will edit the link then in this reply.

Greetings,
littleRathi

[ edit1]I can only report a bug, are you sure to post new code there? found: enhancement Very Happy[ /edit1]
[ edit2]"bug report": https://bugs.eclipse.org/bugs/show_bug.cgi?id=348321[ /edit]

[Updated on: Sun, 05 June 2011 12:11]

Report message to a moderator

Re: [EMF Query 2] QueryContext [message #676600 is a reply to message #676570] Sun, 05 June 2011 16:32 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi littleRathi,

Thanks for raising for the request.Would look into it as soon as i get some time.
Yes Bugzilla is for everything...from A to Z of Eclipse Smile

cheers,
Saurav


Re: [EMF Query 2] QueryContext [message #676628 is a reply to message #676600] Sun, 05 June 2011 18:57 Go to previous message
No real name is currently offline No real nameFriend
Messages: 11
Registered: May 2011
Junior Member
Hi saurav,

i hope that don't make something wrong ^^.

Greetings,
littleRathi
Previous Topic:(no subject)
Next Topic:(no subject)
Goto Forum:
  


Current Time: Thu Mar 28 11:41:19 GMT 2024

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

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

Back to the top