rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject svn commit: r1210742 - in /incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin: UserController.java WidgetController.java
Date Tue, 06 Dec 2011 01:42:23 GMT
Author: raminder
Date: Tue Dec  6 01:42:23 2011
New Revision: 1210742

URL: http://svn.apache.org/viewvc?rev=1210742&view=rev
Log:
added number of items per page to user and widget admin screen. RAVE-376

Modified:
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
    incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java?rev=1210742&r1=1210741&r2=1210742&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
(original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/UserController.java
Tue Dec  6 01:42:23 2011
@@ -20,11 +20,14 @@
 package org.apache.rave.portal.web.controller.admin;
 
 import org.apache.rave.portal.model.Authority;
+import org.apache.rave.portal.model.PortalPreference;
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.util.SearchResult;
 import org.apache.rave.portal.service.AuthorityService;
+import org.apache.rave.portal.service.PortalPreferenceService;
 import org.apache.rave.portal.service.UserService;
 import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.PortalPreferenceKeys;
 import org.apache.rave.portal.web.util.ViewNames;
 import org.apache.rave.portal.web.validator.UserProfileValidator;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +70,9 @@ public class UserController {
     @Autowired
     private UserProfileValidator userProfileValidator;
 
+    @Autowired
+    private PortalPreferenceService preferenceService;
+
     @InitBinder
     public void initBinder(WebDataBinder dataBinder) {
         dataBinder.registerCustomEditor(Authority.class, new AuthorityEditor());
@@ -78,7 +84,7 @@ public class UserController {
                             @RequestParam(required = false) final String action,
                             Model model) {
         addNavigationMenusToModel(SELECTED_ITEM, model);
-        final SearchResult<User> users = userService.getLimitedListOfUsers(offset,
DEFAULT_PAGE_SIZE);
+        final SearchResult<User> users = userService.getLimitedListOfUsers(offset,
getPageSize());
         model.addAttribute(ModelKeys.SEARCHRESULT, users);
 
         if (isDeleteOrUpdate(action)) {
@@ -93,7 +99,7 @@ public class UserController {
                               @RequestParam(required = false, defaultValue = "0") int offset,
Model model) {
         addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<User> users = userService.getUsersByFreeTextSearch(
-                searchTerm, offset, DEFAULT_PAGE_SIZE);
+                searchTerm, offset, getPageSize());
         model.addAttribute(ModelKeys.SEARCH_TERM, searchTerm);
         model.addAttribute(ModelKeys.SEARCHRESULT, users);
         return ViewNames.ADMIN_USERS;
@@ -180,6 +186,16 @@ public class UserController {
         }
 
     }
-
+   public int getPageSize() {
+        final PortalPreference pageSizePref = preferenceService.getPreference(PortalPreferenceKeys.PAGE_SIZE);
+        if (pageSizePref == null) {
+            return DEFAULT_PAGE_SIZE;
+        }
+        try {
+            return Integer.parseInt(pageSizePref.getValue());
+        } catch (NumberFormatException e) {
+            return DEFAULT_PAGE_SIZE;
+        }
+    }
 
 }

Modified: incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java?rev=1210742&r1=1210741&r2=1210742&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
(original)
+++ incubator/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/admin/WidgetController.java
Tue Dec  6 01:42:23 2011
@@ -19,11 +19,14 @@
 
 package org.apache.rave.portal.web.controller.admin;
 
+import org.apache.rave.portal.model.PortalPreference;
 import org.apache.rave.portal.model.Widget;
 import org.apache.rave.portal.model.WidgetStatus;
 import org.apache.rave.portal.model.util.SearchResult;
+import org.apache.rave.portal.service.PortalPreferenceService;
 import org.apache.rave.portal.service.WidgetService;
 import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.PortalPreferenceKeys;
 import org.apache.rave.portal.web.util.ViewNames;
 import org.apache.rave.portal.web.validator.UpdateWidgetValidator;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -62,6 +65,9 @@ public class WidgetController {
     @Autowired
     private UpdateWidgetValidator widgetValidator;
 
+    @Autowired
+    private PortalPreferenceService preferenceService;
+
     @InitBinder
     public void initBinder(WebDataBinder dataBinder) {
         dataBinder.setDisallowedFields("entityId");
@@ -73,7 +79,7 @@ public class WidgetController {
                               Model model) {
         addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<Widget> widgets =
-                widgetService.getLimitedListOfWidgets(offset, DEFAULT_PAGE_SIZE);
+                widgetService.getLimitedListOfWidgets(offset, getPageSize());
         model.addAttribute(ModelKeys.SEARCHRESULT, widgets);
 
         if (isDeleteOrUpdate(action)) {
@@ -90,7 +96,7 @@ public class WidgetController {
                                 @RequestParam(required = false, defaultValue = "0") int offset,
Model model) {
         addNavigationMenusToModel(SELECTED_ITEM, model);
         final SearchResult<Widget> widgets = widgetService.getWidgetsBySearchCriteria(searchTerm,
widgettype,
-                widgetstatus, offset, DEFAULT_PAGE_SIZE);
+                widgetstatus, offset, getPageSize());
         model.addAttribute(ModelKeys.SEARCHRESULT, widgets);
         model.addAttribute(ModelKeys.SEARCH_TERM, searchTerm);
         model.addAttribute("selectedWidgetType", widgettype);
@@ -138,4 +144,15 @@ public class WidgetController {
         this.widgetValidator = widgetValidator;
     }
 
+    public int getPageSize() {
+        final PortalPreference pageSizePref = preferenceService.getPreference(PortalPreferenceKeys.PAGE_SIZE);
+        if (pageSizePref == null) {
+            return DEFAULT_PAGE_SIZE;
+        }
+        try {
+            return Integer.parseInt(pageSizePref.getValue());
+        } catch (NumberFormatException e) {
+            return DEFAULT_PAGE_SIZE;
+        }
+    }
 }



Mime
View raw message