// Load document results from the GUI into a (local) mongoDB
public static void loadSampleData(String dataPath, String mongoServer, int mongoPort, boolean resetBeforeLoading) throws MongoException, IOException
{
String json = readFile(dataPath);
MongoDbConnection mongoConnection = new MongoDbConnection(mongoServer, mongoPort);
if (resetBeforeLoading) {
mongoConnection.getMongo().getDB("test").getCollection("docs").drop();
}
QueryResults res = QueryResults.fromApi(json, QueryResults.class);
List<DocumentPojo> documents = res.documents;
if (null == documents) {
documents = res.data; // (maybe it was a direct JSON call not a GUI save file)
}
for (DocumentPojo doc: documents) {
mongoConnection.getMongo().getDB("test").getCollection("docs").insert(doc.toDb());
}
}//TESTED