Commits

Juan Carlos Picado Herrera  committed bc00335 Merge

Merge

  • Participants
  • Parent commits f4cb46e, 43529dc

Comments (0)

Files changed (17)

File encuestame-business/src/main/java/org/encuestame/business/service/FrontEndService.java

      */
     public List<TweetPollBean> searchItemsByTweetPoll(
                 final String period,
+                final Integer start,
                 Integer maxResults,
                 final HttpServletRequest request)
                 throws EnMeSearchException{
         } else {
             final SearchPeriods periodSelected = SearchPeriods.getPeriodString(period);
             if(periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)){
-                items.addAll(getFrontEndDao().getTweetPollFrontEndLast24(maxResults));
+                items.addAll(getFrontEndDao().getTweetPollFrontEndLast24(start, maxResults));
             } else if(periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)){
-                items.addAll(getFrontEndDao().getTweetPollFrontEndLast24(maxResults));
+                items.addAll(getFrontEndDao().getTweetPollFrontEndLast24(start, maxResults));
             } else if(periodSelected.equals(SearchPeriods.SEVENDAYS)){
-                items.addAll(getFrontEndDao().getTweetPollFrontEndLast7Days(maxResults));
+                items.addAll(getFrontEndDao().getTweetPollFrontEndLast7Days(start, maxResults));
             } else if(periodSelected.equals(SearchPeriods.THIRTYDAYS)){
-                items.addAll(getFrontEndDao().getTweetPollFrontEndLast30Days(maxResults));
+                items.addAll(getFrontEndDao().getTweetPollFrontEndLast30Days(start, maxResults));
             } else if(periodSelected.equals(SearchPeriods.ALLTIME)){
-                items.addAll(getFrontEndDao().getTweetPollFrontEndAllTime(maxResults));
+                items.addAll(getFrontEndDao().getTweetPollFrontEndAllTime(start, maxResults));
             }
             log.debug("TweetPoll "+items.size());
             results.addAll(ConvertDomainBean.convertListToTweetPollBean(items));
      */
     public List<UnitPoll> searchItemsByPoll(
             final String period,
+            final Integer start,
             Integer maxResults)
             throws EnMeSearchException{
     final List<UnitPoll> results = new ArrayList<UnitPoll>();
     } else {
         final SearchPeriods periodSelected = SearchPeriods.getPeriodString(period);
         if(periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)){
-            items.addAll(getFrontEndDao().getPollFrontEndLast24(maxResults));
+            items.addAll(getFrontEndDao().getPollFrontEndLast24(start, maxResults));
         } else if(periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)){
-            items.addAll(getFrontEndDao().getPollFrontEndLast24(maxResults));
+            items.addAll(getFrontEndDao().getPollFrontEndLast24(start, maxResults));
         } else if(periodSelected.equals(SearchPeriods.SEVENDAYS)){
-            items.addAll(getFrontEndDao().getPollFrontEndLast7Days(maxResults));
+            items.addAll(getFrontEndDao().getPollFrontEndLast7Days(start, maxResults));
         } else if(periodSelected.equals(SearchPeriods.THIRTYDAYS)){
-            items.addAll(getFrontEndDao().getPollFrontEndLast30Days(maxResults));
+            items.addAll(getFrontEndDao().getPollFrontEndLast30Days(start, maxResults));
         } else if(periodSelected.equals(SearchPeriods.ALLTIME)){
-            items.addAll(getFrontEndDao().getPollFrontEndAllTime(maxResults));
+            items.addAll(getFrontEndDao().getPollFrontEndAllTime(start, maxResults));
         }
         log.debug("Poll "+items.size());
         results.addAll(ConvertDomainBean.convertListToPollBean((items)));
      */
     public List<HashTagBean> getHashTags(
               Integer maxResults,
-              final Integer start){
+              final Integer start,
+              final String tagCriteria){
         final List<HashTagBean> hashBean = new ArrayList<HashTagBean>();
         if(maxResults == null){
             maxResults = this.MAX_RESULTS;
         }
         log.debug("Max Results HashTag -----> "+maxResults);
         List<HashTag> tags = new ArrayList<HashTag>();
-        tags.addAll(getHashTagDao().getHashTags(maxResults, start));
+        tags.addAll(getHashTagDao().getHashTags(maxResults, start, tagCriteria));
         log.debug("Hashtag total size ---> "+tags.size());
         hashBean.addAll(ConvertDomainBean.convertListHashTagsToBean(tags));
 
     public List<TweetPollBean> getTweetPollsbyHashTagId(
             final Long hashTagId,
             final Integer limit,
+            final String filter,
             final HttpServletRequest request){
-        final List<TweetPoll> tweetPolls = getTweetPollDao().getTweetpollByHashTagId(hashTagId, limit);
+        final List<TweetPoll> tweetPolls = getTweetPollDao().getTweetpollByHashTagId(hashTagId, limit, filter);
         log.debug("TweetPoll by HashTagId total size ---> "+tweetPolls.size());
         final List<TweetPollBean> tweetPollBean = ConvertDomainBean.convertListToTweetPollBean(tweetPolls);
         for (TweetPollBean tweetPoll : tweetPollBean) {
         return tweetPollBean;
     }
 
-
-    public List<TweetPollBean> searchItemsByTweetPollTopRated(
-            final String period,
-            Integer maxResults,
-            final HttpServletRequest request)
-            throws EnMeSearchException{
-    final List<TweetPollBean> results = new ArrayList<TweetPollBean>();
-    if(maxResults == null){
-        maxResults = this.MAX_RESULTS;
-    }
-    log.debug("Max Results "+maxResults);
-    final List<TweetPoll> items = new ArrayList<TweetPoll>();
-    if(period == null ){
-        throw new EnMeSearchException("search params required.");
-    } else {
-        final SearchPeriods periodSelected = SearchPeriods.getPeriodString(period);
-        if(periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)){
-            items.addAll(getFrontEndDao().getTweetPollFrontEndLast24(maxResults));
-        } else if(periodSelected.equals(SearchPeriods.TWENTYFOURHOURS)){
-            items.addAll(getFrontEndDao().getTweetPollFrontEndLast24(maxResults));
-        } else if(periodSelected.equals(SearchPeriods.SEVENDAYS)){
-            items.addAll(getFrontEndDao().getTweetPollFrontEndLast7Days(maxResults));
-        } else if(periodSelected.equals(SearchPeriods.THIRTYDAYS)){
-            items.addAll(getFrontEndDao().getTweetPollFrontEndLast30Days(maxResults));
-        } else if(periodSelected.equals(SearchPeriods.ALLTIME)){
-            items.addAll(getFrontEndDao().getTweetPollFrontEndAllTime(maxResults));
-        }
-        log.debug("TweetPoll "+items.size());
-        results.addAll(ConvertDomainBean.convertListToTweetPollBean(items));
-        for (TweetPollBean tweetPoll : results) {
-            tweetPoll = convertTweetPollRelativeTime(tweetPoll, request);
-        }
-
-    }
-    return results;
-}
-
-
-
     /**
      * Get tweetPoll by top rated.
      * @param hashTagId
      * @param request
      * @return
      */
-    public List<TweetPollBean> getTweetPollsbyTopRated(
+  /*  public List<TweetPollBean> getTweetPollsbyTopRated(
             final Long hashTagId,
             final Integer limit,
             final HttpServletRequest request){
         }
         return tweetPollBean;
     }
-
+*/
     /**
-     *
+     * Get hashTag relevance.
      * @param hashTagId
      * @param limit
      * @return
     public Integer getHashTagRelevance(final Long hashTagId, final Integer limit){
         final Integer totalRelTweetPoll;
         final Integer relevance;
-        final List<TweetPoll> tweetPolls = getTweetPollDao().getTweetpollByHashTagId(hashTagId, limit);
+        final List<TweetPoll> tweetPolls = getTweetPollDao().getTweetpollByHashTagId(hashTagId, limit, "");
         totalRelTweetPoll = tweetPolls.size();
         relevance = totalRelTweetPoll;
         //TODO:Pending count relevance hashtags for polls and surveys.

File encuestame-business/src/main/java/org/encuestame/business/service/imp/IFrontEndService.java

      */
      List<TweetPollBean> searchItemsByTweetPoll(
             final String period,
+            final Integer start,
             Integer maxResults,
             final HttpServletRequest request)
             throws EnMeSearchException;
       */
     List<UnitPoll> searchItemsByPoll(
              final String period,
+             final Integer start,
              Integer maxResults)
              throws EnMeSearchException;
 
      * List Hash tags
      * @param maxResults
      * @param start
+     * @param tagCriteria
      * @return
      */
     List<HashTagBean> getHashTags(
             Integer maxResults,
-            final Integer start);
+            final Integer start,
+            final String tagCriteria);
 
     /**
      * Get hashTag item.
      * @param request
      * @return
      */
-    List<TweetPollBean> getTweetPollsbyHashTagId(final Long hashTagId, final Integer limit, final HttpServletRequest request);
+    List<TweetPollBean> getTweetPollsbyHashTagId(final Long hashTagId, final Integer limit, final String filter, final HttpServletRequest request);
 
     /**
      * Get TweetPolls by top rated.
      * @param request
      * @return
      */
-    List<TweetPollBean> getTweetPollsbyTopRated(final Long hashTagId, final Integer limit, final HttpServletRequest request);
+    //List<TweetPollBean> getTweetPollsbyTopRated(final Long hashTagId, final Integer limit, final HttpServletRequest request);
 }

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/FrontEndJsonController.java

