PojoXml pojo = PojoXmlFactory.createPojoXml();
Shippers shippers = (Shippers) pojo.getPojoFromFile(".\\sampledata\\shippers.xml", Shippers.class);
Suppliers suppliers = (Suppliers) pojo.getPojoFromFile(".\\sampledata\\suppliers.xml", Suppliers.class);
Categories categories = (Categories) pojo.getPojoFromFile(".\\sampledata\\categories.xml", Categories.class);
Customers customers = (Customers) pojo.getPojoFromFile(".\\sampledata\\customers.xml", Customers.class);
Employees employees = (Employees) pojo.getPojoFromFile(".\\sampledata\\employees.xml", Employees.class);
OrderDetails orderdetails = (OrderDetails) pojo.getPojoFromFile(".\\sampledata\\orderdetails_rand_10000.xml", OrderDetails.class);
Orders orders = (Orders) pojo.getPojoFromFile(".\\sampledata\\orders_rand_10000.xml", Orders.class);
OrderDetails orderdetails2 = (OrderDetails) pojo.getPojoFromFile(".\\sampledata\\orderdetails_rand_20000.xml", OrderDetails.class);
Orders orders2 = (Orders) pojo.getPojoFromFile(".\\sampledata\\orders_rand_20000.xml", Orders.class);
Products products = (Products) pojo.getPojoFromFile(".\\sampledata\\products.xml", Products.class);
System.out.println("Data loaded from files :");
System.out.println("Shippers : "+shippers.getShipper().length);
System.out.println("Suppliers : "+suppliers.getSupplier().length);
System.out.println("Categories : "+categories.getCategory().length);
System.out.println("Customers : "+customers.getCustomer().length);
System.out.println("Employees : "+employees.getEmployee().length);
System.out.println("OrderDetails : "+orderdetails.getOrderdetail().length);
System.out.println("Orders : "+orders.getOrder().length);
System.out.println("OrderDetails2 : "+orderdetails2.getOrderdetail().length);
System.out.println("Orders2 : "+orders2.getOrder().length);
System.out.println("Products : "+products.getProduct().length);
//join details with order
joinDetails(orderdetails, orders);
joinDetails(orderdetails2, orders2);
System.out.println("Data prepared.");
//put things in database
HttpClient couchClient=null;
try {
couchClient = new StdHttpClient.Builder()
.username("admin")
.password("admin")
.url("http://localhost:5984")
.build();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
//cleanup
cleanUp(dbInstance);
CouchDbConnector db = null;
// System.out.println("data loading (1 write per document)");
// for(int i=0;i<5;++i){
// System.out.println("test "+(i+1));
// cleanUp(dbInstance);
// cleanRevOrders(orders);
// cleanRevOrders(orders2);
// db = dbInstance.createConnector("orders", true);
// testOrdersLoad(orders, db);
// testOrdersLoad(orders2, db);
// }
db = dbInstance.createConnector("orders", true);
System.out.println("data loading (bulk - 1000 documents in write)");
for(int i=0;i<5;++i){
System.out.println("test "+(i+1));
cleanUp(dbInstance);
cleanRevOrders(orders);
cleanRevOrders(orders2);
db = dbInstance.createConnector("orders", true);
testOrdersBulkLoad(orders, db);
testOrdersBulkLoad(orders2, db);
System.out.println("\n");
}
// db = dbInstance.createConnector("suppliers", true);
for(Supplier s : suppliers.getSupplier()){
db.create(s);
}
// db = dbInstance.createConnector("shippers", true);
for(Shipper s : shippers.getShipper()){
db.create(s);
}
// db = dbInstance.createConnector("categories", true);
for(Category c : categories.getCategory()){
db.create(c);
}
// db = dbInstance.createConnector("customers", true);
for(Customer c : customers.getCustomer()){
db.create(c);
}
// db = dbInstance.createConnector("employees", true);
for(Employee e : employees.getEmployee()){
db.create(e);