roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r495349 - in /incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller: business/datamapper/DatamapperWeblogManagerImpl.java business/jpa/JPAWeblogManagerImpl.java pojos/CommentData.orm.xml
Date Thu, 11 Jan 2007 19:38:06 GMT
Author: clr
Date: Thu Jan 11 11:38:04 2007
New Revision: 495349

URL: http://svn.apache.org/viewvc?view=rev&rev=495349
Log:
Datamapper updates for CommentData status changes

Modified:
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
    incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/pojos/CommentData.orm.xml

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java?view=diff&rev=495349&r1=495348&r2=495349
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/datamapper/DatamapperWeblogManagerImpl.java
Thu Jan 11 11:38:04 2007
@@ -322,9 +322,7 @@
                 null,  // search String
                 null,  // startDate
                 null,  // endDate
-                null,  // pending
-                null,  // approved
-                null,  // spam
+                null,  // status
                 true,  // reverse chrono order (not that it matters)
                 0,     // offset
                 -1);   // no limit
@@ -674,9 +672,7 @@
             String          searchString,
             Date            startDate,
             Date            endDate,
-            Boolean         pending,
-            Boolean         approved,
-            Boolean         spam,
+            String          status,
             boolean         reverseChrono,
             int             offset,
             int             length
@@ -691,12 +687,10 @@
             String  searchString, 
             Date    startDate, 
             Date    endDate, 
-            Boolean pending, 
-            Boolean approved, 
-            Boolean spam) throws RollerException {
+            String status) throws RollerException {
         List comments = getComments( 
             website, entry, searchString, startDate, endDate, 
-            pending, approved, spam, true, 0, -1);
+            status, true, 0, -1);
         int count = 0;
         for (Iterator it = comments.iterator(); it.hasNext();) {
             CommentData comment = (CommentData) it.next();
@@ -1240,7 +1234,7 @@
      */
     public long getCommentCount() throws RollerException {
         List results = (List) strategy.newQuery(CommentData.class, 
-            "CommentData.getCountAllDistinct").execute();
+            "CommentData.getCountAllDistinctByStatus").execute(CommentData.APPROVED);
         
         return ((Long)results.get(0)).longValue();
     }
@@ -1250,7 +1244,8 @@
      */
     public long getCommentCount(WebsiteData website) throws RollerException {
         List results = (List) strategy.newQuery(CommentData.class, 
-            "CommentData.getCountDistinctByWebsite").execute(website);
+            "CommentData.getCountDistinctByWebsite&Status").
+        execute(new Object[] {website, CommentData.APPROVED});
         
         return ((Long)results.get(0)).longValue();
     }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java?view=diff&rev=495349&r1=495348&r2=495349
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
Thu Jan 11 11:38:04 2007
@@ -34,6 +34,7 @@
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WeblogEntryTagAggregateData;
 import org.apache.roller.pojos.WeblogCategoryData;
