r1499 - xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets

Jeremi Joslin jeremi at users.forge.objectweb.org
Fri Nov 3 13:54:33 CET 2006


Author: jeremi
Date: 2006-11-03 13:54:32 +0100 (Fri, 03 Nov 2006)
New Revision: 1499

Modified:
   xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPlugin.java
   xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPluginApi.java
Log:
[GELC]
* improve the getCollection

Modified: xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPlugin.java
===================================================================
--- xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPlugin.java	2006-11-03 10:05:07 UTC (rev 1498)
+++ xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPlugin.java	2006-11-03 12:54:32 UTC (rev 1499)
@@ -498,16 +498,6 @@
         return docName;
     }
 
-    public List getPublishedCollection(XWikiContext context) throws XWikiException {
-        return getPublishedCollection(context.getUser(), context);
-    }
-
-    public List getPublishedCollection(String userName, XWikiContext context) throws XWikiException {
-        String hql = ", BaseObject as obj where doc.fullName=obj.name and obj.className='"+ ASSET_CLASS_FULLNAME + "' and doc.author = '" + userName + "' and doc.web!='" + ASSET_TEMPORARY_SPACE + "'";
-        List xDocs = context.getWiki().getStore().searchDocuments(hql, context);
-        return WrapDocuments(xDocs, context);
-    }
-
     private List WrapDocuments(List xdocs, XWikiContext context){
         List docs = new ArrayList();
         Iterator it  = xdocs.iterator();
@@ -522,8 +512,49 @@
     }
 
     public List getUnpublishedCollection(String userName, XWikiContext context) throws XWikiException {
-        String hql = ", BaseObject as obj where doc.fullName=obj.name and obj.className='"+ ASSET_CLASS_FULLNAME + "' and doc.author = '" + userName + "' and doc.web='" + ASSET_TEMPORARY_SPACE + "'";
-        List xDocs = context.getWiki().getStore().searchDocuments(hql, context);
+        CollectionQuery colQ = new CollectionQuery();
+        colQ.author = userName;
+        colQ.published = false;
+        return getCollection(colQ, context);
+    }
+
+    public List getPublishedCollection(XWikiContext context) throws XWikiException {
+        return getPublishedCollection(context.getUser(), context);
+    }
+
+    public List getPublishedCollection(String userName, XWikiContext context) throws XWikiException {
+        CollectionQuery colQ = new CollectionQuery();
+        colQ.author = userName;
+        colQ.collectionName = context.getWiki().getDocument(userName, context).getName();
+        colQ.published = true;
+        return getCollection(colQ, context);
+    }
+
+    public List getCollection(CollectionQuery colQ, XWikiContext context) throws XWikiException {
+        String hql = ", BaseObject as obj where " +
+                "doc.fullName=obj.name and obj.className='" + ASSET_CLASS_FULLNAME + "'";
+        if (colQ.published)
+               hql +=  " and doc.web = '" + getCollectionSpace(colQ.collectionName, context) + "'";
+        else
+               hql +=  " and doc.web='" + ASSET_TEMPORARY_SPACE;
+        hql +=  " order by " + colQ.order;
+        if (colQ.author != null && colQ.author.length() > 0)
+             hql += "' and doc.author = '" + colQ.author + "'";
+        List xDocs = context.getWiki().getStore().searchDocuments(hql, colQ.begining, colQ.end, context);
         return WrapDocuments(xDocs, context);
     }
+
+    public CollectionQuery getCollectionQuery(){
+        return new CollectionQuery();
+    }
+
+    public class CollectionQuery{
+        public boolean published = true;
+        public String collectionName = "";
+        public String order = "doc.date";
+        public String author = "";
+        public int begining = 0;
+        public int end = 10;
+    }
 }
+

Modified: xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPluginApi.java
===================================================================
--- xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPluginApi.java	2006-11-03 10:05:07 UTC (rev 1498)
+++ xwiki-apps/gelc/gelcv1/trunk/gelcplugins/src/main/java/org/gelc/xwiki/plugins/assets/AssetManagerPluginApi.java	2006-11-03 12:54:32 UTC (rev 1499)
@@ -135,4 +135,12 @@
     public List getUnpublishedCollection(String userName) throws XWikiException {
         return assetManagerPlugin.getUnpublishedCollection(userName, context);
     }
+
+    public AssetManagerPlugin.CollectionQuery getCollectionQueryObject(){
+        return assetManagerPlugin.getCollectionQuery();
+    }
+
+    public List getCollection(AssetManagerPlugin.CollectionQuery colQ) throws XWikiException {
+        return assetManagerPlugin.getCollection(colQ, context);
+    }
 }





More information about the Xwiki-notifications mailing list