+/*
+ ************************************************************************************
+ * Copyright (C) 2001-2010 encuestame: system online surveys Copyright (C) 2009
+ * encuestame Development Team.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.encuestame.mvc.controller.json;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.collections.ListUtils;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.encuestame.core.util.ConvertDomainBean;
+import org.encuestame.mvc.controller.AbstractJsonController;
+import org.encuestame.persistence.dao.SearchPeriods;
+import org.encuestame.persistence.domain.tweetpoll.TweetPoll;
+import org.encuestame.persistence.exception.EnMeSearchException;
+import org.encuestame.utils.web.HashTagBean;
+import org.encuestame.utils.web.TweetPollBean;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Frontend json controller.
+ * @author Morales, Diana Paola paolaATencuestame.org
+ * @since July 04, 2011
+ */
+
+@Controller
+public class FrontEndJsonController extends AbstractJsonController{
+
+
+    /** Log. **/
+    private Logger log = Logger.getLogger(this.getClass());
+
+    /**
+     * Get frontend items.
+     * @param period
+     * @param maxResults
+     * @param request
+     * @param response
+     * @return
+     * @throws JsonGenerationException
+     * @throws JsonMappingException
+     * @throws IOException
+     */
+    @RequestMapping(value = "/api/common/frontend/stream.json", method = RequestMethod.GET)
+    public ModelMap getFrontendItems(
+            @RequestParam(value = "period", required = false) String period,
+            @RequestParam(value = "maxResults", required = false) Integer maxResults,
+            @RequestParam(value = "start", required = false) Integer start,
+            HttpServletRequest request,
+            HttpServletResponse response) throws JsonGenerationException, JsonMappingException, IOException {
+            try {
+                final Map<String, Object> jsonResponse = new HashMap<String, Object>();
+                if(period == null ){
+                    throw new EnMeSearchException("search params required.");
+                } else {
+                    final  List<TweetPollBean> itemList = getFrontService().searchItemsByTweetPoll(period, start, maxResults, request);
+                    jsonResponse.put("frontendItems", itemList);
+                    setItemResponse(jsonResponse);
+                   }
+            } catch (Exception e) {
+                 log.error(e);
+                 e.printStackTrace();
+            }
+            return returnData();
+        }
+}

