roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1549969 - in /roller/trunk/app/src: main/java/org/apache/roller/weblogger/ main/java/org/apache/roller/weblogger/business/ main/java/org/apache/roller/weblogger/business/jpa/ main/java/org/apache/roller/weblogger/pojos/ main/java/org/apach...
Date Tue, 10 Dec 2013 20:59:42 GMT
Author: gmazza
Date: Tue Dec 10 20:59:42 2013
New Revision: 1549969

URL: http://svn.apache.org/r1549969
Log:
ROL-1980, pull out root category from list of options when moving category blog entries to
a new category, fix error that non-published blog articles aren't moved to the new category.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java Tue Dec 10 20:59:42
2013
@@ -264,11 +264,20 @@ public final class TestUtils {
     }
 
     /**
-     * Convenience method for creating a weblog entry.
+     * Convenience method for creating a published weblog entry.
      */
     public static WeblogEntry setupWeblogEntry(String anchor,
             WeblogCategory cat, Weblog weblog, User user) throws Exception {
 
+        return TestUtils.setupWeblogEntry(anchor, cat, WeblogEntry.PUBLISHED, weblog, user);
+    }
+
+    /**
+     * Convenience method for creating a weblog entry
+     */
+    public static WeblogEntry setupWeblogEntry(String anchor,
+        WeblogCategory cat, String status, Weblog weblog, User user) throws Exception {
+
         WeblogEntry testEntry = new WeblogEntry();
         testEntry.setTitle(anchor);
         testEntry.setLink("testEntryLink");
@@ -278,7 +287,7 @@ public final class TestUtils {
                 .getTime()));
         testEntry.setUpdateTime(new java.sql.Timestamp(new java.util.Date()
                 .getTime()));
