Vincent Massol wrote:
The first
proposal is about introducing two $xwiki.countDocuments
methods, one that accepts a simple hql query, and one that accepts a
parametrized query and a list of parameter values. These work like
searchDocuments, but instead of prefixing the query fragment with
'select doc.fullName from XWikiDocument as doc', it will prefix it
with
'select count(*) from XWikiDOcument as doc'.
This will allow to count documents without using a programming-
protected
query, and without retrieving all the documents and count the results.
Such a method is needed for paging results, for example.
Sounds good to me.
Artem, how will this be done with the Query manager?
getQueryManager().createQuery(anyhqlstatement, Query.HQL)
.bindValues(list).execute()
The only problem is positional parameters is not implemented (so there
is no bindValues(list) :) ).
There is no positional parameters in JCRv2 (only named) (and there is no
query parameters at all in JCRv1).
I thought we can emulate positional parameters via named. For example
write ":p1" instead of "?1" (":1" is incorrect named
parameter for many
jpql parsers). But it looks some weird and restrictive.
So I think we should support positional parameters in our Query
interface. Positional parameters will be handled by hibernate in
HibernateStore and will be emulated via named parameters in JCRStore.
I'll implement it.
http://jira.xwiki.org/jira/browse/XWIKI-2641
about countDocuments:
+1
I think we should move all $xwiki.search* functions including this to
"$services.query." velocity bridge and use the new XWQL as a language
for it, but later, in 1.7.
The second
proposal is a temporary hack for hiding documents. The idea
is to add a new field in the XWikiDocument class, 'hidden', which will
be automatically used in searchDocuments and countDocuments to filter
out special documents. This is a workaround until we will be able to
tag
special documents or spaces, and will allow to create special
documents
needed for an application inside the main application's space, instead
of the generic XWiki space. Such hidden pages won't appear in normal
search results, the index page or the navigation panel.
-0 (close to -1) till you explain what is wrong with the solution
below :)
-0. I agree with Vincent.
This could also be implemented using a special Tag
(like:
"xwiki:hidden" for example).
I was going to say: "In general I think we need the ability to add
generic metadata to a document.". however this already exists: it's
called Objects! :)
So I think instead of adding more and more fixed metadata we might
instead want to use Objects. Either reuse the existing Tag or create a
new Visibility class/objects.
What are the cons of using Objects for this feature?
To show these documents (for admins, for example)
we could add another
searchDocuments method which accepts a boolean parameter that
enables or
disables the filter on the 'hidden' property.
If we use an Object then we don't need to add a new API since we
already have all the required APIs for manipulating objects.
--
Artem Melentyev