+import org.apache.roller.pojos.CommentData;
 import org.apache.roller.RollerException;
 
 /**
@@ -171,9 +172,7 @@
             String          searchString,
             Date            startDate,
             Date            endDate,
-            Boolean         pending,
-            Boolean         approved,
-            Boolean         spam,
+            String          status,
             boolean         reverseChrono,
             int             offset,
             int             length) throws RollerException {
@@ -194,33 +193,33 @@
             
         if (searchString != null) {
             params.add(size++, "%" + searchString + "%");
-            whereClause.append(" AND (url LIKE ?").append(size).
-                        append(" OR content LIKE ?)").append(size).append(")");
+            appendConjuctionToWhereclause(whereClause, "(c.url LIKE ?")
+                    .append(size).append(" OR c.content LIKE ?").append(size).append(")");
         }
             
         if (startDate != null) {
             params.add(size++, startDate);
-            whereClause.append("c.postTime >= ?").append(size);
+            appendConjuctionToWhereclause(whereClause, "c.postTime >= ?");
         }
             
         if (endDate != null) {
             params.add(size++, endDate);
-            whereClause.append("c.postTime =< ?").append(size);
+            appendConjuctionToWhereclause(whereClause, "c.postTime <= ?");
         }
-            
-        if (pending != null) {
-            params.add(size++, pending);
-            whereClause.append("c.pending = ?").append(size);
-        }
-            
-        if (approved != null) {
-            params.add(size++, approved);
-            whereClause.append("c.approved = ?").append(size);
-        }
-            
-        if (spam != null) {
-            params.add(size++, spam);
-            whereClause.append("c.spam = ?").append(size);
+
+        if (status != null) {
+            String comparisionOperator;
+            if("ALL_IGNORE_SPAM".equals(status)) {
+                // we want all comments, expect spam
+                // so that means where status != SPAM
+                status = CommentData.SPAM;
+                comparisionOperator = " <> ";
+            } else {
+                comparisionOperator = " = ";
+            }
+            params.add(size++, status);
+            appendConjuctionToWhereclause(whereClause, "c.status ")
+                    .append(comparisionOperator).append('?').append(size);
         }
 
         if(whereClause.length() != 0) {
@@ -252,6 +251,22 @@
     }
 
     /**
+     * Appends given expression to given whereClause. If whereClause already
+     * has other conditions, an " AND " is also appended before appending
+     * the expression
+     * @param whereClause The given where Clauuse
+     * @param expression The given expression
+     * @return the whereClause.
+     */
+    private static StringBuffer appendConjuctionToWhereclause(StringBuffer whereClause,
+            String expression) {
+        if(whereClause.length() != 0 && expression.length() != 0) {
+            whereClause.append(" AND ");
+        }
+        return whereClause.append(expression);
+    }
+
+    /**
      * @inheritDoc
      */
     public int removeMatchingComments(
@@ -260,9 +275,7 @@
             String  searchString,
             Date    startDate,
             Date    endDate,
-            Boolean pending,
-            Boolean approved,
-            Boolean spam) throws RollerException {
+            String status) throws RollerException {
 
         // TODO dynamic bulk delete query
         /* I'd MUCH rather use a bulk delete, but MySQL says "General error,  
@@ -353,9 +366,7 @@
                 searchString,
                 startDate,
                 endDate,
-                pending,
-                approved,
-                spam);
+                status);
     }
 
     /**
@@ -488,7 +499,7 @@
         }
 
         // delete all bad counts
-        strategy.newRemoveQuery(WeblogEntryTagAggregateData.class, 
+        strategy.newRemoveQuery(WeblogEntryTagAggregateData.class,
             "WeblogEntryTagAggregateData.removeByTotalLessEqual")
             .removeAll(new Integer(0));
     }

Modified: incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/pojos/CommentData.orm.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/pojos/CommentData.orm.xml?view=diff&rev=495349&r1=495348&r2=495349
==============================================================================
--- incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/pojos/CommentData.orm.xml
(original)
+++ incubator/roller/trunk/sandbox/jdobackend/src/org/apache/roller/pojos/CommentData.orm.xml
Thu Jan 11 11:38:04 2007
@@ -11,13 +11,13 @@
     <package>org.apache.roller.pojos</package>
     <entity metadata-complete="true" name="CommentData" class="org.apache.roller.pojos.CommentData">
         <table name="roller_comment"/>
-        <named-query name="CommentData.getCountAllDistinct">
+        <named-query name="CommentData.getCountAllDistinctByStatus">
             <!-- DISTINCT is not required for this query as comments would never be duplicated
in retrieved result-->
-            <query>SELECT COUNT(c) FROM CommentData c</query>
+            <query>SELECT COUNT(c) FROM CommentData c where c.status = ?1</query>
         </named-query>
-        <named-query name="CommentData.getCountDistinctByWebsite">
+        <named-query name="CommentData.getCountDistinctByWebsite&amp;Status">
             <!-- DISTINCT is not required for this query as comments would never be duplicated
in retrieved result-->
-            <query>SELECT COUNT(c) FROM CommentData c WHERE c.weblogEntry.website =
?1</query>
+            <query>SELECT COUNT(c) FROM CommentData c WHERE c.weblogEntry.website =
?1 AND c.status = ?2</query>
         </named-query>
         <named-query name="CommentData.getMostCommentedWebsiteByEndDate">
             <!--
@@ -100,17 +100,11 @@
             <basic name="postTime">
                 <column name="posttime" insertable="true" updatable="true" unique="false"/>
             </basic>
-            <basic name="spam">
-                <column name="spam" insertable="true" updatable="true" unique="false"/>
+            <basic name="status">
+                <column name="status" insertable="true" updatable="true" unique="false"/>
             </basic>
             <basic name="notify">
                 <column name="notify" insertable="true" updatable="true" unique="false"/>
-            </basic>
-            <basic name="pending">
-                <column name="pending" insertable="true" updatable="true" unique="false"/>
-            </basic>
-            <basic name="approved">
-                <column name="approved" insertable="true" updatable="true" unique="false"/>
             </basic>
             <basic name="remoteHost">
                 <column name="remotehost" insertable="true" updatable="true" unique="false"/>



Mime
View raw message