Example usage for com.mongodb.client MongoCursor next

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

Introduction

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

Prototype

@Override
    TResult next();

Source Link

Usage

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    unitcol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("UnitName"));
    valuecol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Value"));
    typecol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Type"));
    nccol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("NC"));
    MongoCursor<Document> cursor = db.getCollection("CashDrawerDetail").find().iterator();
    System.out.println("Intilization");
    try {//from www  .j a  v a 2s.  c o m
        while (cursor.hasNext()) {
            Document i = cursor.next();
            System.out.println("Unit name is " + i.getString("UnitName"));
            data.add(new Person(i.getString("UnitName"), i.getString("Currency"), i.getString("UnitType"),
                    i.getString("NonCashUnit")));

        }
    } finally {
        cursor.close();
    }
    table.setItems(data);

}

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    TDesc.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("TDesc"));
    TType.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("TType"));
    MongoCursor<Document> cursor5 = col.find().iterator();
    try {//ww  w  . ja  v  a2 s. co  m
        while (cursor5.hasNext()) {
            Document rs = cursor5.next();
            data.add(new Person(rs.getString("TenderName"), rs.getString("PaymentMode")));
        }
    } finally {
        cursor5.close();
    }
    TenderTable.setItems(data);
    filterField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            initFilter();
        }
    });
}

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    captioncol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Value"));
    amtcol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("UnitName"));
    MongoCursor<Document> cursor4 = db.getCollection("CurrancyDetail").find().iterator();
    try {/*from  w  w w .j a v  a2 s.  c o m*/
        while (cursor4.hasNext()) {
            Document rs = cursor4.next();
            data.add(new Person((rs.getString("Caption")), (rs.getString("Amount"))));
        }
    } finally {
        cursor4.close();
    }
    table.setItems(data);
}

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

@FXML
public void handleEditSaveButtonAction(ActionEvent as) {

    MongoCursor<Document> cursor4 = db.getCollection("CurrancyDetail").find().iterator();
    try {//from   w ww  .j ava2 s.c  o m
        while (cursor4.hasNext()) {
            Document k = cursor4.next();
            System.out.println("before update => " + k.getString("Caption") + " " + k.getString("Amount"));
        }
    } finally {
        cursor4.close();
    }
    //Person person = table.getSelectionModel().getSelectedItem();
    //table.getSelectionModel().clearSelection();            

    //db.getCollection("CurrancyDetail").updateOne(new Document("Caption", person.getUnitName()),
    //new Document("$set", UpdateSeedData()));
    db.getCollection("CurrancyDetail").updateOne(eq("Caption", CaptionTextField.getText()),
            new Document("$set", new Document("Amount", AmountTextField.getText())));

    MongoCursor<Document> cursor5 = db.getCollection("CurrancyDetail").find().iterator();
    try {
        while (cursor5.hasNext()) {
            Document y = cursor5.next();
            System.out.println("After Update => " + y.getString("Caption") + " " + y.getString("Amount"));

        }
    } finally {
        cursor5.close();
    }
    AmountTextField.clear();
    CaptionTextField.clear();
}

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

@FXML
public void handleSearchComboAction(ActionEvent af) {
    switch (SearchBy.getSelectionModel().getSelectedItem().toString()) {
    case "First Name":
        MongoCursor<Document> cursor4 = col.find().iterator();
        try {/*w w  w . ja v a2 s .  com*/
            masterData.clear();
            while (cursor4.hasNext()) {
                System.out.println("First Name=> " + cursor4.next().getString("FirstName"));

            }

        } finally {
            cursor4.close();
        }
        break;
    case "Last Name":
        MongoCursor<Document> cursor5 = col.find().iterator();
        try {
            while (cursor5.hasNext()) {
                System.out.println("Last Name=> " + cursor5.next().getString("LastName"));
            }
        } finally {
            cursor5.close();
        }
        break;
    case "User ID":
        MongoCursor<Document> cursor6 = col.find().iterator();
        try {
            while (cursor6.hasNext()) {
                System.out.println("User ID=> " + cursor6.next().getString("UserEID"));
            }
        } finally {
            cursor6.close();
        }
        break;
    case "Phone":
        MongoCursor<Document> cursor7 = col.find().iterator();
        try {
            while (cursor7.hasNext()) {
                System.out.println("Phone => " + cursor7.next().getString("Phone"));
            }
        } finally {
            cursor7.close();
        }
        break;
    }
}

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    id.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("id"));
    fname.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("FName"));
    lname.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("LName"));
    uid.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("UserId"));
    phone.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("phone"));
    MongoCursor<Document> cursor4 = col.find().iterator();
    try {//from  w w  w.jav a 2s  .  c o  m
        while (cursor4.hasNext()) {
            Document rs = cursor4.next();
            // System.out.println("Id is "+rs.getInteger("ID")+" fname is "+rs.getString("FirstName")+" last name is "+rs.getString("LastName")+" User ID is "+rs.getString("UserEID")+" Phone is "+rs.getString("Phone"));
            data.add(new Person((rs.getInteger("ID")), (rs.getString("FirstName")), (rs.getString("LastName")),
                    (rs.getString("UserEID")), (rs.getString("Phone"))));
        }
    } finally {
        cursor4.close();
    }
    empTable.setItems(data);
    masterData.addAll(data);
    filteredData.addAll(masterData);
    System.out.println("Master data value is " + masterData.get(1).getFName());

    masterData.addListener(new ListChangeListener<Person>() {
        @Override
        public void onChanged(ListChangeListener.Change<? extends Person> change) {
            System.out.println("Onchanged event of data");
            // updateFilteredData();
        }
    });
    filterField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            System.out.println("Onchanged event of filterField");
            //updateFilteredData();
            initFilter();
        }
    });
}

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

