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.Employees7Controller.java

@FXML
public void handleSearchComboAction(ActionEvent af) {
    switch (SearchBy.getSelectionModel().getSelectedItem().toString()) {
    case "First Name":
        MongoCursor<Document> cursor4 = col.find().iterator();
        try {/*from w  w w . j a  va 2s . 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 {/*  w w w. j  av  a2 s .com*/
        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 {//from   ww w  . ja  v a 2 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  www . j  a v 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);//from  w  ww .j a v 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 ww .  j a va 2s. 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();
    }
}

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

@FXML
public void handleAllItemRadioAction(ActionEvent aj) {
    try {//from ww  w .  j  a  v a  2s  .  c om
        DeptCombo.setDisable(true);
        CatCombo.setDisable(true);
        SizeCombo.setDisable(true);
        PackCombo.setDisable(true);
        ItemCombo.setDisable(true);
        SupplierCombo.setDisable(true);
        filterField.setDisable(false);
        System.out.println("Selected radio is all item");
        data.clear();
        MongoCursor<Document> cursorFind = db.getCollection("ItemDetail").find().iterator();
        while (cursorFind.hasNext()) {
            Document g = cursorFind.next();
            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);

    }
}

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

@FXML
public void handleSizeRadioAction(ActionEvent as) {
    DeptCombo.setDisable(true);/*from   ww  w .ja  v  a  2s.  com*/
    CatCombo.setDisable(true);
    SizeCombo.setDisable(false);
    PackCombo.setDisable(true);
    ItemCombo.setDisable(true);
    SupplierCombo.setDisable(true);
    filterField.setDisable(true);
    cursor4 = db.getCollection("SizeDetail").find().iterator();
    try {
        while (cursor4.hasNext()) {
            String rs = cursor4.next().getString("Name");
            SizeCombo.setValue(rs);
            SizeCombo.getItems().addAll(rs);
        }
        SizeCombo.setOnAction((event) -> {
            data.clear();
            String selectedPerson = SizeCombo.getSelectionModel().getSelectedItem().toString();
            System.out.println("ComboBox Action (selected: " + selectedPerson + ")");
            basicdb.clear();
            basicdb.put("Size_Name", selectedPerson);

            MongoCursor<Document> cursorFind = db.getCollection("ItemDetail").find(basicdb).iterator();
            while (cursorFind.hasNext()) {
                Document g = cursorFind.next();
                data.add(new Person(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.ItemGroup6Controller.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    groupcol.setCellValueFactory(//from  ww w  .j a  va2  s . c om
            new javafx.scene.control.cell.PropertyValueFactory<Person, String>("GroupNames"));
    itemcol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, Integer>("Item"));
    updatecol.setCellValueFactory(
            new javafx.scene.control.cell.PropertyValueFactory<Person, String>("AllowUpdates"));
    data.removeAll(data);
    GroupTable.getItems().removeAll(data);
    GroupTable.setItems(data);
    MongoCursor<Document> cursorFind = db.getCollection("ItemGroup").find().iterator();
    while (cursorFind.hasNext()) {
        Document g = cursorFind.next();
        Document d = (Document) g.get("Items");
        count = d.keySet().size();
        data.add(new Person(g.getString("GroupName"), count, g.getString("Update")));
    }
    GroupTable.setItems(data);
    cursorFind.close();

}

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    first.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("SKU"));
    second.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("ItemName"));
    third.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Size"));
    fourth.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Pack"));
    fifth.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Price"));
    sixth.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Qty"));
    MongoCursor<Document> cursor4 = db.getCollection("ItemDetail").find().iterator();
    try {/*from w w w .  java2s.c o  m*/
        while (cursor4.hasNext()) {
            Document rs = cursor4.next();
            System.out.println("SKU is " + rs.getString("SKU") + " iname is " + rs.getString("ItemName")
                    + " Margin is " + rs.getString("Margin") + " Unit Cost is " + rs.getString("UnitCost")
                    + "MSRP " + rs.getString("MSRP"));
            data.add(new Person((rs.getString("SKU")), (rs.getString("ItemName")), (rs.getString("Size_Name")),
                    (rs.getString("Pack_Name")), (rs.getString("UnitCost")), (rs.getString("Quantity"))));
        }
    } finally {
        cursor4.close();
    }
    ItemTable.setItems(data);
}