Package com.uphea.domain

Examples of com.uphea.domain.Question


      String fileName = file.getHeader().getFileName();
      String baseName = FileNameUtil.getBaseName(fileName);
      id = Long.valueOf(baseName);
    }

    Question question = questionService.findQuestionById(id);
    if ((question != null) && file.isValid()) {
      System.out.println(file);
      try {
        FileUtil.writeBytes(new File(appData.getImgRoot(), question.getId() + ".jpg"), file.getFileContent());
      } catch (IOException ioex) {
        log.error("Unable to save uploaded file.", ioex);
        throw new UpheaException("Unable to save uploaded file.", ioex);
      }
    }
View Full Code Here


   * <li>it holds custom data that will be used for rendering.
   */
  @Action("/uphea.xml")
  @Transaction
  public RssData view() {
    Question latestQuestion = questionService.findQuestionForDate(new JDateTime());
    List<Question> questions = questionService.findPreviousQuestions(latestQuestion, 24);
    questions.add(0, latestQuestion);

    Feed feed = new Feed();
    feed.setTitle("uphea.com");
    feed.setLink("http://uphea.com");
    feed.setDescription("the nice way of asking smart questions");
    feed.setEncoding(StringPool.UTF_8);
    feed.setPublishedDate(DateUtil.toJDateTime(latestQuestion.getDate()));

    for (Question q : questions) {
      FeedEntry entry = new FeedEntry();
      entry.setPublishedDate(DateUtil.toJDateTime(q.getDate()));
      entry.setTitle(Format.textPlain(q.getText()));
View Full Code Here

   * JSON action, with no extension.
   */
  @Action(extension = Action.NONE)
  @Transaction
  public String view() {
    Question question = questionService.findQuestionForDate(new JDateTime());
    answerService.loadAnswers(question);

    StringBuilder json = new StringBuilder();
    json.append('{');
    json.append("\"question\": \"").append(Format.textPlain(question.getText())).append("\",");
    json.append("\"answers\": [");
    List<Answer> answers = question.getAnswers();
    for (int i = 0, answersSize = answers.size(); i < answersSize; i++) {
      if (i != 0) {
        json.append(',');
      }
      Answer answer = answers.get(i);
View Full Code Here

  @Override
  public void run() {
    com.uphea.action.IndexAction indexAction = petite.createBean(com.uphea.action.IndexAction.class);
    BeanUtil.setDeclaredProperty(indexAction, "date", "20100720");
    indexAction.view();
    Question q = (Question) BeanUtil.getDeclaredProperty(indexAction, "question");
    System.out.println(q.getText());
  }
View Full Code Here

  public static void main(String[] args) {
    new AppWebRunner() {
      @Override
      public void run() {
        QuestionService qs = petite.getBean(QuestionService.class);
        Question q = qs.findQuestionForDate(new JDateTime());
        System.out.println(q.getText());
      }
    }.runWebApp();
  }
View Full Code Here

TOP

Related Classes of com.uphea.domain.Question

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.