7 messages in org.xwiki.devs[xwiki-devs] [Proposal] QueryManager ...
FromSent OnAttachments
Artem MelentyevMay 25, 2008 8:08 am 
Vincent MassolMay 25, 2008 9:03 am 
Artem MelentyevMay 25, 2008 11:18 am 
Vincent MassolMay 25, 2008 12:11 pm 
Vincent MassolMay 26, 2008 2:35 am 
Artem MelentyevMay 28, 2008 5:31 am 
Vincent MassolMay 28, 2008 5:47 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[xwiki-devs] [Proposal] QueryManager in storeActions
From:Artem Melentyev (amel@gmail.com)
Date:May 25, 2008 8:08:29 am
List:org.xwiki.devs

Hi, devs.

I would like to propose new QueryManager which will deprecate our store.search(* methods This proposal is based on Vincent ideas at http://markmail.org/message/mjgg52coupsmfomg and QueryManager from JCR v2 QueryManager is designed for low-level querying in Java code. (QueryPlugin for high-level and velocity) The main idea is support of multiple languages and easy to add new languages. This is needed for JCRStore.

Here is interfaces:

public interface QueryManager { Query createQuery(String statement, String language); Query getNamedQuery(String qname); String[] getLanguages(); boolean hasLanguage(String language); }

public interface Query { enum Language { HQL, XPATH, JCRSQL } <T> List<T> execute(); Query bindValue(String var, Object val); Query setLimit(int limit); Query setOffset(int offset); }

Here is abstract usecase:

QueryManager qm = xwiki.getStore().getQueryManager(); Query q = qm.getNamedQuery("SomeNameOfQuery"); if (q==null && qm.hasLanguage(Query.Language.HQL.name())) { q = qm.createQuery("from XWikiDocument where author=:var", Language.HQL.name()); } else if (q==null && qm.hasLanguage(Language.XPATH.name())) { q = qm.createQuery("/*/*[@author=:var]", Language.XPATH.name()); } else throw new RuntimeException(); List<XWikiDocument> res = q.setLimit(10).setOffset(10) .bindValue("var", "Some.Author").execute();

notes: I'm not sure we need getNamedQuery right now. But it can be useful for move some complicated queries to store level (to some QueryHolders) or overriding queries. Queries are detached from store session. So session isn't opened until Query#execute().

WDYT?