public void run() {
   while (isAlive) {
     update();
     Dysco dysco = dyscosQueue.poll();
     if (dysco == null) {
       try {
         synchronized (this) {
           this.wait(100);
         }
       } catch (InterruptedException e) {
         logger.error(e.getMessage());
       }
       continue;
     } else {
       try {
         searchForDysco(dysco);
       } catch (Exception e) {
         logger.error(
             "Error during searching for dysco: "
                 + dysco.getId()
                 + " of type: "
                 + dysco.getDyscoType());
         logger.error("Exception: " + e.getMessage());
       }
     }
   }
 }
  /**
   * Transforms Query instances to KeywordsFeed instances that will be used for searching social
   * media
   *
   * @param queries
   * @param dateToRetrieve
   * @return the list of feeds
   */
  public List<Feed> getSimpleFeeds(Dysco dysco) {

    List<Feed> feeds = new ArrayList<Feed>();

    DateUtil dateUtil = new DateUtil();
    Date dateToRetrieve = dateUtil.addDays(dysco.getCreationDate(), -1);

    Map<String, Double> keywords = dysco.getKeywords();
    for (Entry<String, Double> entry : keywords.entrySet()) {

      String text = entry.getKey();
      String[] parts = text.split("\\s+");

      if (parts.length < 2) continue;

      UUID UUid = UUID.randomUUID();
      Keyword keyword = new Keyword(text, entry.getValue());
      KeywordsFeed feed = new KeywordsFeed(keyword, dateToRetrieve, UUid.toString());
      feeds.add(feed);
    }

    List<Entity> entities = dysco.getEntities();
    for (Entity entity : entities) {
      if (entity.getType().equals(Type.LOCATION)) continue;

      UUID UUid = UUID.randomUUID();
      Keyword keyword = new Keyword(entity.getName(), entity.getCont());
      KeywordsFeed feed = new KeywordsFeed(keyword, dateToRetrieve, UUid.toString());
      feeds.add(feed);
    }

    Map<String, Double> hashtags = dysco.getHashtags();
    for (Entry<String, Double> entry : hashtags.entrySet()) {

      String hashtag = entry.getKey();
      hashtag = hashtag.replaceAll("#", "");

      if (hashtag.length() < 4) continue;

      UUID UUid = UUID.randomUUID();
      Keyword keyword = new Keyword(hashtag, entry.getValue());
      KeywordsFeed feed = new KeywordsFeed(keyword, dateToRetrieve, UUid.toString());
      feeds.add(feed);
    }

    return feeds;
  }
 public void addDysco(Dysco dysco) {
   try {
     dyscosQueue.put(dysco);
     logger.info(dysco.getId() + " putted in dyscos queue (" + dyscosQueue.size() + ")");
   } catch (Exception e) {
     logger.error(e);
   }
 }