File encuestame-mvc/src/main/java/org/encuestame/mvc/controller/json/HashTagsJsonController.java

              final IFrontEndService service = getFrontService();
              final List<HashTagBean> hashTagList;
              if(limit == null){
-                 hashTagList = service.getHashTags(20, 0); // TODO: Add to file properties limit to show hashtags.
+                 hashTagList = service.getHashTags(20, 0, "hashTagsCloud"); // TODO: Add to file properties limit to show hashtags.
              }
              else {
-                hashTagList = service.getHashTags(limit, 0);
+                hashTagList = service.getHashTags(limit, 0, "hashTagsCloud");
              }
              jsonResponse.put("cloud", hashTagList);
              setItemResponse(jsonResponse);

File encuestame-mvc/src/main/java/org/encuestame/mvc/view/HashTagController.java

     /** Log. **/
         private Log log = LogFactory.getLog(this.getClass());
 
+        /** HashTag max results. **/
+        private final Integer MAX_HASHTAG = 80;
+
+        /** HashTag max results. **/
+        private final Integer LIMIT_HASHTAG = 15;
     /**
      * HashTag List.
      * @param model
     public String hashTagController(ModelMap model, HttpServletRequest request,
                   HttpServletResponse response) {
         final IFrontEndService service = getFrontService();
-        final List<HashTagBean> hashTagList = service.getHashTags(20, 0); //TODO: Add to file properties number 20
+        final List<HashTagBean> hashTagList = service.getHashTags(MAX_HASHTAG, 0, "hashTagsCloud"); //TODO: Add to file properties number 20
         log.debug("Tag list size ---> "+ hashTagList.size());
         model.addAttribute("hashtags", hashTagList);
         return "cloud";
         try {
             final HashTagBean tag = service.getHashTagItem(name);
             log.debug("hashTag Id ---> "+ tag.getId());
-            final List<TweetPollBean> tweetPoll = service.getTweetPollsbyHashTagId(tag.getId(), 10, request);
-            log.debug("TweetPolls by HashTag Id ---> "+ tweetPoll.size());
+            final List<TweetPollBean> tweetPollbyTags = service.getTweetPollsbyHashTagId(tag.getId(), LIMIT_HASHTAG, "hashtag", request);
+            log.debug("TweetPolls by HashTag Id ---> "+ tweetPollbyTags.size());
 
-            final List<TweetPollBean> tweetPollrated = service.getTweetPollsbyTopRated(tag.getId(), 10, request);
-            log.debug("TweetPolls by Top rated ---> "+ tweetPoll.size());
+            final List<TweetPollBean> tweetPollbyRated = service.getTweetPollsbyHashTagId(tag.getId(), LIMIT_HASHTAG, "hashtagRated", request);
+            log.debug("TweetPolls by Top rated ---> "+ tweetPollbyTags.size());
             if (tag == null) {
                 return "pageNotFound";
             } else {
                 model.addAttribute("tagName", service.getHashTagItem(name));
-                model.addAttribute("tweetPolls", service.getTweetPollsbyHashTagId(tag.getId(), 10, request));
-                model.addAttribute("tweetPollrated", service.getTweetPollsbyTopRated(tag.getId(), 10, request));
+                model.addAttribute("tweetPolls", tweetPollbyTags);
+                model.addAttribute("tweetPollrated", tweetPollbyRated);
             }
         } catch (Exception e) {
             log.error(e);

File encuestame-mvc/src/main/java/org/encuestame/mvc/view/HomeController.java

     */
     private Log log = LogFactory.getLog(this.getClass());
 
