コード例 #1
0
  /**
   * aba de reviews
   *
   * @return
   * @throws ActionException
   */
  public String review() throws ActionException {
    int idUsuario = InfoHelper.setExtraInfo(this);
    boolean esseUsuarioJaVotou = false;
    int idEmulador = 0;

    try {
      idEmulador = input.getInt("id");
    } catch (InputException ie) {
      return NULL;
    }

    boolean estaLogado = UserHelper.usuarioEstaLogado(this);
    setEmuladorFavorito();
    // buscar reviews
    ReviewDeEmuladorDAO reviewDeEmuladorDAO = ReviewDeEmuladorDAO.getinstance();
    Collection<?> reviews;
    try {
      reviews = reviewDeEmuladorDAO.buscaPorEmulador(idEmulador);
      output.setValue("reviews", reviews);

      if (estaLogado) {
        ReviewDeEmuladorDAO daoReviewDeEmulador = ReviewDeEmuladorDAO.getinstance();
        esseUsuarioJaVotou = daoReviewDeEmulador.usuarioFezReviewDeEmulador(idUsuario, idEmulador);

        if (esseUsuarioJaVotou) output.setValue("jaVotou", "S");
        else output.setValue("jaVotou", "N");
      } else {
        output.setValue("jaVotou", "N");
      }

    } catch (DAOException e) {
      logger.debug("Erro na busca de reviews...", e);
    }

    output.setValue("aba2", "S");
    TopHelper.updateEmuladorHelper(idEmulador, output);
    return SUCCESS;
  }
コード例 #2
0
  /**
   * action que lista todos os favoritos
   *
   * @return
   * @throws ActionException
   */
  public String lista() throws ActionException {
    InfoHelper.setExtraInfo(this);

    int idDoUsuarioLogado = UserHelper.mantemUsuarioNaRequisicao(this);

    if (UserHelper.usuarioEstaLogado(this)) {
      Collection<JogosFavoritosVO> jogosFavoritos = new ArrayList<JogosFavoritosVO>();
      Collection<EmuladoresFavoritosVO> emuladoresFavoritos =
          new ArrayList<EmuladoresFavoritosVO>();
      JogosFavoritosDAO jogosFavoritosDAO = JogosFavoritosDAO.getinstance();
      EmuladoresFavoritosDAO emuladoresFavoritosDAO = EmuladoresFavoritosDAO.getinstance();
      try {
        jogosFavoritos = jogosFavoritosDAO.buscaPorUsuario(idDoUsuarioLogado);
        output.setValue("jogosFavoritos", jogosFavoritos);
        emuladoresFavoritos = emuladoresFavoritosDAO.buscaPorUsuario(idDoUsuarioLogado);
        output.setValue("emuladoresFavoritos", emuladoresFavoritos);
      } catch (DAOException e) {
        logger.error("Erro ao ler favoritos", e);
      }
    }

    return SUCCESS;
  }