private Document UpdateSeedData() {
    Document d = new Document();
    b = new BasicDBObject();
    b.put("Name", AddToDeptCombo.getValue());
    MongoCursor<Document> cursor = db.getCollection("DeptDetail").find(b).iterator();
    try {/*  w  ww  .ja  v  a2  s  . c  o m*/
        while (cursor.hasNext()) {
            dept_id = cursor.next().getInteger("ID");
            System.out.println("Searched Output " + dept_id);
        }
    } finally {
        cursor.close();
    }
    /* d.append("ItemDesc", DescriptionTextField.getText());
     d.append("ItemName",ItemNameText.getText() );
     d.append("Dept_ID",dept_id );
     d.append("Size_Name",size_name );      
     d.append("Pack_Name",pack_name );
     d.append("Cat_Name", CatCombo.getValue());
     d.append("Brand_Name",brand_name );
             
     d.append("Model_Num",ModelText.getText() );
     d.append("Part_Num",PartText.getText() );
     d.append("NonStock",nonstock );
     d.append("UnitType",IventoryTypeCombo.getValue() );
     d.append("NonText", nontax);
     d.append("Tax1",Tax1Combo.get() );
     d.append("Tax2",Tax2Text.getText() );
     d.append("Tax3",Tax3Text.getText() );
     d.append("QualityPrompt", priceF);
     d.append("UnitCost",CostText.getText() );
     d.append("UnitPrice",PriceText.getText() );
     d.append("Margin",MarginText.getText());
     d.append("MSRP",MSRPText.getText() );       
     d.append("BuyDownAmount",BuyDownText.getText() );
     d.append("MarkUP",MarkUpText.getText() );       
     d.append("SalesPrice",SaleText.getText() );
     d.append("WeightedItem",check1 );          
     d.append("ExcludeSale", check3);       
     d.append("WIC",check4 );        
     d.append("HealthCard",check5 );       */
    d.append("Dept_ID", dept_id);
    d.append("Cat_Name", AddToCatCombo.getValue());
    d.append("Location", LocationCombo.getValue());
    d.append("WebItem", (WebCombo.getValue().equals("Add")) ? 1 : 0);
    d.append("FoodStamp", (FoodStampCombo.getValue().equals("Add")) ? 1 : 0);
    /*d.append("NonRevenueItem", check7); 
    if(SaleMsgCombo.getValue().equals("add")){
    d.append("SaleMessage", Salemsg.getValue().toString());
    }
            
    table.getItems().forEach(item -> d.append("Quantity",item.getValue()));
    costTable.getItems().forEach(item -> d.append("CostQuantity",item.getUnitName()));
    costTable.getItems().forEach(item -> d.append("Price",item.getValue()));     */

    return d;
}

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

