Package org.ektorp

Examples of org.ektorp.CouchDbConnector


    @Override
    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows) {
        // the connector represents a handle to the the couchdb "database".
        final String databaseName = table.getName();
        final CouchDbConnector connector = _couchDbInstance.createConnector(databaseName, false);

        ViewQuery query = new ViewQuery().allDocs().includeDocs(true);

        if (maxRows > 0) {
            query = query.limit(maxRows);
        }
        if (firstRow > 1) {
            final int skip = firstRow - 1;
            query = query.skip(skip);
        }

        final StreamingViewResult streamingView = connector.queryForStreamingView(query);

        final SelectItem[] selectItems = MetaModelHelper.createSelectItems(columns);
        return new CouchDbDataSet(selectItems, streamingView);
    }
View Full Code Here


    @Override
    protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed) {
        if (whereItems.isEmpty()) {
            String databaseName = table.getName();
            CouchDbConnector connector = _couchDbInstance.createConnector(databaseName, false);
            long docCount = connector.getDbInfo().getDocCount();
            return docCount;
        }
        return null;
    }
View Full Code Here

   
    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);
    }
   
//    db = dbInstance.createConnector("products", true);
    for(Product p : products.getProduct()){
      db.create(p);
    }
   
  }
View Full Code Here

      e.printStackTrace();
    }
   
    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
   
    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
View Full Code Here

      e.printStackTrace();
    }
   
    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
   
    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
View Full Code Here

      e.printStackTrace();
    }
   
    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
   
    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
View Full Code Here

      e.printStackTrace();
    }
   
    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
   
    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
   
    OrderRepository or = new OrderRepository(db);
    ViewResult result = null;
View Full Code Here

      e.printStackTrace();
    }

    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);

    CouchDbConnector db = null;

    db = dbInstance.createConnector("orders", false);
    OrderRepository or = new OrderRepository(db);

    List<Product> allProd = or.getAllProducts();
View Full Code Here

      e.printStackTrace();
    }
   
    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
   
    CouchDbConnector db = null;
   
    db = dbInstance.createConnector("orders", false);
    OrderRepository or = new OrderRepository(db)
    ViewResult result = null;
   
View Full Code Here

                .password("admin")
                .url("http://localhost:5984")
                .build();
   
    CouchDbInstance dbInstance = new StdCouchDbInstance(couchClient);
    CouchDbConnector db = dbInstance.createConnector("testdb", true);
   
    DbInfo info = db.getDbInfo();
    DecimalFormat df = new DecimalFormat("#.##");

    logger.info("DB info : dbName=" + info.getDbName() + ", docCount="
        + info.getDocCount() + ", diskSize=" + df.format(info.getDiskSize()
        / 1024.0 / 1024.0) + " MB");

    Client john = new Client("John Smith", "USA");
   
    john.setId("john");
   
    logger.info("john : _id="+john.getId()+" _rev="+john.getRevision());
    waitForKey();   
   
   
    db.create(john);   
    logger.info("create");
    logger.info("john : _id="+john.getId()+" _rev="+john.getRevision());
   
    waitForKey();
   
    john.setAddress("PL");
    db.update(john);
   
    logger.info("update");
    logger.info("john : _id="+john.getId()+" _rev="+john.getRevision());
   
    waitForKey();
   
    logger.info("get");
    john = db.get(Client.class, "john");
    logger.info("john : _id="+john.getId()+" _rev="+john.getRevision());
   
    waitForKey();
   
    logger.info("delete");
    db.delete(john);
   
    waitForKey();
   
    logger.info("Order create");
   
    Order o1 = new Order();
    o1.setCustomerId(john.getId());
    db.create(o1);
   
    waitForKey();
   
    logger.info("Order delete ");
   
    db.delete(o1);
   
    waitForKey();
   
    logger.info("Map object");
   
    Map<String,Object> mapExample = new HashMap<>();
    mapExample.put("_id", "mapExample");
    mapExample.put("someNumber", 2);
    mapExample.put("table", new Integer[]{2,3,4,5});
   
    db.create(mapExample);
   
    waitForKey();
   
    logger.info("JsonNode");
    JsonNode json = db.get(JsonNode.class, "mapExample");
    String fields="";
    Iterator<String> it = json.getFieldNames();
    while(it.hasNext()){
      fields+=" :: "+it.next();
    }
View Full Code Here

TOP

Related Classes of org.ektorp.CouchDbConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.