System.out.println(Arrays.toString(args));
Globals.setIdentity(Identity.IDENTITY_SERVICE);
Globals.overrideConfigLocation(args[0]);
// "-1"] Test initialization
new GenericProcessingController().Initialize();
// 0] Preparation: use the harvest library to get various sets of files to test out...
HarvestController hc = new HarvestController();
hc.setStandaloneMode(5);
LinkedList<DocumentPojo> toAdd_feed = new LinkedList<DocumentPojo>();
LinkedList<DocumentPojo> toUpdate_feed = new LinkedList<DocumentPojo>();
LinkedList<DocumentPojo> toDelete_feed = new LinkedList<DocumentPojo>();
// File type:
BasicDBObject query = new BasicDBObject("extractType", "Feed");
// A useful source known to work during V0S1 testing:
query.put("key", "arstechnica.com.tech-policy.2012.10.last-android-vendor-f.147.4.");
SourcePojo feedSource = SourcePojo.fromDb(DbManager.getIngest().getSource().findOne(query), SourcePojo.class);
hc.harvestSource(feedSource, toAdd_feed, toUpdate_feed, toDelete_feed);
System.out.println("############# Retrieved sample feed documents: " + toAdd_feed.size() + " from " + feedSource.getUrl());
// 1] Test the store and index manager by itself:
StoreAndIndexManager.setDiagnosticMode(true);
// // Test all public calls
//1.1] (resize DB)
// StoreAndIndexManager storeManager = new StoreAndIndexManager();
// storeManager.resizeDB(7365793L);
// System.exit(0);
// StoreAndIndexManager storeManager = new StoreAndIndexManager();
// storeManager.addToDatastore(toAdd_feed, true);
// // (addToSearch called from addToDatastore so not duplicated here)
// storeManager.removeFromDatastore_byURL(toAdd_feed, true);
// storeManager.removeFromDatastore_byId(toAdd_feed, true);
// // (removeFromSearch called from removeFromDatastore_byId so not duplicated here)
// // Finally, test the index switching/bulk indexing logic standalone:
// if (toAdd_feed.size() > 4) {
// toAdd_feed.get(2).setIndex("document_index");
// toAdd_feed.get(3).setIndex(null);
// storeManager.addToSearch(toAdd_feed);
// }
// if (toAdd_feed.size() > 4) {
// toAdd_feed.get(2).setIndex(toAdd_feed.get(0).getIndex());
// toAdd_feed.get(3).setIndex(toAdd_feed.get(0).getIndex());
// toAdd_feed.get(0).setIndex(null);
// toAdd_feed.get(3).setIndex(null);
// storeManager.removeFromSearch(toAdd_feed);
// }
// if (toAdd_feed.size() < 5) {
// System.out.println("************** Couldn't test StoreAndIndexManager indexing fully because <5 docs");
// }
// System.out.println("############# Tested StoreAndIndexManager calls");
// 2] Now run through a full store/aggregation cycle
// 2.0] Need to rerun the harvester because adding/removing from index changes to docs
// toAdd_feed.clear(); toUpdate_feed.clear(); toDelete_feed.clear();
// hc.harvestSource(feedSource, toAdd_feed, toUpdate_feed, toDelete_feed);
// System.out.println("############# ReRetrieved sample feed documents");
// 2.1] Logic:
AggregationManager.setDiagnosticMode(true);
GenericProcessingController pxControl_feed = new GenericProcessingController();
// No need to do this, thoroughly tested during beta (and a bit slow)
//pxControl.Initialize();
// Comment in the desired test...
// 2.1.1] Only adding:
// (+Check that the feeds' entities statistics have been updated:)
// pxControl_feed.processDocuments(InfiniteEnums.FEEDS, toAdd_feed, toUpdate_feed, toDelete_feed); // (add, update, delete)
// System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(toAdd_feed));
// 2.1.2] Updating:
DocumentPojo docToUpdate1 = toAdd_feed.get(0);
DocumentPojo docToUpdate2 = toAdd_feed.get(1);
// Couple of options:
docToUpdate1.setId(null); // (should be unnecessary, _id shouldn't have been set)
docToUpdate2.setId(null);
docToUpdate2.setUpdateId(new ObjectId("5277fec1256f16a6d3def633")); // (Doesn't matter what it is, just check the diagnostic from StoreAndIndexManager.removeFromSearch matches)
toUpdate_feed.add(docToUpdate1);
toUpdate_feed.add(docToUpdate2);
pxControl_feed.processDocuments(InfiniteEnums.FEEDS, toAdd_feed, toUpdate_feed, toDelete_feed); // (add, update, delete)
// 2.1.3] Deleting some docs, adding others
// toDelete_feed.add(toAdd_feed.pop());
// pxControl_feed.processDocuments(InfiniteEnums.FEEDS, toAdd_feed, toUpdate_feed, toDelete_feed); // (add, update, delete)
// 2.1.4] More logic:
// DocumentPojo doc1 = null;