1. Juan Carlos Picado Herrera
  2. encuestame

Commits

Juan Carlos Picado Herrera  committed 2f1b722

Added tweetpoll detail filter by slug name

  • Participants
  • Parent commits d65f343
  • Branches master

Comments (0)

Files changed (17)

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

View file
         return this.getTweetPollById(tweetPollId, getUserPrincipalUsername());
     }
 
+
+    /**
+     *
+     * @param tweetPollId
+     * @param username
+     * @param slug
+     * @return
+     * @throws EnMeNoResultsFoundException
+     */
+    public TweetPoll getTweetPollByIdSlugName(final Long tweetPollId, final String slug) throws EnMeNoResultsFoundException {
+        TweetPoll tweetPoll;
+        try {
+                tweetPoll = getTweetPollDao().getTweetPollByIdandSlugName(tweetPollId, slug);
+            if (tweetPoll == null) {
+                log.error("tweet poll invalid with this id "+tweetPollId);
+                throw new EnMeTweetPollNotFoundException("tweet poll invalid with this id "+tweetPollId);
+            }
+        } catch (UnsupportedEncodingException e) {
+            log.error(e);
+            tweetPoll = null;
+        }
+        return tweetPoll;
+    }
+
     /*
      *
      */

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

View file
     public TweetPoll getTweetPollById(final Long tweetPollId, final String username) throws EnMeNoResultsFoundException;
 
     /**
+    * Get {@link TweetPoll} by id and slug name.
+    * @param tweetPollId
+    * @param username
+    * @param slug
+    * @return
+    * @throws EnMeNoResultsFoundException
+    */
+    TweetPoll getTweetPollByIdSlugName(final Long tweetPollId, final String slug) throws EnMeNoResultsFoundException;
+
+    /**
      * Get complete list of {@link TweetPollSwitch}/
      * @param tweetPoll {@link TweetPoll}.
      * @return resutls.

File encuestame-core/src/main/java/org/encuestame/core/util/ConvertDomainBean.java

View file
         final QuestionBean questionBean = new QuestionBean();
         questionBean.setId(questions.getQid());
         questionBean.setQuestionName(questions.getQuestion());
-        questionBean.setUserId(questions.getAccountQuestion().getUid());
+        questionBean.setSlugName(questions.getSlugQuestion());
+        questionBean.setHits(questions.getHits());
+        questionBean.setUserId(questions.getAccountQuestion() == null ? null : questions.getAccountQuestion().getUid());
         return questionBean;
     }
 

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

View file
         log.debug("detailTweetPollController "+id);
         log.debug("detailTweetPollController "+slug);
         try {
-            //id = filterValue(id);
             slug = filterValue(slug);
-            final TweetPoll tp = getTweetPollService().getTweetPollById(id, null); //TODO: add slug param.
+            final TweetPoll tp = getTweetPollService().getTweetPollByIdSlugName(id, slug); //TODO: add slug param.
             model.addAttribute("tweetpoll", ConvertDomainBean.convertTweetPollToBean(tp));
             final List<TweetPollSwitch> answers = getTweetPollService().getTweetPollSwitch(tp);
             model.addAttribute("answers", answers);

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

View file
 
 package org.encuestame.persistence.dao;
 
+import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.util.List;
 
       TweetPoll getTweetPollByIdandUserId(final Long tweetPollId, final Long userId);
 
       /**
+       * Get {@link TweetPoll} by id, userid and slug name.
+       * @param tweetPollId tweet poll id.
+       * @param userId user id.
+       * @param slugName slug name.
+       * @return
+     * @throws UnsupportedEncodingException
+       */
+      TweetPoll getTweetPollByIdandSlugName(final Long tweetPollId, final String slugName) throws UnsupportedEncodingException;
+
+      /**
        * Retrieve TweetPoll Today.
        * @param keyWord
        * @param userId

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

View file
 
 package org.encuestame.persistence.dao.imp;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.encuestame.persistence.dao.ITweetPoll;
 import org.springframework.dao.support.DataAccessUtils;
 import org.springframework.stereotype.Repository;
 
+import com.lowagie.text.html.HtmlEncoder;
+
 /**
  * TweetPoll Dao Implementation.
  * @author Picado, Juan juan@encuestame.org
          return (TweetPoll) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
     }
 
+    /**
+     * Get {@link TweetPoll} by id, userid and slug name.
+     * @param tweetPollId tweet poll id.
+     * @param userId user id.
+     * @param slugName slug name.
+     * @return
+     * @throws UnsupportedEncodingException
+     */
+    @SuppressWarnings("unchecked")
+    public TweetPoll getTweetPollByIdandSlugName(final Long tweetPollId, final String slugName) throws UnsupportedEncodingException {
+        final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class);
+        criteria.createAlias("question", "q");
+        criteria.add(Restrictions.eq("tweetPollId", tweetPollId));
+        criteria.add(Restrictions.eq("q.slugQuestion", URLEncoder.encode(slugName, "UTF-8")));
+        return (TweetPoll) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
+   }
+
     /*
      * (non-Javadoc)
      * @see org.encuestame.persistence.dao.ITweetPoll#getTweetpollByHashTagName(java.lang.String)

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/question/Question.java

View file
     /**
      * @param slugQuestion the slugQuestion to set
      */
