Package com.uphea.action.admin

Source Code of com.uphea.action.admin.PreviewAction

package com.uphea.action.admin;

import com.uphea.domain.Question;
import com.uphea.service.AnswerService;
import com.uphea.service.QuestionService;
import com.uphea.service.StatsService;
import com.uphea.util.DateUtil;
import jodd.datetime.JDateTime;
import jodd.jtx.meta.Transaction;
import jodd.madvoc.meta.Action;
import jodd.madvoc.meta.In;
import jodd.madvoc.meta.MadvocAction;
import jodd.madvoc.meta.Out;
import jodd.petite.meta.PetiteInject;

/**
* Previews questions.
*/
@MadvocAction
public class PreviewAction {

  @PetiteInject
  QuestionService questionService;

  @PetiteInject
  AnswerService answerService;

  @PetiteInject
  StatsService statsService;

  @In
  Integer date;

  @Out
  Question question;

  @Out
  Question nextQuestion;

  @Out
  Question prevQuestion;

  @Action
  @Transaction
  public void view() {
    JDateTime questionDate = date != null ? DateUtil.toJDateTime(date.intValue()) : new JDateTime();
    question = questionService.findQuestionForDate(questionDate);
    nextQuestion = questionService.findNextQuestion(question);
    prevQuestion = questionService.findPreviousQuestion(question);
    answerService.loadAnswers(question);
    statsService.calcAnswerDistribution(question);
  }

}
TOP

Related Classes of com.uphea.action.admin.PreviewAction

TOP
Copyright © 2018 www.massapi.com. 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.