-        testEntry.setStatus(WeblogEntry.PUBLISHED);
+        testEntry.setStatus(status);
         testEntry.setWebsite(getManagedWebsite(weblog));
         testEntry.setCreatorUserName(getManagedUser(user).getUserName());
         testEntry.setCategory(cat);

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/WeblogEntryManager.java
Tue Dec 10 20:59:42 2013
@@ -148,10 +148,10 @@ public interface WeblogEntryManager {
      * Get weblog entries with given category or, optionally, any sub-category
      * of that category.
      * @param cat     Category
-     * @param subcats True if sub-categories are to be fetched
+     * @param publishedOnly True to retrieve published articles only
      * @return        List of weblog entries in category
      */
-    List getWeblogEntries(WeblogCategory cat, boolean subcats)
+    List getWeblogEntries(WeblogCategory cat, boolean publishedOnly)
             throws WebloggerException; 
     
     /** 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
Tue Dec 10 20:59:42 2013
@@ -123,7 +123,7 @@ public class JPAWeblogEntryManagerImpl i
      */
     public void removeWeblogCategory(WeblogCategory cat)
     throws WebloggerException {
-        if(cat.retrieveWeblogEntries(true).size() > 0) {
+        if(cat.retrieveWeblogEntries(false).size() > 0) {
             throw new WebloggerException("Cannot remove category with entries");
         }
         
@@ -231,7 +231,7 @@ public class JPAWeblogEntryManagerImpl i
         }
         
         // get all entries in category and subcats
-        List results = srcCat.retrieveWeblogEntries(true);
+        List results = srcCat.retrieveWeblogEntries(false);
         
         // Loop through entries in src cat, assign them to dest cat
         Iterator iter = results.iterator();
@@ -774,12 +774,12 @@ public class JPAWeblogEntryManagerImpl i
     /**
      * @inheritDoc
      */
-    // TODO: this method should be removed and it's functionality moved to getWeblogEntries()
-    public List getWeblogEntries(WeblogCategory cat, boolean subcats)
+    // TODO: this method should be removed and its functionality moved to getWeblogEntries()
+    public List getWeblogEntries(WeblogCategory cat, boolean publishedOnly)
     throws WebloggerException {
         List results = null;
         
-        if (!subcats) {
+        if (publishedOnly) {
             Query q = strategy.getNamedQuery(
                     "WeblogEntry.getByStatus&Category");
             q.setParameter(1, WeblogEntry.PUBLISHED);
@@ -787,10 +787,8 @@ public class JPAWeblogEntryManagerImpl i
             results = q.getResultList();
         } else {
             Query q = strategy.getNamedQuery(
-                    "WeblogEntry.getByStatus&Category.pathLike&Website");
-            q.setParameter(1, WeblogEntry.PUBLISHED);
-            q.setParameter(2, cat.getPath() + '%');
-            q.setParameter(3, cat.getWebsite());
+                    "WeblogEntry.getByCategory");
+            q.setParameter(1, cat);
             results = q.getResultList();
         }
         

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java Tue
Dec 10 20:59:42 2013
@@ -226,13 +226,13 @@ public class WeblogCategory implements S
      * Retrieve all weblog entries in this category and, optionally, include
      * weblog entries all sub-categories.
      *
-     * @param subcats True if entries from sub-categories are to be returned.
+     * @param publishedOnly True if desired to return only published entries
      * @return List of WeblogEntryData objects.
      * @throws WebloggerException
      */
-    public List retrieveWeblogEntries(boolean subcats) throws WebloggerException {
+    public List retrieveWeblogEntries(boolean publishedOnly) throws WebloggerException {
         WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        return wmgr.getWeblogEntries(this, subcats);
+        return wmgr.getWeblogEntries(this, publishedOnly);
     }
     
     
@@ -295,7 +295,7 @@ public class WeblogCategory implements S
     
     /**
      * Determine if category is in use. Returns true if any weblog entries
-     * use this category or any of it's subcategories.
+     * use this category or any of its subcategories.
      */
     public boolean isInUse() {
         try {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogCategoryWrapper.java
Tue Dec 10 20:59:42 2013
@@ -110,10 +110,10 @@ public final class WeblogCategoryWrapper
     }
     
     
-    public List retrieveWeblogEntries(boolean subcats)
+    public List retrieveWeblogEntries(boolean publishedOnly)
             throws WebloggerException {
         
-        List initialCollection = this.pojo.retrieveWeblogEntries(subcats);
+        List initialCollection = this.pojo.retrieveWeblogEntries(publishedOnly);
         
         // iterate through and wrap
         // we force the use of an ArrayList because it should be good enough to cover

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryRemove.java
Tue Dec 10 20:59:42 2013
@@ -90,7 +90,7 @@ public class CategoryRemove extends UIAc
         try {
             // Build list of all categories, except for current one, sorted by path.
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog(),
true);
+            List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog(),
false);
             for(WeblogCategory cat : cats) {
                 if (!cat.getId().equals(getRemoveId())) {
                     allCategoriesSet.add(cat);

Modified: roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/jsps/editor/CategoryRemove.jsp Tue Dec 10 20:59:42
2013
@@ -37,7 +37,7 @@
         </span>
         <p><s:text name="categoryDeleteOK.youMustMoveEntries" /><p>
             <s:text name="categoryDeleteOK.moveToWhere" />
-            <s:select name="targetCategoryId" list="allCategories" listKey="id" listValue="path"
/>
+            <s:select name="targetCategoryId" list="allCategories" listKey="id" listValue="name"
/>
         </p>
     </s:if>
     <s:else>

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
(original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
Tue Dec 10 20:59:42 2013
@@ -246,8 +246,9 @@ public class WeblogCategoryFunctionality
         WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
         WeblogEntry e1 = null;
         WeblogEntry e2 = null; 
-        WeblogEntry e3 = null; 
-        
+        WeblogEntry e3 = null;
+        WeblogEntry e4 = null;
+
         try {
             // add some categories and entries to test with
             WeblogCategory dest = new WeblogCategory(testWeblog, root, "c0", null, null);
@@ -270,8 +271,9 @@ public class WeblogCategoryFunctionality
             dest = mgr.getWeblogCategory(dest.getId());
 
             e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
-            e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
-            e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
+            e2 = TestUtils.setupWeblogEntry("e2", c1, WeblogEntry.DRAFT, testWeblog, testUser);
+            e3 = TestUtils.setupWeblogEntry("e3", c2, testWeblog, testUser);
+            e4 = TestUtils.setupWeblogEntry("e4", c3, testWeblog, testUser);
 
             TestUtils.endSession(true);
 
@@ -284,10 +286,10 @@ public class WeblogCategoryFunctionality
             // verify number of entries in each category
             assertEquals(0, dest.retrieveWeblogEntries(true).size());
             assertEquals(0, dest.retrieveWeblogEntries(false).size());
-            assertEquals(1, c1.retrieveWeblogEntries(false).size());
-            assertEquals(3, c1.retrieveWeblogEntries(true).size());
+            assertEquals(2, c1.retrieveWeblogEntries(false).size());
+            assertEquals(1, c1.retrieveWeblogEntries(true).size());
 
-            // move contents of source category c1 to destination catetory dest
+            // move contents of source category c1 to destination category dest
             mgr.moveWeblogCategory(c1, dest);
             TestUtils.endSession(true);
 
@@ -297,24 +299,21 @@ public class WeblogCategoryFunctionality
             c2 = mgr.getWeblogCategory(c2.getId());
             c3 = mgr.getWeblogCategory(c3.getId());
 
-            assertEquals(3, dest.retrieveWeblogEntries(true).size());
-            assertEquals(0, dest.retrieveWeblogEntries(false).size());
-
             assertEquals(dest, c1.getParent());
             assertEquals(c1,   c2.getParent());
             assertEquals(c2,   c3.getParent());
 
-            assertEquals(1, c1.retrieveWeblogEntries(false).size());
+            assertEquals(2, c1.retrieveWeblogEntries(false).size());
+            assertEquals(1, c1.retrieveWeblogEntries(true).size());
             assertEquals(1, c2.retrieveWeblogEntries(false).size());
             assertEquals(1, c3.retrieveWeblogEntries(false).size());
-
-            List entries = c1.retrieveWeblogEntries(true);
-            assertEquals(3, entries.size());
+            assertEquals(0, dest.retrieveWeblogEntries(false).size());
 
         } finally {
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e1));
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e2));
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e3));
+            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e4));
         }
         log.info("END");
     }
