@Override public void run() { ArticleAggregator agg = new ArticleAggregator(); IDatabase db = Manager.getDatabase(); SourceParser parser = new SourceParser(); int counter = 0; for (String link : links) { Article article = parser.parse(new Source(link)); // if the article object is null that means an error occurred while parsing the link look in // error log file for reason if (article != null) { counter++; System.out.println(counter + " " + link); Story matchedStory = agg.matchArticle(article); // if null was returned from the aggregator a new Story entry must be made because there // is no good match in the database if (matchedStory == null) { // use the values of the article to set up the Story Story story = new Story(); // TODO come up with better way of choosing category than taking the category from the // article story.setCategory(article.getCategory()); story.setTitle(article.getTitle()); story.setDate(article.getDate()); // id will be set when the store method is carried out db.storeStory(story); article.setStoryID(story.getID()); } // if matchedStory isn't null it was matched to an already existing Story entry else { article.setStoryID(matchedStory.getID()); } db.storeArticle(article); } // if (counter > ){ //// db.printArticleTable(); // System.exit(0); // } } }