List of usage examples for com.mongodb.client MongoCursor close
@Override
void close();
From source file:com.mycompany.mavenproject2.AddUser8Controller.java
private void InsertMongo() { if (GlobalFlag == 1) { UpdateMongo();//from w w w.j a v a2s.c o m } else { count = (int) col.count(); if (count == 0) { seedData = createSeedData(); 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()) { EID = cursor.next().getInteger("ID"); System.out.println("last EID " + EID); EID++; System.out.println("Inserted " + EID); } } finally { cursor.close(); } final Document seedData = createSeedData(); col.insertOne(seedData); } } }
From source file:com.mycompany.mavenproject2.AddUser8Controller.java
public void UpdateMongo() { System.out.println("global 1 update called"); /* condition=new BasicDBObject(); condition.put("UserEID", uid.getText()); /*from w ww. jav a2 s .co m*/ MongoCursor<Document> cursor = col.find(condition).iterator(); while (cursor.hasNext()) { System.out.println("Updated Selected _id is "+Eid); Eid=cursor.next().getObjectId("_id").toString(); System.out.println("Updated Selected _id is "+Eid); }*/ MongoCursor<Document> cursor4 = col.find().iterator(); try { while (cursor4.hasNext()) { System.out.println("ID=> " + cursor4.next().getString("UserEID")); } } finally { cursor4.close(); } // col.updateOne(eq("_id",Eid), new Document("$set",new Document("UserEID","U25")) ); //col.replaceOne(eq("_id",Eid),UpdateSeedData()); 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().getString("UserEID")); } } finally { cursor5.close(); } /* 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()); Document updateDocument = d1; 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); //col1.update(updateDocument); db.getCollection("PriceDetail").updateOne(d1,updateDocument); }*/ }
From source file:com.mycompany.mavenproject2.AddUser8Controller.java
@Override public void initialize(URL url, ResourceBundle rb) { MongoCursor<Document> cursor4 = db.getCollection("SecurityRole").find().iterator(); try {/* w w w . j ava 2 s. c o m*/ 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.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 {// ww w . j a v a 2 s. co 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 {//from www . j av a 2s . c om 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 ww w. j a va2s . com 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 {/* ww w . j av a 2 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 {//ww w.j av a 2s.co m 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 a va 2 s .co 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 {/*from w w w.ja v a2s. 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; }