Example usage for com.mongodb.client MongoCursor hasNext

List of usage examples for com.mongodb.client MongoCursor hasNext

Introduction

In this page you can find the example usage for com.mongodb.client MongoCursor hasNext.

Prototype

@Override
    boolean hasNext();

Source Link

Usage

From source file:com.mycompany.mavenproject2.SelectDeptController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    /*   List<String> values = Arrays.asList("one", "two", "three");
    list.setItems(FXCollections.observableList(values));*/

    /*    String qry="select name from dept_detail";
    java.sql.Connection conn=Connection.getConnect();            
    PreparedStatement pst2=conn.prepareStatement(qry);
    ResultSet rs = pst2.executeQuery(qry);
    while(rs.next()){                //from  w w w .j a  va2s .co  m
       List.getItems().addAll(rs.getString("name"));
    }*/

    MongoCursor<Document> cursor4 = db.getCollection("DeptDetail").find().iterator();
    try {
        while (cursor4.hasNext()) {
            String rs = cursor4.next().getString("Name");
            List.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }

}

From source file:com.mycompany.mavenproject2.SelectLocationController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    /*    String qry="select name from location_detail";
    java.sql.Connection conn=Connection.getConnect();            
    PreparedStatement pst2=conn.prepareStatement(qry);
    ResultSet rs = pst2.executeQuery(qry);
    while(rs.next()){/*w  w w  .  j a  va 2 s  .c  o  m*/
                
       List.getItems().addAll(rs.getString("name"));
    }*/

    MongoCursor<Document> cursor4 = db.getCollection("LocationDetail").find().iterator();
    try {
        while (cursor4.hasNext()) {

            String rs = cursor4.next().getString("Name");
            List.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }
}

From source file:com.mycompany.mavenproject2.SelectPackController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    /* String qry="select name from pack_detail";
    java.sql.Connection conn=Connection.getConnect();            
    PreparedStatement pst2=conn.prepareStatement(qry);
    ResultSet rs = pst2.executeQuery(qry);
    while(rs.next()){//from  w  w  w .jav a2  s. co  m
                
       List.getItems().addAll(rs.getString("name"));
    }*/

    MongoCursor<Document> cursor4 = col.find().iterator();
    try {
        while (cursor4.hasNext()) {

            String rs = cursor4.next().getString("Name");
            List.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }
}

From source file:com.mycompany.mavenproject2.SelectSizeController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    /*String qry="select name from size_detail";
    java.sql.Connection conn=Connection.getConnect();            
    PreparedStatement pst2=conn.prepareStatement(qry);
    ResultSet rs = pst2.executeQuery(qry);
    while(rs.next()){//  www .java 2  s  .c  o m
                
       List.getItems().addAll(rs.getString("name"));
    }*/
    MongoCursor<Document> cursor4 = col.find().iterator();
    try {
        while (cursor4.hasNext()) {

            String rs = cursor4.next().getString("Name");
            List.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }

}

From source file:com.mycompany.mavenproject2.SelectUOMController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    /*String qry="select name from uom_detail";
    java.sql.Connection conn=Connection.getConnect();            
    PreparedStatement pst2=conn.prepareStatement(qry);
    ResultSet rs = pst2.executeQuery(qry);
    while(rs.next()){/* w  w  w  .j  a  v a2  s . c o m*/
                
       List.getItems().addAll(rs.getString("name"));
    }*/
    MongoCursor<Document> cursor4 = db.getCollection("UOMDetail").find().iterator();
    try {
        while (cursor4.hasNext()) {

            String rs = cursor4.next().getString("Name");
            List.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }

}

From source file:com.mycompany.mavenproject2.ShortcutController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    MongoCursor<Document> cursor4 = db.getCollection("PackDetail").find().iterator();
    try {/*from w w w.  j  a v  a  2 s  .  co  m*/
        while (cursor4.hasNext()) {
            String rs = cursor4.next().getString("Name");
            PackCombo.setValue(rs);
            PackCombo.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }
}

From source file:com.mycompany.mavenproject2.TenderAddController.java

