roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r528078 - in /roller/trunk/apps/planet: src/java/org/apache/roller/planet/business/ src/java/org/apache/roller/planet/business/hibernate/ src/java/org/apache/roller/planet/tasks/ test/java/org/apache/roller/planet/business/
Date Thu, 12 Apr 2007 18:42:48 GMT
Author: agilliland
Date: Thu Apr 12 11:42:47 2007
New Revision: 528078

URL: http://svn.apache.org/viewvc?view=rev&rev=528078
Log:
final fix up for planet manager getEntries() method by group.  basically i am reverting the
changes from revision 526464 which allowed a list of groups to be passed in and reverting
back to the code from revision 517463.  the code from revision 526464 was introduced to support
a legacy way that the Roller Weblogger code was using the planet functionality, but we are
going to fix that in a different way instead.


Modified:
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
    roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
    roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java?view=diff&rev=528078&r1=528077&r2=528078
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
(original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
Thu Apr 12 11:42:47 2007
@@ -157,36 +157,28 @@
     /**
      * Get Entries for a Group in reverse chonological order.
      *
-     * Entries may be constrained to a certain timeframe and the offset and
-     * length parameters can be used to retrieve a specific segment of the 
-     * results.
-     *
-     * @param group Get entries from the subscriptions in the specified group.
-     * @param startDate The oldest date for entries to include.
-     * @param endDate The newest date for entries to include.
+     * @param group Restrict to entries from one group.
      * @param offset Offset into results (for paging)
-     * @param length Maximum number of results to return (for paging)
+     * @param len Maximum number of results to return (for paging)
      */
-    public List getEntries(PlanetGroupData group, 
-                           Date startDate, 
-                           Date endDate,
-                           int offset, 
-                           int length) throws RollerException;
+    public List getEntries(PlanetGroupData group, int offset, int len) 
+        throws RollerException;
     
     
     /**
      * Get Entries for a Group in reverse chonological order, optionally 
      * constrained to a certain timeframe.
      *
-     * @param groups Restrict to entries from these groups (list of PlanetGroupData objects)
+     * @param group Restrict to entries from one group.
      * @param startDate The oldest date for entries to include.
-     * @param endDate   The newest date for entries to include.
-     * @param offset    Offset into results (for paging)
-     * @param len       Maximum number of results to return (for paging)
+     * @param endDate The newest date for entries to include.
+     * @param offset Offset into results (for paging)
+     * @param len Maximum number of results to return (for paging)
      */
-    public List getEntries(List groups, 
+    public List getEntries(PlanetGroupData group, 
                            Date startDate, 
                            Date endDate,
                            int offset, 
-                           int len) throws RollerException;    
+                           int len) throws RollerException;
+    
 }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java?view=diff&rev=528078&r1=528077&r2=528078
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
(original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
Thu Apr 12 11:42:47 2007
@@ -310,25 +310,20 @@
     }
     
     
-    // Lookup Entries from a specific group
-    public List getEntries(PlanetGroupData group, Date startDate, Date endDate, 
-                           int offset, int length) 
+    // lookup Entries from a specific Group
+    public List getEntries(PlanetGroupData group, int offset, int len) 
             throws RollerException {
-        return getEntries(Collections.singletonList(group), startDate, endDate, offset, length);
+        return getEntries(group, null, null, offset, len);
     } 
     
     
-    // Lookup Entries from a specific list of groups
-    public List getEntries(List groups, Date startDate, 
-                           Date endDate, int offset, int length)
+    // Lookup Entries from a specific group
+    public List getEntries(PlanetGroupData group, Date startDate, Date endDate, 
+                           int offset, int length) 
             throws RollerException {
         
-        if (groups == null) {
-            throw new RollerException("groups cannot be null");
-        }
-        
-        if (groups.size() == 0) {
-            throw new RollerException("groups cannot be empty");
+        if (group == null) {
+            throw new RollerException("group cannot be null");
         }
         
         List ret = null;
@@ -340,13 +335,7 @@
             StringBuffer sb = new StringBuffer();
             sb.append("select e from PlanetEntryData e ");
             sb.append("join e.subscription.groups g ");
-            
-            sb.append("where (");
-            for (int i=0; i<groups.size(); i++) {
-                if (i > 0) sb.append(" or ");
-                sb.append(" g=:group" + i);
-            }
-            sb.append(") ");
+            sb.append("where g=:group ");
             
             if (startDate != null) {
                 sb.append("and e.pubTime > :startDate ");
@@ -357,10 +346,7 @@
             sb.append("order by e.pubTime desc");
             
             Query query = session.createQuery(sb.toString());
-            for (int i=0; i<groups.size(); i++) {
-                PlanetGroupData group = (PlanetGroupData)groups.get(i);
-                query.setParameter("group" + i, group);
-            }
+            query.setParameter("group", group);
             if(offset > 0) {
                 query.setFirstResult(offset);
             }

Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java?view=diff&rev=528078&r1=528077&r2=528078
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
(original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
Thu Apr 12 11:42:47 2007
@@ -81,7 +81,7 @@
     
     public List getAggregation(
             PlanetGroupData group, int maxEntries) throws RollerException {
-        return planetManager.getEntries(group, null, null, 0, maxEntries);
+        return planetManager.getEntries(group, 0, maxEntries);
     }
     
     

Modified: roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java?view=diff&rev=528078&r1=528077&r2=528078
==============================================================================
--- roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java
(original)
+++ roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/EntryFunctionalTests.java
Thu Apr 12 11:42:47 2007
@@ -94,7 +94,7 @@
         
         // by group
         PlanetGroupData group = mgr.getGroupById(testGroup1.getId());
-        assertEquals(3, mgr.getEntries(group, null, null, 0, 10).size());
+        assertEquals(3, mgr.getEntries(group, 0, 10).size());
         
         // by group with timeframe constraint
         assertEquals(0, mgr.getEntries(group, new Date(), null, 0, 10).size());



Mime
View raw message