Author: jvelociter
Date: 2008-02-11 16:50:23 +0100 (Mon, 11 Feb 2008)
New Revision: 7500
Modified:
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/api/SpaceManager.java
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
Log:
XPSM-6 Allow to order on searchSpaces queries.
Patch submitted by Cristian Vrabie
Modified:
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/api/SpaceManager.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/api/SpaceManager.java
2008-02-11 15:03:26 UTC (rev 7499)
+++
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/api/SpaceManager.java
2008-02-11 15:50:23 UTC (rev 7500)
@@ -155,6 +155,16 @@
* @return list of space objects
*/
public List getSpaces(int nb, int start, XWikiContext context) throws
SpaceManagerException;
+
+ /**
+ * Lists spaces in the wiki
+ *
+ * @param nb the maximum number of spaces to retrieve
+ * @param start the offset to start retrieving spaces at
+ * @param ordersql hibernate sql describing how to order the spaceobjects
+ * @return list of space objects
+ */
+ public List getSpaces(int nb, int start, String ordersql, XWikiContext
context) throws SpaceManagerException;
/**
* Get a list of space names
@@ -165,6 +175,17 @@
*/
public List getSpaceNames(int nb, int start, XWikiContext context)
throws SpaceManagerException;
+
+ /**
+ * Get a list of space names
+ *
+ * @param nb the maximum number of space names to retrieve
+ * @param start the offset to start retrieving the names at
+ * @param ordersql hibernate sql describing how to order the names
+ * @return list of space names
+ */
+ public List getSpaceNames(int nb, int start, String ordersql, XWikiContext
context)
+ throws SpaceManagerException;
/**
* Search for spaces using an HQL query returning Space objects
@@ -172,8 +193,17 @@
* @see #searchSpaceNames(String, String, int, int, XWikiContext) for
parameters details.
* @return list of space objects
*/
- public List searchSpaces(String fromsql, String wherehql, int nb, int
start,
+ public List searchSpaces(String fromsql, String wheresql, int nb, int
start,
XWikiContext context) throws SpaceManagerException;
+
+ /**
+ * Search for spaces using an HQL query returning Space objects
+ *
+ * @see #searchSpaceNames(String, String, String, int, int, XWikiContext)
for parameters details.
+ * @return list of space objects
+ */
+ public List searchSpaces(String fromsql, String wheresql, String ordersql,
int nb, int start,
+ XWikiContext context) throws SpaceManagerException;
/**
* Search for spaces using an HQL query returning Space Names
@@ -189,6 +219,22 @@
*/
public List searchSpaceNames(String fromsql, String wheresql, int nb, int
start,
XWikiContext context) throws SpaceManagerException;
+
+ /**
+ * Search for spaces using an HQL query returning Space Names
+ *
+ * @param fromsql the from clause of the hql query. Should start with a
comma if not empty
+ * (since appended to the actual search spaces from clause)
+ * @param wheresql the where clause of the hql query. Should start with "
and" if not empty
+ * (since appended to the actual search spaces where clause).
+ * @param ordersql the where clause of the hql query. Should start with "
" if not empty
+ * @param nb the maximum number of spaces to retrieve
+ * @param start the offset to start retrieving the spaces at.
+ * @param context
+ * @return list of space names matching the generated query
+ */
+ public List searchSpaceNames(String fromsql, String wheresql, String
ordersql, int nb, int start,
+ XWikiContext context) throws SpaceManagerException;
/**
* Get the list of spaces for a user in a specific role If role is null it
will get all spaces
Modified:
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
2008-02-11 15:03:26 UTC (rev 7499)
+++
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
2008-02-11 15:50:23 UTC (rev 7500)
@@ -788,6 +788,12 @@
List spaceNames = getSpaceNames(nb, start, context);
return getSpaceObjects(spaceNames, context);
}
+
+ public List getSpaces(int nb, int start, String ordersql, XWikiContext
context) throws SpaceManagerException
+ {
+ List spaceNames = getSpaceNames(nb, start, ordersql, context);
+ return getSpaceObjects(spaceNames, context);
+ }
/**
* Returns a list of nb space names starting at start
@@ -810,10 +816,17 @@
return spaceList;
}
+ public List getSpaceNames(int nb, int start, XWikiContext context)
+ throws SpaceManagerException
+ {
+ return getSpaceNames( nb, start, "", context );
+ }
+
+
/**
* [EMAIL PROTECTED]
*/
- public List getSpaceNames(int nb, int start, XWikiContext context)
+ public List getSpaceNames(int nb, int start, String ordersql, XWikiContext
context)
throws SpaceManagerException
{
String type = getSpaceTypeName();
@@ -823,13 +836,13 @@
sql =
"select distinct doc.web from XWikiDocument as doc, BaseObject
as obj, "
+ className + " as space where doc.fullName = obj.name and
obj.className='"
- + className + "' and obj.id = space.id and space.type='" +
type + "'";
+ + className + "' and obj.id = space.id and space.type='" +
type + "'" + ordersql;
else
sql =
"select distinct doc.web from XWikiDocument as doc, BaseObject
as obj, StringProperty typeprop where doc.fullName=obj.name and obj.className =
'"
+ className
+ "' and obj.id=typeprop.id.id and typeprop.id.name='type'
and typeprop.value='"
- + type + "'";
+ + type + "'" + ordersql;
List spaceList = null;
try {
@@ -841,19 +854,54 @@
}
/**
- * [EMAIL PROTECTED]
- */
- public List searchSpaces(String fromsql, String wherehql, int nb, int
start,
+ * Performs a search for spaces
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param ordersql The sql fragment describing the order in wich the
spaces should be returned
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @param context XWiki context
+ * @return A list with space objects matching the search
+ * @throws SpaceManagerException
+ */
+ public List searchSpaces(String fromsql, String wheresql, String ordersql,
int nb, int start,
XWikiContext context) throws SpaceManagerException
{
- List spaceNames = searchSpaceNames(fromsql, wherehql, nb, start,
context);
+ List spaceNames = searchSpaceNames(fromsql, wheresql, ordersql, nb,
start, context);
return getSpaceObjects(spaceNames, context);
}
+
+ /**
+ * Performs a search for spaces. This variant returns the spaces ordered
ascending by creation date
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @param context XWiki context
+ * @return A list with space objects matching the search
+ * @throws SpaceManagerException
+ */
+ public List searchSpaces(String fromsql, String wheresql, int nb, int
start,
+ XWikiContext context) throws SpaceManagerException
+ {
+ return searchSpaces(fromsql, wheresql, "", nb, start, context);
+ }
/**
- * [EMAIL PROTECTED]
- */
- public List searchSpaceNames(String fromsql, String wheresql, int nb, int
start,
+ * Performs a search for space names
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param ordersql The sql fragment describing the order in wich the
spaces should be returned
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @param context XWiki context
+ * @return A list of strings representing the names of the spaces
matching the search
+ * @throws SpaceManagerException
+ */
+ public List searchSpaceNames(String fromsql, String wheresql, String
ordersql, int nb, int start,
XWikiContext context) throws SpaceManagerException
{
String type = getSpaceTypeName();
@@ -864,7 +912,7 @@
"select distinct doc.web from XWikiDocument as doc, BaseObject
as obj, "
+ className + " as space" + fromsql
+ " where doc.fullName = obj.name and obj.className='" +
className
- + "' and obj.id = space.id and space.type='" + type + "'"
+ wheresql;
+ + "' and obj.id = space.id and space.type='" + type + "'"
+ wheresql + ordersql;
else
sql =
"select distinct doc.web from XWikiDocument as doc, BaseObject
as obj, StringProperty as typeprop"
@@ -872,7 +920,7 @@
+ " where doc.fullName=obj.name and obj.className = '"
+ className
+ "' and obj.id=typeprop.id.id and typeprop.id.name='type'
and typeprop.value='"
- + type + "'" + wheresql;
+ + type + "'" + wheresql + ordersql;
List spaceList = null;
try {
@@ -882,6 +930,23 @@
}
return spaceList;
}
+
+ /**
+ * Performs a search for space names. This variant returns the spaces
ordered ascending by creation date
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @param context XWiki context
+ * @return A list of strings representing the names of the spaces
matching the search
+ * @throws SpaceManagerException
+ */
+ public List searchSpaceNames(String fromsql, String wheresql, int nb,
int start,
+ XWikiContext context) throws SpaceManagerException
+ {
+ return searchSpaceNames(fromsql,wheresql,"",nb,start,context);
+ }
/**
* [EMAIL PROTECTED]
@@ -924,6 +989,7 @@
return spaceList;
}
+
/**
* [EMAIL PROTECTED]
*/
Modified:
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
2008-02-11 15:03:26 UTC (rev 7499)
+++
xwiki-platform/xwiki-plugins/trunk/spacemanager/src/main/java/com/xpn/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
2008-02-11 15:50:23 UTC (rev 7500)
@@ -210,6 +210,19 @@
List spacesList = getSpaceManager().getSpaces(nb, start, context);
return spacesList;
}
+
+ /**
+ * Get the list of space objects
+ *
+ * @param nb
+ * @param start
+ * @param ordersql
+ * @return list of space objects
+ */
+ public List getSpaces(int nb, int start, String ordersql) throws
SpaceManagerException {
+ List spacesList = getSpaceManager().getSpaces(nb, start, ordersql,
context);
+ return spacesList;
+ }
/*
private List wrapSpaces(List spacesList) {
@@ -232,35 +245,85 @@
public List getSpaceNames(int nb, int start) throws SpaceManagerException {
return getSpaceManager().getSpaceNames(nb, start, context);
}
-
- /**
- * Search for spaces using an HQL query returning Space objects
+
+ /**
+ * Get the list of space objects
*
- * @param fromsql
- * @param wheresql
* @param start
* @param nb
- * @return list of space objects
+ * @param ordersql
+ * @return list of space names
*/
+ public List getSpaceNames(int nb, int start, String ordersql) throws
SpaceManagerException {
+ return getSpaceManager().getSpaceNames(nb, start, ordersql, context);
+ }
+
+ /**
+ * Performs a search for spaces. This variant returns the spaces ordered
ascending by creation date
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @return A list with space objects matching the search
+ * @throws SpaceManagerException
+ */
public List searchSpaces(String fromsql, String wheresql, int nb, int
start) throws SpaceManagerException {
List spacesList = getSpaceManager().searchSpaces(fromsql, wheresql,
nb, start, context);
return spacesList;
}
+
+ /**
+ * Performs a search for spaces
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param ordersql The sql fragment describing the order in wich the
spaces should be returned
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @return A list with space objects matching the search
+ * @throws SpaceManagerException
+ */
+ public List searchSpaces(String fromsql, String wheresql, String ordersql,
int nb, int start) throws SpaceManagerException
+ {
+ List spacesList = getSpaceManager().searchSpaces(fromsql,
wheresql, ordersql, nb, start, context);
+ return spacesList;
+ }
- /**
- * Search for spaces using an HQL query returning Space Names
- *
- * @param fromsql
- * @param wheresql
- * @param start
- * @param nb
- * @return
- */
+ /**
+ * Performs a search for space names. This variant returns the spaces
ordered ascending by creation date
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @param context XWiki context
+ * @return A list of strings representing the names of the spaces
matching the search
+ * @throws SpaceManagerException
+ */
public List searchSpaceNames(String fromsql, String wheresql, int nb, int
start) throws SpaceManagerException {
return getSpaceManager().searchSpaceNames(fromsql, wheresql, nb,
start, context);
}
+
/**
+ * Performs a search for space names
+ *
+ * @param fromsql The sql fragment describing the source of the search
+ * @param wheresql The sql fragment describing the where clause of the
search
+ * @param ordersql The sql fragment describing the order in wich the
spaces should be returned
+ * @param nb The number of spaces to return (limit)
+ * @param start Number of spaces to skip
+ * @return A list of strings representing the names of the spaces
matching the search
+ * @throws SpaceManagerException
+ */
+ public List searchSpaceNames(String fromsql, String wheresql, String
ordersql, int nb, int start) throws SpaceManagerException
+ {
+ return getSpaceManager().searchSpaceNames(fromsql, wheresql, ordersql,
nb, start, context);
+ }
+
+
+ /**
* Get the list of spaces for a user in a specific role
* If role is null it will get all spaces in which the user is member
* return space name
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications