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

@FXML
public void handleAllItemRadioAction(ActionEvent aj) {
    try {/* w ww  .  jav a2 s  .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 w  w w.j  av a 2 s .  c  o m
    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 w  ww  .ja v  a  2 s . c o  m
            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 {//w  w  w . ja va  2 s  . 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);
}

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

@FXML
public void handleAddOnButtonAction(ActionEvent a) throws UnknownHostException {

    ref = new BasicDBObject();
    ref.put("Name", Pattern.compile(ChargeNameText.getText(), Pattern.CASE_INSENSITIVE));
    MongoCursor<Document> myDoc2 = col.find(ref).iterator();
    if (myDoc2.hasNext()) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("Error ");
        alert.setContentText("ChargeName Already exist!");
        alert.showAndWait();/*from  w w w.ja v a2s .c o m*/
        ChargeNameText.clear();
        ChargeValue.clear();
        repeat = 1;
    } else {
        repeat = 0;
    }
    if (repeat == 0 && GlobalFlag == 0) {
        InsertMongo();
        // InsertSQl(conn);
    }
    if (GlobalFlag == 1) {
        /*db.getCollection("PriceDetail").updateOne(eq("ChargeName", addon), up.append("$set", new Document("ChargeName", ChargeNameText.getText())));
        db.getCollection("PriceDetail").updateOne(eq("ChargeName", addon), up.append("$set", new Document("ChargeValue", ChargeValue.getText())));
        db.getCollection("PriceDetail").updateOne(eq("ChargeName", addon),new Document(var, var)*/
        BasicDBObject b = new BasicDBObject();
        b.put("ChargeName", addon);

        MongoCursor<Document> cursor = db.getCollection("PriceDetail").find(b).iterator();

        while (cursor.hasNext()) {
            Document d1 = cursor.next();
            System.out.println("output is " + d1.toString());

            if (PercentageRadio.isSelected()) {
                cost1 = 1;
            }
            if (AmountRadio.isSelected()) {
                cost2 = 1;
            }

            if (InactiveCheck.isSelected()) {
                IFlag = 1;
            }
            if (TaxCheck.isSelected()) {
                TFlag = 1;
            }

            /*  updateDocument.put("ChargeName",ChargeNameText.getText());            
              updateDocument.put("ChargeValue", ChargeValue.getText());
              updateDocument.put("PercentageCheck", cost1);
            updateDocument.put("Amountcheck", cost2);
            updateDocument.put("Inactive", IFlag);
            updateDocument.put("Tax", TFlag);        */
            updateDocument.put("$set", up.append("ChargeName", ChargeNameText.getText()));
            updateDocument.put("$set", up.append("ChargeValue", ChargeValue.getText()));
            updateDocument.put("$set", up.append("PercentageCheck", cost1));
            updateDocument.put("$set", up.append("Amountcheck", cost2));
            updateDocument.put("$set", up.append("Inactive", IFlag));
            updateDocument.put("$set", up.append("Tax", TFlag));

            db.getCollection("PriceDetail").updateOne(d1, up);
            //MongoUtils.printAllDocument("founder", "mongodb");

            //  db.getCollection("PriceDetail").updateOne(d1,updateDocument);

        }
    }
    System.out.println("global value is " + GlobalFlag);
    Stage stage = (Stage) SaveButton.getScene().getWindow();
    stage.close();
}

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