public void EditButton(String Desc, String Type) throws URISyntaxException, IOException {
    GlobalFlag = 1;//from ww w .  j  ava 2s. c om
    TenderName.setText(Desc);
    sort2 = new BasicDBObject();
    sort2.put("TenderName", Desc);
    MongoCursor<Document> cursor = col.find(sort2).iterator();
    while (cursor.hasNext()) {
        Document dr = cursor.next();
        PID = dr.getInteger("ID");
        PaymentCombo.setValue(dr.getString("PaymentMode"));
        ERRate.setText(dr.getString("ExchangeRate"));
        ConvRate.setText(dr.getString("ConversionRate"));
        CurSymbol.setText(dr.getString("Currency"));
        MinPayAmount.setText(dr.getString("MinPayAmount"));
        NoteText.setText(dr.getString("Notes"));
        if (!dr.getString("Image").equalsIgnoreCase("")) {
            Path get = Paths.get(dr.getString("Image"));
            byte[] readAllBytes = Files.readAllBytes(get);
            Image convertToJavaFXImage = convertToJavaFXImage(readAllBytes, 1024, 768);

            imageLabel.setImage(convertToJavaFXImage);
        }
        if (dr.getInteger("AuthenticationCheck") == 1) {
            AuthenticationCheck.setSelected(true);
        } else {
            AuthenticationCheck.setSelected(false);
        }
    }
}

From source file:com.mycompany.mavenproject2.TenderAddController.java

public void InsertMongo() {
    if (GlobalFlag == 1) {
        UpdateMongo();//from   w  w w.j  a v a  2  s  . c  om
    } else {
        count = (int) col.count();
        if (count == 0) {
            Document input = createSaleSeedData();
            col.insertOne(input);
        } else {
            sort1 = new BasicDBObject();
            MongoCursor<Document> cursor = col.find().sort(sort1).limit(1).skip((int) count - 1).iterator();
            try {
                while (cursor.hasNext()) {
                    EID = cursor.next().getInteger("ID");
                    System.out.println("last EID " + EID);
                    EID++;
                    System.out.println("Inserted " + EID);
                }
            } finally {
                cursor.close();
            }
            final Document seedData = createSaleSeedData();
            col.insertOne(seedData);
        }
    }
}

From source file:com.mycompany.mavenproject2.TenderAddController.java

public void UpdateMongo() {
    MongoCursor<Document> cursor4 = col.find().iterator();
    try {/*from w  ww.ja v a2  s.c  o m*/
        while (cursor4.hasNext()) {
            System.out.println("ID=> " + cursor4.next().getInteger("ID"));
        }
    } finally {
        cursor4.close();
    }
    System.out.println("Updated Selected _id is " + PID);
    col.updateOne(new Document("ID", PID), new Document("$set", UpdateSeedData()));
    //.append("$currentDate", new Document("lastModified", true)));
    MongoCursor<Document> cursor5 = col.find().iterator();
    try {
        while (cursor5.hasNext()) {
            System.out.println("After UpdateID=> " + cursor5.next().getInteger("ID"));
        }
    } finally {
        cursor5.close();
    }
}

From source file:com.navercorp.pinpoint.plugin.mongodb.MongoDBBase.java

License:Apache License

public void readData(PluginTestVerifier verifier, MongoCollection<Document> collection,
        Class<?> mongoDatabaseImpl) {
    //read data/*from   ww  w .j ava  2 s.com*/
    MongoCursor<Document> cursor = collection.find().iterator();

    Method find;
    try {
        find = mongoDatabaseImpl.getDeclaredMethod("find");
    } catch (NoSuchMethodException e) {
        find = null;
    }

    verifier.verifyTrace(event(MONGO_EXECUTE_QUERY, find, null, MONGODB_ADDRESS, null,
            new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_INFO.getName(), "customers"),
            new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_OPTION.getName(), "secondaryPreferred")));

    int resultCount = 0;
    try {
        while (cursor.hasNext()) {
            resultCount++;
            cursor.next();
        }
    } finally {
        cursor.close();
    }
    Assert.assertEquals(2, resultCount);
}