roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1571562 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/pojos/WeblogCategory.java java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml
Date Tue, 25 Feb 2014 04:42:33 GMT
Author: gmazza
Date: Tue Feb 25 04:42:32 2014
New Revision: 1571562

URL: http://svn.apache.org/r1571562
Log:
ROL-1981 categories now ordered by time created, can be reordered by combinations of deleting,
re-adding and/or renaming them.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogCategory.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
    roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml

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=1571562&r1=1571561&r2=1571562&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
Feb 25 04:42:32 2014
@@ -66,7 +66,12 @@ public class WeblogCategory implements S
         
         this.weblog = weblog;
         weblog.getWeblogCategories().add(this);
-        this.position = weblog.getWeblogCategories().size();
+        int size = weblog.getWeblogCategories().size();
+        if (size == 1) {
+            this.position = 0;
+        } else {
+            this.position = weblog.getWeblogCategories().get(size - 2).getPosition() + 1;
+        }
     }
     
     
@@ -149,9 +154,7 @@ public class WeblogCategory implements S
     }
 
     /**
-     * A 1-based position indicator for desired display order of that category.
-     * Value of 0 indicates no ordering yet assigned.
-     * New categories are always placed at the end of the list.
+     * A 0-based position indicator for desired display order of that category.
      */
     public int getPosition() {
         return position;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java?rev=1571562&r1=1571561&r2=1571562&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Categories.java
Tue Feb 25 04:42:32 2014
@@ -40,14 +40,8 @@ public class Categories extends UIAction
 
 	private static Log log = LogFactory.getLog(Categories.class);
 
-	// list of category ids to move
-	private String[] selectedCategories = null;
-
-	// category id of the category to move to
-	private String targetCategoryId = null;
-
 	// all categories from the action weblog
-	private Set<WeblogCategory> allCategories = Collections.EMPTY_SET;
+	private List<WeblogCategory> allCategories;
 
 	public Categories() {
 		this.actionName = "categories";
@@ -61,57 +55,26 @@ public class Categories extends UIAction
 	}
 
 	public String execute() {
-
-		// build list of categories for display
-		TreeSet<WeblogCategory> allCategories = new TreeSet<WeblogCategory>(new WeblogCategoryPathComparator());
-
 		try {
-			// Build list of all categories, except for current one, sorted by
-			// path.
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-			List<WeblogCategory> cats = wmgr.getWeblogCategories(getActionWeblog());
-			for (WeblogCategory cat : cats) {
-			    allCategories.add(cat);
-			}
+			allCategories = wmgr.getWeblogCategories(getActionWeblog());
 		} catch (WebloggerException ex) {
 			log.error("Error building categories list", ex);
-			// TODO: i18n
 			addError("Error building categories list");
 		}
 
-		if (allCategories.size() > 0) {
-			setAllCategories(allCategories);
-		}
-
 		return LIST;
 	}
 
 	public String move() {
-        // TODO: Handle reordering of categories
 		return execute();
 	}
 
-	public String[] getSelectedCategories() {
-		return selectedCategories;
-	}
-
-	public void setSelectedCategories(String[] selectedCategories) {
-		this.selectedCategories = selectedCategories;
-	}
-
-	public String getTargetCategoryId() {
-		return targetCategoryId;
-	}
-
-	public void setTargetCategoryId(String targetCategoryId) {
-		this.targetCategoryId = targetCategoryId;
-	}
-
-	public Set getAllCategories() {
+	public List<WeblogCategory> getAllCategories() {
 		return allCategories;
 	}
 
-	public void setAllCategories(Set allCategories) {
+	public void setAllCategories(List<WeblogCategory> allCategories) {
 		this.allCategories = allCategories;
 	}
 }

Modified: roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml?rev=1571562&r1=1571561&r2=1571562&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml (original)
+++ roller/trunk/app/src/main/resources/org/apache/roller/weblogger/pojos/Weblog.orm.xml Tue
Feb 25 04:42:32 2014
@@ -164,8 +164,9 @@
 				<join-column name="bloggercatid" insertable="true" updatable="true"/>
 			</many-to-one>
             <one-to-many name="weblogCategories" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory"
mapped-by="weblog" fetch="EAGER">
+                <order-by>position</order-by>
                 <cascade>
-                    <cascade-remove/>
+                    <cascade-remove/>                                             
                                                    1
                 </cascade>
             </one-to-many>
 			<transient name="theme"/>



Mime
View raw message