@SuppressWarnings("unused")
  private void fetchTweets(String company) {
    Twitter twitter = new TwitterFactory().getInstance();

    Query query = new Query(company);
    query.setLang("en");
    query.setRpp(100);

    try {
      List<TweetDTO> tweets = new ArrayList<TweetDTO>();

      for (int i = 1; i < 10; i++) {
        query.setPage(i);
        QueryResult result = twitter.search(query);
        for (Tweet tweet : result.getTweets()) {
          TweetDTO dto = new TweetDTO();
          dto.setTwitterId(Long.toString(tweet.getId()));
          dto.setText(tweet.getText());
          dto.setDate(tweet.getCreatedAt());
          dto.setCompanies(company);
          tweets.add(dto);
        }
      }

      new GoogleTweetDAO().storeTweet(tweets);
    } catch (TwitterException e) {
    }
  }
  /**
   * Metodo que permite crear la consulta en tweeter en base al texto ingresado en el query.
   *
   * @param textoConsultaEjecutar
   * @return
   */
  public List<Status> ejecutarQueyEnBaseAConsulta(String textoConsultaEjecutar) {
    logger.info("<====  armaQueyEnBaseAConsulta ====>");
    logger.debug("textoConsultaEjecutar: " + textoConsultaEjecutar);

    Twitter twitter = TwitterFactory.getSingleton();
    Query query = new Query(textoConsultaEjecutar);
    query.setLang(COD_LENGUAJE_CONSULTA_ESPANOL);

    return ejecutaQueryEnTwitter(twitter, query);
  }
  /**
   * Search tweets with the keyword "word"
   *
   * @param word : keyword
   */
  public void doSearch(String word) {
    List<Status> listStatus;
    listCleanTweets = new ArrayList<Tweet>();
    listDirtyTweets = new ArrayList<Tweet>();

    try {
      Query query = new Query(word);
      query.resultType(ResultType.mixed);
      query.setLang("fr");
      query.count(30);
      QueryResult result = InterfaceG.twitter.search(query);

      listStatus = result.getTweets();

      for (Status status : listStatus) {
        Tweet tclean =
            new Tweet(
                status.getId(),
                status.getUser().getName(),
                cleanTweet(status.getText()),
                status.getCreatedAt().toString(),
                -1);
        listCleanTweets.add(tclean);

        Tweet tdirty =
            new Tweet(
                status.getId(),
                status.getUser().getName(),
                status.getText(),
                status.getCreatedAt().toString(),
                -1);
        listDirtyTweets.add(tdirty);
      }

      setChanged();
      notifyObservers();
    } catch (TwitterException te) {
      System.out.println("doSearch:TwitterExc");
      System.out.println(te.getMessage());
      System.exit(-1);
    } catch (IOException e) {
      System.out.println("doSearch:IOExc");
      System.out.println(e.getMessage());
    }
  }
  public void grab(Date timeLimit) {
    log.info("Twitter grabber started...");
    Twitter twitter = new TwitterFactory().getInstance();

    List<Brand> brandList = handler.getBrandProvider().getAllBrands();
    ArticleProvider articleProvider = handler.getArticleProvider();

    for (Brand b : brandList) {
      Query query = new Query(b.getName());
      query.setRpp(PAGE_SIZE);
      query.setLang("ru");
      query.setResultType(Query.MIXED);

      List<Tweet> resultTweets = new LinkedList<Tweet>();
      QueryResult queryResult;
      int pageNumber = 1;

      try {
        do {
          query.setPage(pageNumber);
          queryResult = twitter.search(query);
          resultTweets.addAll(queryResult.getTweets());
          pageNumber++;
          log.info(pageNumber);
        } while (ISSUANCE_SIZE > resultTweets.size());
      } catch (TwitterException e) {
        throw new RuntimeException(e);
      }
      log.info("tweets in da111y: " + resultTweets.size());
      twitter = null;
      twitter = new TwitterFactory().getInstance();

      for (Tweet t : resultTweets) {
        articleProvider.writeArticleToDataStore(
            new Article(-1, b.getId(), 2, "", t.getText(), "", getSimpleTime(t.getCreatedAt()), 1));
      }
    }
    log.info("twitter grabber finished succesful.");
  }