+    /** HashTag max results. **/
+    private final Integer MAX_HASHTAG = 80;
+
+    /** Items max results. **/
+    private final Integer MAX_ITEMS = 10;
     /**
     * Home Controller.
     *
             final IFrontEndService service = getFrontService();
             try {
                 if (view.isEmpty()) {
-                    model.addAttribute("items", service.searchItemsByTweetPoll(period, 20, request));
+                    model.addAttribute("items", service.searchItemsByTweetPoll(period, 0 ,MAX_ITEMS, request));
                 } else {
                     if ("tweetpoll".equals(view)){
-                        model.addAttribute("items", service.searchItemsByTweetPoll(period, 20, request));
+                        model.addAttribute("items", service.searchItemsByTweetPoll(period, 0 ,MAX_ITEMS, request));
                     } else if("poll".equals(view)){
-                        model.addAttribute("items", service.searchItemsByPoll(period, 20));
+                        model.addAttribute("items", service.searchItemsByPoll(period, 0 ,MAX_ITEMS));
                     } else if("survey".equals(view)){
-                        model.addAttribute("items", service.searchItemsByTweetPoll(period, 20, request));
+                        model.addAttribute("items", service.searchItemsByTweetPoll(period, 0 ,MAX_ITEMS, request));
                     }
                 }
-                model.addAttribute("hashTags", service.getHashTags(30, 0));
+                model.addAttribute("hashTags", service.getHashTags(MAX_HASHTAG, 0, ""));
                 //TODO: search hashtags and other information.
             } catch (EnMeSearchException e) {
                 return "error";

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/IFrontEndDao.java

      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<TweetPoll> getTweetPollFrontEndLast30Days(final Integer maxResults);
+    List<TweetPoll> getTweetPollFrontEndLast30Days(final Integer start, final Integer maxResults);
 
     /**
      * Get TweetPoll Last 7 Days
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<TweetPoll> getTweetPollFrontEndLast7Days(final Integer maxResults);
+    List<TweetPoll> getTweetPollFrontEndLast7Days(final Integer start, final Integer maxResults);
 
     /**
      * Get TweetPoll Last 24 Hours.
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<TweetPoll> getTweetPollFrontEndLast24(final Integer maxResults);
+    List<TweetPoll> getTweetPollFrontEndLast24(final Integer start, final Integer maxResults);
 
     /**
      * Get Poll Last 24 Hours.
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<Poll> getPollFrontEndLast24(final Integer maxResults);
+    List<Poll> getPollFrontEndLast24(final Integer start, final Integer maxResults);
 
     /**
      * Get Poll Last 7 Days
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<Poll> getPollFrontEndLast7Days(final Integer maxResults);
+    List<Poll> getPollFrontEndLast7Days(final Integer start, final Integer maxResults);
 
     /**
      * Get Poll Last 30 Days
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<Poll> getPollFrontEndLast30Days(final Integer maxResults);
+    List<Poll> getPollFrontEndLast30Days(final Integer start, final Integer maxResults);
 
     /**
      * Get Poll on All Time.
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<Poll> getPollFrontEndAllTime(final Integer maxResults);
+    List<Poll> getPollFrontEndAllTime(final Integer start, final Integer maxResults);
 
     /**
      * Get TweetPoll all time.
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    List<TweetPoll> getTweetPollFrontEndAllTime(final Integer maxResults);
+    List<TweetPoll> getTweetPollFrontEndAllTime(final Integer start, final Integer maxResults);
 
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/IHashTagDao.java

      * Get hashTags.
      * @param maxResults
      * @param start
+     * @param tagCriteria
      * @return
      */
