Package com.liferay.portlet.polls.model

Examples of com.liferay.portlet.polls.model.PollsQuestion


   *            a valid question id
   * @return the PollQuestion
   */
  public PollsQuestion getQuestion(String questionId) {

    PollsQuestion question = null;
    try {
      question = PollsQuestionManagerUtil.getQuestion(questionId);
    } catch (Exception e) {
      Logger.error(this, e.getMessage(),e);
    }
View Full Code Here


   *            a valid question id
   * @return if the question has expired.
   */
  public boolean hasExpired(String questionId) {

    PollsQuestion question = null;
    boolean hasExpired = false;
    try {
      question = PollsQuestionManagerUtil.getQuestion(questionId);
    } catch (Exception e) {
      Logger.error(PollsAPILiferayImpl.class, e.getMessage());
    }
    Date expirationDate = question.getExpirationDate();
    if (expirationDate != null) {
      Date today = new Date();
      if (expirationDate.before(today)) {
        hasExpired = true;
      }
View Full Code Here

   *            a valid question id
   * @return if the question exists.
   */
  public boolean questionExists(String questionId) {

    PollsQuestion question = getQuestion(questionId);
    if (question == null) {
      return false;
    } else {
      return true;
    }
View Full Code Here

    public int compare( Object object1, Object object2 ) throws ClassCastException {
      final int BEFORE = -1;
      final int EQUAL = 0;
      final int AFTER = 1;

      PollsQuestion object11 = (PollsQuestion)object1;
      PollsQuestion object22 = (PollsQuestion)object2;

      if ( object1 == object2 ) return EQUAL;

      if(orderBy.equals("createDate")){
        if (object11.getCreateDate().before(object22.getCreateDate())) return BEFORE * direction;
        if (object11.getCreateDate().after(object22.getCreateDate())) return AFTER * direction;
      }
      if(orderBy.equals("expirationDate")){
        if (object11.getExpirationDate().before(object22.getExpirationDate())) return BEFORE * direction;
        if (object11.getExpirationDate().after(object22.getExpirationDate())) return AFTER * direction;
      }
      if(orderBy.equals("questionId")){
        return object11.getQuestionId().compareTo(object22.getQuestionId());
      }

      assert object1.equals(object2) : "compareTo inconsistent with equals.";

      return EQUAL;
View Full Code Here

            + questionId + "._voted") != null)) {
      hasVoted = true;
    }

    if (!hasVoted) {
      PollsQuestion question = pollsAPI.getQuestion(questionId);
      List choices = pollsAPI.getChoices(questionId);
      Iterator itr = choices.iterator();
 
      htmlResult.append("<table class='poll-answer-table' id='answer" + questionId + "'>");
      while (itr.hasNext()) {
View Full Code Here

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    StringBuffer htmlResult = new StringBuffer(512);
    htmlResult.ensureCapacity(128);

    int totalVotes = pollsAPI.getTotalVotes(questionId);
    PollsQuestion question = pollsAPI.getQuestion(questionId);

    List choices = pollsAPI.getChoices(questionId);

    htmlResult.append("<div id='result" + questionId + "'>");
    //htmlResult.append("<h2>" + question.getDescription() + "</h2>");
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public List<PollsQuestion> displayActivePolls(String questionId)
  {   
    List<PollsQuestion> pollsQuestions = new ArrayList<PollsQuestion>();
    PollsQuestion question = pollsAPI.getQuestion(questionId);
    if(UtilMethods.isSet(question))
    {
      pollsQuestions.add(question);
    }
    return pollsQuestions;
View Full Code Here

    }
    else if (questionId == null) {
      return null;
    }
    else {
      PollsQuestion obj = null;
      String key = questionId.toString();

      if (Validator.isNull(key)) {
        return null;
      }
View Full Code Here

    }
    else if (questionId == null) {
      return null;
    }
    else {
      PollsQuestion obj = null;
      String key = questionId.toString();

      if (Validator.isNull(key)) {
        return null;
      }
View Full Code Here

    User user = UserLocalManagerUtil.getUserById(userId);

    String questionId = Long.toString(CounterManagerUtil.increment(
      PollsQuestion.class.getName()));

    PollsQuestion question = PollsQuestionUtil.create(questionId);

    Date now = new Date();

    Date expirationDate = null;
    if (!neverExpires) {
      expirationDate = PortalUtil.getDate(
        expMonth, expDay, expYear,
        new QuestionExpirationDateException());
    }

    question.setPortletId(portletId);
    question.setCompanyId(user.getCompanyId());
    question.setUserId(user.getUserId());
    question.setUserName(user.getFullName());
    question.setCreateDate(now);
    question.setModifiedDate(now);
    question.setTitle(title);
    question.setDescription(description);
    question.setExpirationDate(expirationDate);
    question.setGroupId("");

    PollsQuestionUtil.update(question);

    // Add choices
View Full Code Here

TOP

Related Classes of com.liferay.portlet.polls.model.PollsQuestion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.