-    public void setSlugQuestion(String slugQuestion) {
+    public void setSlugQuestion(final String slugQuestion) {
         this.slugQuestion = slugQuestion;
     }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/question/QuestionAnswer.java

View file
     public void setCreatedDate(final Date createdDate) {
         this.createdDate = createdDate;
     }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "QuestionAnswer [questionAnswerId=" + questionAnswerId
+                + ", questions=" + questions + ", answer=" + answer
+                + ", uniqueAnserHash=" + uniqueAnserHash + ", urlAnswer="
+                + urlAnswer + ", answerType=" + answerType + ", provider="
+                + provider + ", createdDate=" + createdDate + "]";
+    }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/tweetpoll/TweetPoll.java

View file
         this.updatedDate = updatedDate;
     }
 
-
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "TweetPoll [tweetPollId=" + tweetPollId + ", closeNotification="
+                + closeNotification + ", resultNotification="
+                + resultNotification + ", allowLiveResults=" + allowLiveResults
+                + ", publishTweetPoll=" + publishTweetPoll
+                + ", scheduleTweetPoll=" + scheduleTweetPoll
+                + ", resumeTweetPollDashBoard=" + resumeTweetPollDashBoard
+                + ", scheduleDate=" + scheduleDate + ", createDate="
+                + createDate + ", updatedDate=" + updatedDate + ", completed="
+                + completed + ", captcha=" + captcha + ", limitVotesEnabled="
+                + limitVotesEnabled + ", limitVotes=" + limitVotes
+                + ", resumeLiveResults=" + resumeLiveResults + ", tweetOwner="
+                + tweetOwner + ", editorOwner=" + editorOwner + ", question="
+                + question + ", allowRepatedVotes=" + allowRepatedVotes
+                + ", maxRepeatedVotes=" + maxRepeatedVotes + ", hashTags="
+                + hashTags + ", numbervotes=" + numbervotes + ", hits=" + hits
+                + ", tweetPollFolder=" + tweetPollFolder + ", favourites="
+                + favourites + "]";
+    }
 }

File encuestame-persistence/src/main/java/org/encuestame/persistence/domain/tweetpoll/TweetPollSwitch.java

View file
     public void setDateUpdated(Date dateUpdated) {
         this.dateUpdated = dateUpdated;
     }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "TweetPollSwitch [switchId=" + switchId + ", codeTweet="
+                + codeTweet + ", tweetPoll=" + tweetPoll + ", answers="
+                + answers + ", dateUpdated=" + dateUpdated + ", shortUrl="
+                + shortUrl + "]";
+    }
 }