-    List<HashTag> getHashTags( final Integer maxResults,final Integer start);
+    List<HashTag> getHashTags( final Integer maxResults,final Integer start, final String tagCriteria);
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/ITweetPoll.java

      */
     List<TweetPollSwitch> getAnswerTweetSwitch(final QuestionAnswer questionAnswer);
 
-    /**
-     * Get TweetPoll by hashTag id.
-     * @param hashTag
-     * @param limit
-     * @return
-     */
-    List getTweetpollByHashTagId(final Long hashTag,  final Integer limit);
-
-    /**
+     /**
      * Get tweetPoll by top rated.
      * @param hashTagId
      * @param limit
+     * @param limit
      * @return
      */
-    List<TweetPoll> getTweetpollByTopRated(final Long hashTagId, final Integer limit);
+   List<TweetPoll> getTweetpollByHashTagId(final Long hashTagId, final Integer limit, final String filterby);
 
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/FrontEndDao.java

      * @return list of tweetPoll.
      */
     @SuppressWarnings("unchecked")
-    public final List<TweetPoll> getTweetPollFrontEnd(Integer period, final Integer maxResults, final Integer firstResult){
+    public final List<TweetPoll> getTweetPollFrontEnd(Integer period, final Integer start, final Integer maxResults, final Integer firstResult){
         final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class);
             criteria.createAlias("question", "question");
         if (period != null) {
             criteria.add(Restrictions.between("createDate", startDate, endDate));
         }
         criteria.add(Restrictions.eq("publishTweetPoll", Boolean.TRUE)); //should be published
-        return getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults);
+        return (List<TweetPoll>) filterByMaxorStart(criteria, maxResults, start);
+        //return getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults);
     }
 
     /**
      * @return list of poll.
      */
     @SuppressWarnings("unchecked")