@FXML
public void handleCatRadioAction(ActionEvent d) {
    System.out.println("cat radio action");
    DeptCombo.setDisable(true);/*from   w ww .j  av a  2 s .co  m*/
    SizeCombo.setDisable(true);
    PackCombo.setDisable(true);
    ItemCombo.setDisable(true);
    SupplierCombo.setDisable(true);
    CatCombo.setDisable(false);
    filterField.setDisable(true);
    cursor4 = db.getCollection("CategoryDetail").find().iterator();

    try {
        while (cursor4.hasNext()) {
            String rs = cursor4.next().getString("Name");
            CatCombo.setValue(rs);
            CatCombo.getItems().addAll(rs);
            CatCombo.setValue("");
        }
        CatCombo.setOnAction((event) -> {
            data.clear();
            String selectedPerson = CatCombo.getSelectionModel().getSelectedItem().toString();
            System.out.println("ComboBox Action (selected: " + selectedPerson + ")");
            basicdb.clear();
            basicdb.put("Cat_Name", selectedPerson);
            MongoCursor<Document> cursorFind = db.getCollection("ItemDetail").find(basicdb).iterator();
            while (cursorFind.hasNext()) {
                Document g = cursorFind.next();
                // System.out.println("Item is "+cursorFind.next().getString("ItemName"));
                data.add(new Person(g.getString("SKU"), g.getString("ItemDesc"), g.getString("Size_Name"),
                        g.getString("Pack_Name"), g.getString("UnitCost")));
                //System.out.println("result data is "+g.getString("SKU")+ g.getString("ItemDesc")+g.getString("Size_Name")+ g.getString("Pack_Name")+" " +g.getString("UnitCost"));
            }

        });
    } finally {
        ItemTable.setItems(data);
        cursor4.close();
    }
}

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

@FXML
public void handleDeptRadioButtonAction(ActionEvent af) {
    DeptCombo.setDisable(false);/*  ww w .  jav  a  2s . c o  m*/
    CatCombo.setDisable(true);
    SizeCombo.setDisable(true);
    PackCombo.setDisable(true);
    ItemCombo.setDisable(true);
    SupplierCombo.setDisable(true);
    filterField.setDisable(true);
    cursor4 = db.getCollection("DeptDetail").find().iterator();
    try {
        while (cursor4.hasNext()) {
            String rs = cursor4.next().getString("Name");
            DeptCombo.setValue(rs);
            DeptCombo.getItems().addAll(rs);
        }
        DeptCombo.setOnAction((event) -> {
            data.clear();
            String selectedPerson = DeptCombo.getSelectionModel().getSelectedItem().toString();
            System.out.println("ComboBox Action (selected: " + selectedPerson + ")");
            basicdb.clear();
            deptBasicdb.put("Name", selectedPerson);
            MongoCursor<Document> findDept = db.getCollection("DeptDetail").find(deptBasicdb).iterator();
            while (findDept.hasNext()) {
                Document g = findDept.next();
                id = g.getInteger("ID");
            }
            basicdb.put("Dept_ID", id);
            MongoCursor<Document> cursorFind = db.getCollection("ItemDetail").find(basicdb).iterator();
            while (cursorFind.hasNext()) {
                Document g = cursorFind.next();
                // System.out.println("Item is "+cursorFind.next().getString("ItemName"));
                data.add(new Person(g.getString("SKU"), g.getString("ItemDesc"), g.getString("Size_Name"),
                        g.getString("Pack_Name"), g.getString("UnitCost")));
                //System.out.println("result data is "+g.getString("SKU")+ g.getString("ItemDesc")+g.getString("Size_Name")+ g.getString("Pack_Name")+" " +g.getString("UnitCost"));
            }

        });
    } finally {
        ItemTable.setItems(data);
        cursor4.close();
    }
}

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

@FXML
public void handleItemRadioAction(ActionEvent as) {
    DeptCombo.setDisable(true);//  w w w  .j  av a2 s  .  c  o  m
    CatCombo.setDisable(true);
    SizeCombo.setDisable(true);
    PackCombo.setDisable(false);
    ItemCombo.setDisable(true);
    SupplierCombo.setDisable(true);
    filterField.setDisable(true);
    cursor4 = db.getCollection("PackDetail").find().iterator();
    try {
        while (cursor4.hasNext()) {
            String rs = cursor4.next().getString("Name");
            PackCombo.setValue(rs);
            PackCombo.getItems().addAll(rs);
        }
        PackCombo.setOnAction((event) -> {
            data.clear();
            String selectedPerson = PackCombo.getSelectionModel().getSelectedItem().toString();
            System.out.println("ComboBox Action (selected: " + selectedPerson + ")");
            basicdb.clear();
            basicdb.put("Pack_Name", selectedPerson);
            MongoCursor<Document> cursorFind = db.getCollection("ItemDetail").find(basicdb).iterator();
            while (cursorFind.hasNext()) {
                Document g = cursorFind.next();
                // S    ystem.out.println("Item is "+cursorFind.next().getString("ItemName"));
                data.add(new Person(g.getString("SKU"), g.getString("ItemDesc"), g.getString("Size_Name"),
                        g.getString("Pack_Name"), g.getString("UnitCost")));
                //System.out.println("result data is "+g.getString("SKU")+ g.getString("ItemDesc")+g.getString("Size_Name")+ g.getString("Pack_Name")+" " +g.getString("UnitCost"));
            }

        });

    } finally {
        ItemTable.setItems(data);
        cursor4.close();
    }
}