File encuestame-utils/src/main/java/org/encuestame/utils/web/QuestionBean.java

View file
 import java.util.List;
 
 /**
- * Unit Question Bean.
- *
+ * Question Bean.
  * @author Picado, Juan juanATencuestame.org
  * @since 01/06/2009 15:22:10
- * @version $Id$
  **/
 public class QuestionBean implements Serializable {
 
      */
     private static final long serialVersionUID = -3106607865655197340L;
 
-
+    /**
+     * Question name.
+     */
     private String questionName = new String("");
+
+    /**
+     *  Slug name.
+     */
+    private String slugName;
+
+    /**
+     * Hits.
+     */
+    private Long hits;
+
     /**
      *
      */
         this.userId = userId;
     }
 
+    /**
+     * @return the slugName
+     */
+    public String getSlugName() {
+        return slugName;
+    }
+
+    /**
+     * @param slugName the slugName to set
+     */
+    public void setSlugName(final String slugName) {
+        this.slugName = slugName;
+    }
+
+
+
+    /**
+     * @return the hits
+     */
+    public Long getHits() {
+        return hits;
+    }
+
+    /**
+     * @param hits the hits to set
+     */
+    public void setHits(Long hits) {
+        this.hits = hits;
+    }
+
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */
     @Override
     public String toString() {
-        return "QuestionBean [questionName=" + questionName + "]";
+        return "QuestionBean [questionName=" + questionName + ", slugName="
+                + slugName + ", version=" + version + ", pattern=" + pattern
+                + ", stateId=" + stateId + ", id=" + id + ", userId=" + userId
+                + ", listAnswers=" + listAnswers + "]";
     }
-
-
 }

File encuestame-war/src/main/resources/log4j.xml

View file
     </logger>
 
     <logger name="org.encuestame.persistence">
-        <level value="info" />
+        <level value="debug" />
     </logger>
 
     <logger name="org.encuestame.core">

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

View file
                 </div>
                 <div class="content">
                     <div class="title">
-                         <a href="<%=request.getContextPath()%>/tweetpoll/${item.id}/test">${item.questionBean.questionName}</a>
+                         <a href="<%=request.getContextPath()%>/tweetpoll/${item.id}/${item.questionBean.slugName}">${item.questionBean.questionName}</a>
                     </div>
                     <div class="bottom">
                        <div class="options">

File encuestame-war/src/main/webapp/WEB-INF/views/tweetpoll/web/detail.jsp

View file
 <%@ include file="/WEB-INF/jsp/includes/taglibs.jsp"%>
-<div class="publicMarginWrapper tweetPollDetail">
-   <div class="question">
+<div class="web-tweetpoll-detail ">
+   <div class="question defaultSectionTitle">
         ${tweetpoll.questionBean.questionName}
    </div>
    <c:forEach items="${answers}" var="a">
      <div class="answerVote">
-          ${a.answers.answer}
+          ${a}
      </div>
    </c:forEach>
 </div>

File encuestame-war/src/main/webapp/resource/css/default.css

View file
 
 div.web-profile-wrapper .rss li img{
     float: left;
-    margin-left: 10px;
+    margin-right: 10px;
 }
 
 div.web-profile-wrapper .rss li {

File encuestame-war/src/main/webapp/resource/css/mobile/default.css

View file
 
 div.mobile-profile-wrapper .rss li img{
     float: left;
-    margin-left: 5px;
+    margin-right: 5px;
 }
 
 div.mobile-profile-wrapper .rss li {
   display: block;
   padding-left: 5px;
   vertical-align: middle;
-}
+}
+

File encuestame-war/src/main/webapp/resource/css/public.css

View file
     background-position: bottom left;
     padding: 6px 0 4px 18px; /* push text down 1px */
 }
+
+/** tweetpoll detail **/
+
+div.web-tweetpoll-detail{
+    margin-top: 15px;
+}