List of usage examples for com.mongodb.client MongoCollection find
FindIterable<TDocument> find(ClientSession clientSession);
From source file:Mangement.Details.java
public void initialize(URL url, ResourceBundle rb) { Connector con = new Connector(); con.connect();//from w ww.ja v a 2s . c om MongoCollection<Document> col = con.getData(); Document d; d = col.find(eq("itemId", Menu.idno)).first(); System.out.println(me.idno); jLabel4.setText((String) d.get("Customer Name")); jLabel5.setText((String) d.get("Address")); if (d.containsKey("Phone")) jLabel6.setText((String) d.get("Phone")); if (d.containsKey("Company")) jLabel7.setText((String) d.get("Company")); jLabel8.setText((String) d.get("Entry_by")); jLabel9.setText((String) d.get("Quantity")); jLabel9.setText((String) d.get("Price")); jLabel16.setText((String) d.get("Warrenty")); }
From source file:Mangement.ProDetails.java
public void initialize(URL url, ResourceBundle rb) { ProductController con = new ProductController(); con.connect();/*from w ww. j a va2s . c om*/ MongoCollection<Document> col = con.getData(); Document d; d = col.find(eq("itemId", ProClass.idno)).first(); System.out.println(d); jLabel4.setText((String) d.get("Item Name")); jLabel5.setText((String) d.get("Company")); jLabel6.setText((String) d.get("Entry_by")); if (d.containsKey("Price")) jLabel7.setText((String) d.get("Price")); if (d.containsKey("Quantity")) jLabel8.setText((String) d.get("Quantity")); }
From source file:Mangement.ProUpdate.java
public void initialize(URL url, ResourceBundle rb) { ProductController con = new ProductController(); con.connect();/* www .j av a 2s.c o m*/ MongoCollection<Document> col = con.getData(); Document d; d = col.find(eq("itemId", ProClass.idno)).first(); itemName.setText((String) d.get("Item Name")); company.setText((String) d.get("Company")); brand.setText((String) d.get("Brand")); price.setText((String) d.get("Price")); quantity.setText((String) d.get("Quantity")); }
From source file:Mangement.SellItem.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed Document doc;/*from ww w .j av a2 s. com*/ doc = new Document(); ProductController conu = new ProductController(); conu.connect(); String prc = conu.find((String) jComboBox1.getSelectedItem()); if (!custName.getText().isEmpty()) doc.append("Customer Name", custName.getText()); if (!phone.getText().isEmpty()) doc.append("Phone", phone.getText()); doc.append("Company", (String) jComboBox1.getSelectedItem()); if (!jTextField1.getText().isEmpty()) doc.append("Quantity", jTextField1.getText()); if (!price.getText().isEmpty()) doc.append("Price", price.getText()); if (!war.getText().isEmpty()) doc.append("Warrenty", war.getText()); if (!add.getText().isEmpty()) doc.append("Address", add.getText()); doc.append("Entry_by", Menu.handle); Connector con = new Connector(); con.connect(); int index = con.getIndex(); doc.append("itemId", index); con.insert(doc); System.out.println("data inserted"); Document don; don = new Document(); MongoCollection<Document> col = con.getData(); Document d; d = col.find(eq("itemId", ind)).first(); available = Integer.parseInt(quantity) - Integer.parseInt(jTextField1.getText()); System.out.println(available); don.append("Quantity", Integer.toString(available)); ProductController conn = new ProductController(); conn.connect(); System.out.println("jkb" + ind); conn.update("itemId", ind, "Quantity", Integer.toString(available)); Menu menu = new Menu(); LogIn.log.getContentPane().removeAll(); LogIn.log.getContentPane().add(Menu.MenuPan); LogIn.log.repaint(); LogIn.log.revalidate(); }
From source file:Mangement.Update.java
public void initialize(URL url, ResourceBundle rb) { Connector con = new Connector(); con.connect();/*from ww w . j a va 2s .c o m*/ MongoCollection<Document> col = con.getData(); Document d; d = col.find(eq("itemId", me.idno)).first(); System.out.println(me.idno); custName.setText((String) d.get("Customer Name")); add.setText((String) d.get("Address")); if (d.containsKey("Phone")) phone.setText((String) d.get("Phone")); jTextField1.setText((String) d.get("Quantity")); if (d.containsKey("Brand")) jTextField1.setText((String) d.get("Brand")); price.setText((String) d.get("Price")); war.setText((String) d.get("Warrenty")); }
From source file:me.lucko.luckperms.common.storage.backing.MongoDBBacking.java
License:Open Source License
@Override public boolean loadUser(UUID uuid, String username) { User user = plugin.getUserManager().getOrMake(UserIdentifier.of(uuid, username)); user.getIoLock().lock();/*from w w w .j a v a 2 s . c om*/ try { return call(() -> { MongoCollection<Document> c = database.getCollection("users"); try (MongoCursor<Document> cursor = c.find(new Document("_id", user.getUuid())).iterator()) { if (cursor.hasNext()) { // User exists, let's load. Document d = cursor.next(); user.setNodes(revert((Map<String, Boolean>) d.get("perms"))); user.setPrimaryGroup(d.getString("primaryGroup")); boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false); if (user.getName() == null || user.getName().equalsIgnoreCase("null")) { user.setName(d.getString("name")); } else { if (!d.getString("name").equalsIgnoreCase(user.getName())) { save = true; } } if (save) { c.replaceOne(new Document("_id", user.getUuid()), fromUser(user)); } } else { if (GenericUserManager.shouldSave(user)) { user.clearNodes(); user.setPrimaryGroup(null); plugin.getUserManager().giveDefaultIfNeeded(user, false); } } } return true; }, false); } finally { user.getIoLock().unlock(); user.getRefreshBuffer().requestDirectly(); } }
From source file:me.lucko.luckperms.common.storage.backing.MongoDBBacking.java
License:Open Source License
@Override public boolean saveUser(User user) { if (!GenericUserManager.shouldSave(user)) { user.getIoLock().lock();/*from w ww . ja v a2s . c om*/ try { return call(() -> { MongoCollection<Document> c = database.getCollection("users"); return c.deleteOne(new Document("_id", user.getUuid())).wasAcknowledged(); }, false); } finally { user.getIoLock().unlock(); } } user.getIoLock().lock(); try { return call(() -> { MongoCollection<Document> c = database.getCollection("users"); try (MongoCursor<Document> cursor = c.find(new Document("_id", user.getUuid())).iterator()) { if (!cursor.hasNext()) { c.insertOne(fromUser(user)); } else { c.replaceOne(new Document("_id", user.getUuid()), fromUser(user)); } } return true; }, false); } finally { user.getIoLock().unlock(); } }
From source file:me.lucko.luckperms.common.storage.backing.MongoDBBacking.java
License:Open Source License
@Override public boolean createAndLoadGroup(String name) { Group group = plugin.getGroupManager().getOrMake(name); group.getIoLock().lock();/*from w ww.j av a 2 s. co m*/ try { return call(() -> { MongoCollection<Document> c = database.getCollection("groups"); try (MongoCursor<Document> cursor = c.find(new Document("_id", group.getName())).iterator()) { if (cursor.hasNext()) { // Group exists, let's load. Document d = cursor.next(); group.setNodes(revert((Map<String, Boolean>) d.get("perms"))); } else { c.insertOne(fromGroup(group)); } } return true; }, false); } finally { group.getIoLock().unlock(); } }
From source file:me.lucko.luckperms.common.storage.backing.MongoDBBacking.java
License:Open Source License
@Override public boolean loadGroup(String name) { Group group = plugin.getGroupManager().getOrMake(name); group.getIoLock().lock();//from w ww . j a va 2 s.c o m try { return call(() -> { MongoCollection<Document> c = database.getCollection("groups"); try (MongoCursor<Document> cursor = c.find(new Document("_id", group.getName())).iterator()) { if (cursor.hasNext()) { Document d = cursor.next(); group.setNodes(revert((Map<String, Boolean>) d.get("perms"))); return true; } return false; } }, false); } finally { group.getIoLock().unlock(); } }
From source file:me.lucko.luckperms.common.storage.backing.MongoDBBacking.java
License:Open Source License
@Override public boolean createAndLoadTrack(String name) { Track track = plugin.getTrackManager().getOrMake(name); track.getIoLock().lock();/*from w ww . j a va2 s .c o m*/ try { return call(() -> { MongoCollection<Document> c = database.getCollection("tracks"); try (MongoCursor<Document> cursor = c.find(new Document("_id", track.getName())).iterator()) { if (!cursor.hasNext()) { c.insertOne(fromTrack(track)); } else { Document d = cursor.next(); track.setGroups((List<String>) d.get("groups")); } } return true; }, false); } finally { track.getIoLock().unlock(); } }