public void EditButton(String para1, String para2, String para3, String para4) {
    addon = para1;/*  ww  w . jav a2  s . co  m*/
    GlobalFlag = 1;
    System.out.println("global value is edit button" + GlobalFlag);
    int op = 0, amt = 0;
    System.out.println("Percentage " + para3 + " Tax " + para4);
    BasicDBObject b = new BasicDBObject();
    b.put("ChargeName", para1);
    MongoCursor<Document> cursor = db.getCollection("PriceDetail").find(b).iterator();
    try {
        while (cursor.hasNext()) {
            Document d = cursor.next();
            amt = d.getInteger("Amountcheck");
            op = d.getInteger("Inactive");
        }
    } finally {
        cursor.close();
    }
    if (amt == 1) {
        AmountRadio.setSelected(true);
    } else {
        AmountRadio.setSelected(false);
    }
    if (op == 1) {
        InactiveCheck.setSelected(true);
    } else {
        InactiveCheck.setSelected(false);
    }
    if (para3.equals("Yes")) {
        PercentageRadio.setSelected(true);
        System.out.println("Percentage should be checked ");
    } else {
        PercentageRadio.setSelected(false);
    }
    if (para4.equals("Yes")) {
        TaxCheck.setSelected(true);
        System.out.println("CheckBox should check");
    } else {
        TaxCheck.setSelected(false);
    }
    ChargeNameText.setText(para1);
    ChargeValue.setText(para2);
}

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    idcol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, Integer>("ID"));
    namecol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("SaleName"));
    sdatecol.setCellValueFactory(/*from   w  w w  .  ja va 2 s . co  m*/
            new javafx.scene.control.cell.PropertyValueFactory<Person, String>("StartDate"));
    edatecol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("EndDate"));
    targetcol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Target"));
    couponcol.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person, String>("Coupon"));
    data.removeAll(data);
    SalesTable.getItems().removeAll(data);
    MongoCursor<Document> cur = col.find().iterator();
    while (cur.hasNext()) {
        Document d = cur.next();
        data.add(new Person(d.getInteger("ID"), d.getString("Name"), d.getString("StartDate"),
                d.getDate("EndDate").toString(), d.getString("TargetCust"), "c"));
    }
    cur.close();
    final ObservableList<Integer> highlightRows = FXCollections.observableArrayList();
    SalesTable.setItems(data);
    SalesTable.getItems().forEach(item -> Date(item));

}

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

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

    entitycol.setCellValueFactory(//ww w. j  a v a2  s . c  o  m
            new javafx.scene.control.cell.PropertyValueFactory<Person, String>("EntityName"));
    addcol.setCellValueFactory(new PropertyValueFactory("Add"));
    editcol.setCellValueFactory(new PropertyValueFactory("Edit"));
    delcol.setCellValueFactory(new PropertyValueFactory("Delete"));
    uidcol.setCellValueFactory(new PropertyValueFactory("UID"));
    fnmcol.setCellValueFactory(new PropertyValueFactory("FirstName"));
    lnmcol.setCellValueFactory(new PropertyValueFactory("LastName"));
    roleTable.setItems(empData);
    /* MongoCursor<Document> cur=db.getCollection("EmployeeDetail").find().iterator();
     while(cur.hasNext()){
         Document rs=cur.next();
         System.out.println("UserEID is "+rs.getString("UserEID")+" first name is "+rs.getString("FirstName")+" Last Name is "+rs.getString("LastName"));
         //empData.add(new Person2(rs.getString("UserEID"),rs.getString("FirstName"),rs.getString("LastName")));
     } */
    roleCombo.setOnAction((event) -> {
        String selectedPerson = roleCombo.getSelectionModel().getSelectedItem().toString();
        System.out.println("ComboBox Action (selected: " + selectedPerson + ")");
        basicdb.clear();
        data1.clear();
        RoleID = 0;
        basicdb.put("Role", selectedPerson);
        MongoCursor<Document> cursorFind = db.getCollection("EmployeeDetail").find(basicdb).iterator();
        while (cursorFind.hasNext()) {
            Document g = cursorFind.next();
            //RoleID=g.getInteger("ID");
            data1.add(new Person2(g.getString("UserEID"), g.getString("FirstName"), g.getString("LastName")));
            System.out.println("usereid " + g.getString("FirstName"));
        }
        roleTable.setItems(data1);
        System.out.println("Set data of table");
    });
    addcol.setCellFactory(new Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>>() {
        public TableCell<Person, Boolean> call(TableColumn<Person, Boolean> p) {
            return new CheckBoxTableCell<Person, Boolean>();
        }

    });
    editcol.setCellFactory(new Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>>() {
        public TableCell<Person, Boolean> call(TableColumn<Person, Boolean> p) {
            return new CheckBoxTableCell<Person, Boolean>();
        }
    });
    delcol.setCellFactory(new Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>>() {

        public TableCell<Person, Boolean> call(TableColumn<Person, Boolean> p) {

            return new CheckBoxTableCell<Person, Boolean>();

        }

    });

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

            String rs = cursor4.next().getString("Role");
            roleCombo.setValue(rs);
            roleCombo.getItems().addAll(rs);
        }
    } finally {
        cursor4.close();
    }
}

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

public void InsertMongo() {
    count = (int) col.count();
    if (count == 0) {
        seedData = createSeedData();/*ww  w .j  av a2s  .c  o  m*/
        col.insertOne(seedData);
    } else {
        sort1 = new BasicDBObject();
        MongoCursor<Document> cursor = col.find().sort(sort1).limit(1).skip((int) count - 1).iterator();
        try {
            while (cursor.hasNext()) {

                ID = cursor.next().getInteger("ID");
                System.out.println("last ID " + ID);
                ID++;
                System.out.println("Inserted " + ID);
            }
        } finally {
            cursor.close();
        }
        Document input = createSeedData();
        db.getCollection("SecurityRole").insertOne(input);

    }
}

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

@Override
public void initialize(URL url, ResourceBundle rb) {
    System.out.println("intialize");
    MongoCursor<Document> cursor4 = db.getCollection("SecurityRole").find().iterator();

    try {//from   w  w w .j  a va2  s .  c  o m
        while (cursor4.hasNext()) {

            String rs = cursor4.next().getString("Role");

            rolelist.getItems().addAll(rs.toString());

            //   System.out.println("output is "+String.valueOf(rs1)));
        }
    } finally {
        cursor4.close();
    }

}