Update of 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/forms
In directory 
james.mmbase.org:/tmp/cvs-serv18191/portlets-newsletter/src/java/com/finalist/newsletter/forms

Modified Files:
      Tag: b1_5
        SubscriptioManagementAction.java 
        NewsletterSubscriberSearchAction.java 
Log Message:
CMSC-1283 - Newsletter: improved code efficiency. Added count method. Added 
infix to fullname.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/forms
See also: http://www.mmbase.org/jira/browse/CMSC-1283


Index: SubscriptioManagementAction.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/forms/SubscriptioManagementAction.java,v
retrieving revision 1.13.2.1
retrieving revision 1.13.2.2
diff -u -b -r1.13.2.1 -r1.13.2.2
--- SubscriptioManagementAction.java    22 Oct 2008 05:58:42 -0000      1.13.2.1
+++ SubscriptioManagementAction.java    6 Feb 2009 16:12:45 -0000       1.13.2.2
@@ -171,7 +171,11 @@
       List<Object[]> qResults = subscriptionHService
             .getSubscribersRelatedInfo(authenticationIds, name, "", email, 
true);
       for (Object[] result : qResults) {
-         String tmpFullName = result[0].toString() + " " + 
result[1].toString();
+         String tmpFullName = result[0].toString(); //Firstname
+         if(StringUtils.isNotEmpty(result[1].toString())) { //If infix is not 
empty, add it
+            tmpFullName += " " + result[1].toString();
+         }
+         tmpFullName += " " + result[2].toString(); //Add Lastname
          String tmpEmail = result[2].toString();
          int tmpAuthenticationId = Integer.parseInt(result[3].toString());
          String tmpUserName = result[4].toString();
@@ -205,7 +209,7 @@
       Set<Long> authenticationIds = new HashSet<Long>();
       authenticationIds = 
subscriptionServices.getAuthenticationIdsByNewsletter(newsletterId);
       if (authenticationIds.size() > 0) {
-         resultCount = 
subscriptionHService.getSubscribersRelatedInfo(authenticationIds, name, "", 
email, false).size();
+         resultCount = 
subscriptionHService.getSubscribersRelatedInfoCount(authenticationIds, name, 
"", email, false);
       }
       return resultCount;
    }
@@ -247,13 +251,16 @@
 
       Set<Long> authenticationIds = new HashSet<Long>();
       authenticationIds = subscriptionServices.getAuthenticationIds();
-      List<Object[]> qResults = 
subscriptionHService.getSubscribersRelatedInfo(authenticationIds, fullname, "", 
email,
-            true);
+      List<Object[]> qResults = 
subscriptionHService.getSubscribersRelatedInfo(authenticationIds, fullname, "", 
email, true);
       for (Object[] result : qResults) {
-         String tmpFullName = result[0].toString() + " " + 
result[1].toString();
-         String tmpEmail = result[2].toString();
-         int tmpAuthenticationId = Integer.parseInt(result[3].toString());
-         String tmpUserName = result[4].toString();
+         String tmpFullName = result[0].toString(); //Firstname
+         if(StringUtils.isNotEmpty(result[1].toString())) { //If infix is not 
empty, add it
+            tmpFullName += " " + result[1].toString();
+         }
+         tmpFullName += " " + result[2].toString(); //Add Lastname
+         String tmpEmail = result[3].toString();
+         int tmpAuthenticationId = Integer.parseInt(result[4].toString());
+         String tmpUserName = result[5].toString();
          addToSubscriptionMap(results, tmpFullName, tmpUserName, tmpEmail, 
tmpAuthenticationId);
       }
       return results;
@@ -264,8 +271,7 @@
       Set<Long> authenticationIds = new HashSet<Long>();
       authenticationIds = subscriptionServices.getAuthenticationIds();
       if (authenticationIds.size() > 0) {
-         resultCount = 
subscriptionHService.getSubscribersRelatedInfo(authenticationIds, fullname, "", 
email, false)
-               .size();
+         resultCount = 
subscriptionHService.getSubscribersRelatedInfoCount(authenticationIds, 
fullname, "", email, false);
       }
       return resultCount;
    }


Index: NewsletterSubscriberSearchAction.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/forms/NewsletterSubscriberSearchAction.java,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -b -r1.12 -r1.12.2.1
--- NewsletterSubscriberSearchAction.java       24 Sep 2008 09:56:25 -0000      
1.12
+++ NewsletterSubscriberSearchAction.java       6 Feb 2009 16:12:45 -0000       
1.12.2.1
@@ -10,6 +10,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts.action.ActionForm;
@@ -174,12 +175,16 @@
             email, true);
       for (Object[] result : qResults) {
          
-         String tmpFullName = result[0].toString() + " " + 
result[1].toString();
-         String tmpEmail = result[2].toString();
-         int tmpAuthenticationId = Integer.parseInt(result[3].toString());
+         String tmpFullName = result[0].toString(); //Firstname
+         if(StringUtils.isNotEmpty(result[1].toString())) { //If infix is not 
empty, add it
+            tmpFullName += " " + result[1].toString();
+         }
+         tmpFullName += " " + result[2].toString(); //Add Lastname
+         String tmpEmail = result[3].toString();
+         int tmpAuthenticationId = Integer.parseInt(result[4].toString());
          String tmpNewsletters = 
subscriptionService.getNewsletterNameList(tmpAuthenticationId);
          String tmpTerms = 
subscriptionService.getTermsNameList(tmpAuthenticationId);
-         String tmpUserName = result[4].toString();
+         String tmpUserName = result[5].toString();
          addToMap(results, tmpFullName, tmpUserName, tmpEmail, tmpNewsletters, 
tmpTerms, tmpAuthenticationId);
       }
       return results;
@@ -207,8 +212,7 @@
       
       authenticationIds = 
subscriptionService.getAuthenticationIdsByTerms(newsletterId, terms);
       if (authenticationIds.size() > 0) {
-         resultCount = 
subscriptionHService.getSubscribersRelatedInfo(authenticationIds, fullName, 
userName, email,
-               false).size();
+         resultCount = 
subscriptionHService.getSubscribersRelatedInfoCount(authenticationIds, 
fullName, userName, email, false);
       }
       return resultCount;
    }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to