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

Modified Files:
        NewsletterSubscriptionHibernateService.java 
Log Message:
CMSC-990 replace subscriber parts : showing,paging with  ui tags


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


Index: NewsletterSubscriptionHibernateService.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/services/impl/NewsletterSubscriptionHibernateService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NewsletterSubscriptionHibernateService.java 24 Jul 2008 09:04:16 -0000      
1.1
+++ NewsletterSubscriptionHibernateService.java 27 Jul 2008 07:38:09 -0000      
1.2
@@ -7,15 +7,18 @@
 import org.hibernate.Query;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.finalist.cmsc.paging.PagingStatusHolder;
+import com.finalist.cmsc.paging.PagingUtils;
 import com.finalist.cmsc.services.HibernateService;
 import com.finalist.newsletter.services.SubscriptionHibernateService;
 
 public class NewsletterSubscriptionHibernateService extends HibernateService 
implements SubscriptionHibernateService {
 
        @Transactional
-       public List<Object[]> getSubscribersRelatedInfo(Set<Long> 
authenticationIds, String fullName, String userName, String email, int pageSize,
-                       int offset, String order, String direction) {
-               // TODO Auto-generated method stub
+       public List<Object[]> getSubscribersRelatedInfo(Set<Long> 
authenticationIds, String fullName, String userName, String email, boolean 
paging) {
+               // TODO merge with the following function
+
+               PagingStatusHolder pagingHolder = PagingUtils.getStatusHolder();
 
                StringBuffer strb = new StringBuffer(
                                "select person.firstName, person.lastName, 
person.email ,person.authenticationId, authentication1.userId"
@@ -41,54 +44,25 @@
                        idStr.append(")");
                        strb.append(idStr);
                }
+               String order = pagingHolder.getSort();
+
                        if ("fullname".equals(order)) {
                                strb.append(" order by person.firstName");
                        } else if ("username".equals(order)) {
                                strb.append(" order by authentication1.userId");
                        } else if ("email".equals(order)) {
                                strb.append(" order by person.email");
-                       }else if("number".equals(order)){
+               } else {
                                strb.append(" order by person.id");
                        }
-               strb.append(" " + direction);
-               Query query = getSession().createSQLQuery(strb.toString());
-
-               query.setFirstResult(offset);
-               query.setMaxResults(pageSize);
-               List<Object[]> results = query.list();
-               return results;
-       }
+               strb.append(" " + pagingHolder.getDir());
        
-       @Transactional
-       public int getSubscribersCount(Set<Long> authenticationIds, String 
fullName, String userName, String email) {
-               // TODO Auto-generated method stub
-               StringBuffer strb = new StringBuffer(
-                               "select person.firstName, person.lastName, 
person.email ,person.authenticationId, authentication1.userId"
-                                               + " from people person, 
authentication authentication1 " + "where person.authenticationId = 
authentication1.id");
-               if (StringUtils.isNotBlank(fullName)) {
-                       String[] names = fullName.split(" ");
-                       if (names.length >= 2) {
-                               strb.append(" and (person.firstName like '%" + 
names[0] + "%' or person.firstName like '%" + fullName + "%')"
-                                               + " and (person.lastName like 
'%" + names[1] + "%' or person.lastName like '%" + fullName + "%')");
-                       } else if (names.length == 1) {
-                               strb.append(" and (person.firstName like '%" + 
names[0] + "%')");
-                       }
-               }
-               if (StringUtils.isNotBlank(email)) {
-                       strb.append(" and person.email like '%" + email.trim() 
+ "%'");
-               }
-               if (authenticationIds.size() > 0) {
-                       StringBuffer idStr = new StringBuffer(" and 
authentication1.id in (");
-                       for (Long authentication : authenticationIds) {
-                               idStr.append(authentication + ",");
-                       }
-                       idStr.delete(idStr.length() - 1, idStr.length());
-                       idStr.append(")");
-                       strb.append(idStr);
-               }
                Query query = getSession().createSQLQuery(strb.toString());
-               return query.list().size();
+               if (paging) {
+                       query.setFirstResult(pagingHolder.getOffset());
+                       query.setMaxResults(pagingHolder.getPageSize());
        }
        
-       
+               return query.list();
+       }
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to