-    public final List<Poll> getPollFrontEnd(final Integer period, final Integer maxResults, final Integer firstResult){
+    public final List<Poll> getPollFrontEnd(final Integer period, final Integer start, final Integer maxResults, final Integer firstResult){
         final DetachedCriteria criteria = DetachedCriteria.forClass(Poll.class);
         criteria.createAlias("question", "question");
         if(period != null){
             criteria.add(Restrictions.between("createdAt", Calendar.getInstance().getTime(), hi.getTime()));
         }
         criteria.add(Restrictions.eq("publish", Boolean.TRUE)); //should be published
-        return getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults);
+        return (List<Poll>) filterByMaxorStart(criteria, maxResults, start);
+        //return getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final List<TweetPoll> getTweetPollFrontEndLast24(final Integer maxResults){
-        return this.getTweetPollFrontEnd(this.PERIOD_24, maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final List<TweetPoll> getTweetPollFrontEndLast24(final Integer start, final Integer maxResults){
+        return this.getTweetPollFrontEnd(this.PERIOD_24, start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final List<TweetPoll> getTweetPollFrontEndLast7Days(final Integer maxResults) {
-        return this.getTweetPollFrontEnd(this.PERIOD_7_DAYS , maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final List<TweetPoll> getTweetPollFrontEndLast7Days(final Integer start, final Integer maxResults) {
+        return this.getTweetPollFrontEnd(this.PERIOD_7_DAYS , start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final List<TweetPoll> getTweetPollFrontEndLast30Days(final Integer maxResults){
-        return this.getTweetPollFrontEnd(this.PERIOD_30_DAYS , maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final List<TweetPoll> getTweetPollFrontEndLast30Days(final Integer start, final Integer maxResults){
+        return this.getTweetPollFrontEnd(this.PERIOD_30_DAYS , start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final List<TweetPoll> getTweetPollFrontEndAllTime(final Integer maxResults){
-        return this.getTweetPollFrontEnd(this.PERIOD_ALL , maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final List<TweetPoll> getTweetPollFrontEndAllTime(final Integer start, final Integer maxResults){
+        return this.getTweetPollFrontEnd(this.PERIOD_ALL , start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final  List<Poll> getPollFrontEndLast24(final Integer maxResults){
-        return this.getPollFrontEnd(this.PERIOD_24, maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final  List<Poll> getPollFrontEndLast24(final Integer start, final Integer maxResults){
+        return this.getPollFrontEnd(this.PERIOD_24, start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public List<Poll> getPollFrontEndLast7Days(final Integer maxResults){
-        return this.getPollFrontEnd(this.PERIOD_7_DAYS , maxResults, this.WITHOUT_FIRST_RESULTS);
+    public List<Poll> getPollFrontEndLast7Days(final Integer start, final Integer maxResults){
+        return this.getPollFrontEnd(this.PERIOD_7_DAYS ,start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final List<Poll> getPollFrontEndLast30Days(final Integer maxResults){
-        return this.getPollFrontEnd(this.PERIOD_30_DAYS , maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final List<Poll> getPollFrontEndLast30Days(final Integer start, final Integer maxResults){
+        return this.getPollFrontEnd(this.PERIOD_30_DAYS , start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**
      * @param maxResults max results
      * @return list of tweetPoll.
      */
-    public final List<Poll> getPollFrontEndAllTime(final Integer maxResults){
-        return this.getPollFrontEnd(this.PERIOD_ALL , maxResults, this.WITHOUT_FIRST_RESULTS);
+    public final List<Poll> getPollFrontEndAllTime(final Integer start, final Integer maxResults){
+        return this.getPollFrontEnd(this.PERIOD_ALL , start, maxResults, this.WITHOUT_FIRST_RESULTS);
     }
 
     /**

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/HashTagDao.java

     */
     @SuppressWarnings("unchecked")
     public List<HashTag> getHashTags( final Integer maxResults,
-                    final Integer start){
+                    final Integer start,
+                    final String tagCriteria){
         final DetachedCriteria criteria = DetachedCriteria.forClass(HashTag.class);
-        criteria.add(Restrictions.gt("hits", 0L));//review
-        criteria.addOrder(Order.desc("hits"));
-        criteria.addOrder(Order.asc("hashTag"));
+        if(tagCriteria.equals("hashTagsCloud")){
+            criteria.add(Restrictions.gt("hits", 0L));//review
+        }
+        else {
+            criteria.addOrder(Order.desc("hits"));
+            criteria.addOrder(Order.asc("hashTag"));
+        }
         return (List<HashTag>) filterByMaxorStart(criteria, maxResults, start);
     }
 

File encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/TweetPollDao.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.encuestame.persistence.dao.ITweetPoll;
+import org.encuestame.persistence.dao.SearchPeriods;
 
 import org.encuestame.persistence.domain.HashTag;
 import org.encuestame.persistence.domain.question.QuestionAnswer;
      * @see org.encuestame.persistence.dao.ITweetPoll#getTweetpollByHashTagName(java.lang.String)
      */
     @SuppressWarnings("unchecked")
-    public List<TweetPoll> getTweetpollByHashTagId(final Long hashTagId, final Integer limit){
+    public List<TweetPoll> getTweetpollByHashTagId(final Long hashTagId, final Integer limit, final String filterby){
          final DetachedCriteria detached = DetachedCriteria.forClass(TweetPoll.class)
         .createAlias("hashTags", "hashTags")
         .setProjection(Projections.id())
               .add(Restrictions.in("hash.hashTagId", new Long[] {hashTagId}))));
         final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class, "tweetPoll");
         criteria.add(Subqueries.propertyIn("tweetPoll.tweetPollId", detached));
-        criteria.addOrder(Order.desc("tweetPoll.createDate"));
+        if(filterby.equals("hashtag")){
+            criteria.addOrder(Order.desc("tweetPoll.createDate"));
+        }
+        else if (filterby.equals("hashtagRated")){
+            criteria.addOrder(Order.desc("numbervotes"));
+        }
         return getHibernateTemplate().findByCriteria(criteria, 0, limit);
     }
-
-
-    @SuppressWarnings("unchecked")
-       public List<TweetPoll> getTweetpollByTopRated(final Long hashTagId, final Integer limit){
-           final DetachedCriteria detached = DetachedCriteria.forClass(TweetPoll.class)
-           .createAlias("hashTags", "hashTags")
-           .setProjection(Projections.id())
-           .add(Subqueries.propertyIn("hashTags.hashTagId",
-           DetachedCriteria.forClass(HashTag.class, "hash")
-                 .setProjection(Projections.id())
-                 .add(Restrictions.in("hash.hashTagId", new Long[] {hashTagId}))));
-           final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class, "tweetPoll");
-           criteria.add(Subqueries.propertyIn("tweetPoll.tweetPollId", detached));
-           criteria.addOrder(Order.desc("numbervotes"));
-           return getHibernateTemplate().findByCriteria(criteria, 0, limit);
-       }
-
-
-    /**
-     *
-     * @return
-     */
-    public TweetPoll getNumberVotes(final Long tweetPollId){
-        final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class);
-        criteria.add(Restrictions.eq("tweetPollId", tweetPollId));
-        return (TweetPoll) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
-    }
 }

File encuestame-persistence/src/test/java/org/encuestame/test/config/AbstractBase.java

 import org.encuestame.persistence.domain.tweetpoll.TweetPollResult;
 import org.encuestame.persistence.domain.tweetpoll.TweetPollSwitch;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
-import org.encuestame.utils.oauth.AccessGrant;
-import org.encuestame.utils.oauth.OAuth1Token;
 import org.hibernate.search.FullTextSession;
 import org.hibernate.search.Search;
 import org.springframework.beans.factory.annotation.Autowired;

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestHashTagDao.java

 
         final int limit = 20;
         final int start = 0;
-        final List<HashTag> results = getHashTagDao().getHashTags(limit, start);
+        final List<HashTag> results = getHashTagDao().getHashTags(limit, start, "");
         Assert.assertNotNull(results);
         assertEquals("Should be equals", 4, results.size());
 

File encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestTweetPollDao.java

         final Calendar calendar2 = Calendar.getInstance();
         System.out.println("SECOND CALENDAR--"+ calendar2.getTime());
 
-        final List<TweetPoll> tweetPolls = getTweetPoll().getTweetpollByHashTagId(this.hashTag1.getHashTagId(), limit);
+        final List<TweetPoll> tweetPolls = getTweetPoll().getTweetpollByHashTagId(this.hashTag1.getHashTagId(), limit, "hashtag");
         assertEquals("Should be equals", 1, tweetPolls.size());
         final HashTag hashtag2 = createHashTag("paola");
         final HashTag hashtag3 = createHashTag("juan");
         final HashMap<Integer, RelativeTimeEnum> hm3 = DateUtil.getRelativeTime(tweetPoll1.getCreateDate());
         System.out.println("HM 3 ---------->"+hm3);
 
-        final List<TweetPoll> tweetPolls2 = getTweetPoll().getTweetpollByHashTagId(this.hashTag1.getHashTagId(), limit);
+        final List<TweetPoll> tweetPolls2 = getTweetPoll().getTweetpollByHashTagId(this.hashTag1.getHashTagId(), limit, "hashtag");
         System.out.println("------------- HASH TAG NAME---------> " + this.hashTag1.getHashTag());
 
 
 
 
 
-        final List<TweetPoll> tweetPolls2 = getTweetPoll().getTweetpollByTopRated(this.hashTag1.getHashTagId(), limit);
+        final List<TweetPoll> tweetPolls2 = getTweetPoll().getTweetpollByHashTagId(this.hashTag1.getHashTagId(), limit, "hashtagRated");
         System.out.println("------------- HASH TAG NAME---------> " + this.hashTag1.getHashTag());
 
         for (TweetPoll tweetPoll : tweetPolls2) {

File encuestame-war/src/main/webapp/WEB-INF/layouts/standard/header.jsp

                  </span>
             </div>
      </div>
-</div>
+</div>

File encuestame-war/src/main/webapp/WEB-INF/views/home/mobile/profile.jsp

             </li>
         </ul>
     </div>
-</div>
+</div>
+<div>Cloud Page</div>
+ <c:forEach items="${hashtags}" var="cloud">
+     <span class="item" style="font-size: ${cloud.size}px;">
+         <a href="<%=request.getContextPath()%>/tag/${cloud.hashTagName}/">${cloud.hashTagName}</a>
+     </span>
+   </c:forEach>
+