@@ -328,7 +327,8 @@ public class WeblogCategoryFunctionality
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         WeblogEntry e1 = null;
         WeblogEntry e2 = null; 
-        WeblogEntry e3 = null; 
+        WeblogEntry e3 = null;
+        WeblogEntry e4 = null;
         try {
 
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
@@ -358,8 +358,9 @@ public class WeblogCategoryFunctionality
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
             testUser = TestUtils.getManagedUser(testUser);
             e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
-            e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
-            e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
+            e2 = TestUtils.setupWeblogEntry("e2", c1, WeblogEntry.DRAFT, testWeblog, testUser);
+            e3 = TestUtils.setupWeblogEntry("e3", c2, testWeblog, testUser);
+            e4 = TestUtils.setupWeblogEntry("e4", c3, testWeblog, testUser);
 
             TestUtils.endSession(true);
 
@@ -372,8 +373,8 @@ public class WeblogCategoryFunctionality
             // verify number of entries in each category
             assertEquals(0, dest.retrieveWeblogEntries(true).size());
             assertEquals(0, dest.retrieveWeblogEntries(false).size());
-            assertEquals(1, c1.retrieveWeblogEntries(false).size());
-            assertEquals(3, c1.retrieveWeblogEntries(true).size());
+            assertEquals(2, c1.retrieveWeblogEntries(false).size());
+            assertEquals(1, c1.retrieveWeblogEntries(true).size());
 
             // move contents of source category c1 to destination category dest
             mgr.moveWeblogCategoryContents(c1, dest);
@@ -385,16 +386,17 @@ public class WeblogCategoryFunctionality
             c1 = mgr.getWeblogCategory(c1.getId());
 
             // Hierarchy is flattened under dest      
-            assertEquals(3, dest.retrieveWeblogEntries(true).size());
-            assertEquals(3, dest.retrieveWeblogEntries(false).size());
+            assertEquals(2, dest.retrieveWeblogEntries(false).size());
+            assertEquals(1, dest.retrieveWeblogEntries(true).size());
 
             // c1 category should be empty now
             assertEquals(0, c1.retrieveWeblogEntries(false).size());
-            
+
         } finally {
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e1));
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e2));
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e3));
+            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e4));
         }
         
         log.info("END");

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java?rev=1549969&r1=1549968&r2=1549969&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java
(original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/WeblogEntryTest.java
Tue Dec 10 20:59:42 2013
@@ -230,7 +230,7 @@ public class WeblogEntryTest extends Tes
         
         // get all (non-future) PUBLISHED entries in category 
         entries = null;
-        entries = mgr.getWeblogEntries(testWeblog.getDefaultCategory(), false);
+        entries = mgr.getWeblogEntries(testWeblog.getDefaultCategory(), true);
         assertNotNull(entries);
         assertEquals(3, entries.size());
         



Mime
View raw message