List of usage examples for com.mongodb BasicDBObject BasicDBObject
public BasicDBObject()
From source file:Entry_OR_Exit.java
private void Exit_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Exit_buttonActionPerformed // TODO add your handling code here: try {/*from www . ja va2 s . c om*/ MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection = db.getCollection("vehicle_count"); if (radio_vehicle_check == -99) JOptionPane.showMessageDialog(null, "Please Chhose Vehicle Type"); else { if (radio_vehicle_check == 2) { int count_bike; BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("wheeler_2", 1); DBCursor cursor = collection.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count_bike = obj.getInt("wheeler_2"); System.out.println(count_bike); if (count_bike == 0) { JOptionPane.showMessageDialog(null, "No 2 Wheelers in the Parking!"); } else { setVisible(false); new Vehicle_exit(radio_vehicle_check).setVisible(true); } } else if (radio_vehicle_check == 4) { int count_car; BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("wheeler_4", 1); DBCursor cursor = collection.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count_car = obj.getInt("wheeler_4"); System.out.println(count_car); if (count_car == 0) { JOptionPane.showMessageDialog(null, "No 4 Wheelers in the Parking!"); } else { setVisible(false); new Vehicle_exit(radio_vehicle_check).setVisible(true); } } else { int count_other; BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("other", 1); DBCursor cursor = collection.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count_other = obj.getInt("other"); System.out.println(count_other); if (count_other == 0) { JOptionPane.showMessageDialog(null, "No Others in the Parking!"); } else { setVisible(false); new Vehicle_exit(radio_vehicle_check).setVisible(true); } } } } catch (Exception e) { System.err.println(e); } }
From source file:Inicio.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed //String e = EdadT.getText(); //int i = Integer.parseInt(EdadT.getText()); BasicDBObject document = new BasicDBObject(); if (Nombre.getText().equals("") || ApPaterno.getText().equals("") || ApMaterno.getText().equals("") || EdadT.getText().equals("") || matricula.getText().equals("") || Carrera.getText().equals("")) { JOptionPane.showMessageDialog(null, "Faltan campos por llenar"); } else {/*from ww w. j ava2 s . com*/ document.put("Nombre", "" + NombreT.getText() + ""); document.put("ApPaterno", "" + ApPaterno.getText() + ""); document.put("ApMaterno", "" + ApMaterno.getText() + ""); document.put("FechaNac", (String) dia.getSelectedItem() + "-" + mes.getSelectedItem() + "-" + anio.getSelectedItem()); document.put("Edad", Integer.parseInt(EdadT.getText())); document.put("Sexo", "" + sexo.getSelectedItem() + ""); document.put("Matricula", "" + matricula.getText() + ""); document.put("Semestre", Integer.parseInt("" + semestre.getSelectedItem())); document.put("Carrera", "" + Carrera.getText() + ""); tabla.insert(document); javax.swing.JOptionPane.showMessageDialog(this, "Se ha agregado exitosamente un nuevo alumno"); Inicio newFrame = new Inicio(); newFrame.setVisible(true); this.dispose(); } // TODO add your handling code here: }
From source file:act.installer.bing.BingSearcher.java
License:Open Source License
private void addBingSearchResultsForEntireDatabase() { Iterator<String> it = db.getIteratorOverInchis(new BasicDBObject()); while (it.hasNext()) { String inchi = it.next(); if (inchi.contains("FAKE")) { continue; }// w ww .j a v a 2s.c om try { addBingSearchResultsForInChI(inchi); } catch (IOException e) { LOGGER.error("Bing Search results could not be added for: %s", inchi); } } }
From source file:act.installer.bing.SearchResult.java
License:Open Source License
public BasicDBObject getBasicDBObject() { BasicDBObject topSearchResultDBObject = new BasicDBObject(); topSearchResultDBObject.put("title", getTitle()); topSearchResultDBObject.put("description", getDescription()); topSearchResultDBObject.put("url", getUrl()); return topSearchResultDBObject; }
From source file:act.installer.reachablesexplorer.ReachablesProjectionUpdate.java
License:Open Source License
public void updateDatabase(DBCollection reachables) { for (String product : products) { // The query object for this product BasicDBObject newProductQuery = new BasicDBObject().append(INCHI_KEY, product); // DB list of the substrates of this projection BasicDBList substrateList = new BasicDBList(); substrateList.addAll(substrates); // DB list of the one RO associated with this projection BasicDBList roList = new BasicDBList(); roList.addAll(ros);/* w w w. j a v a2s .com*/ // The full entry to be added to the product's precursor list BasicDBObject precursorEntry = new BasicDBObject().append(SUBSTRATES_KEY, substrateList).append(RO_KEY, roList); // The command to push the precursor entry onto the precursor list BasicDBObject precursors = new BasicDBObject(); precursors.append("$push", new BasicDBObject(PRECURSOR_KEY, precursorEntry)); // Do the update! reachables.update(newProductQuery, precursors, UPSERT, NO_MULTI); } }
From source file:act.server.BingCacheMongoDB.java
License:Open Source License
public BasicDBObject getNameSearchResultDBObjectFromName(String formattedName) { BasicDBObject whereQuery = new BasicDBObject(); BasicDBObject allFields = new BasicDBObject(); whereQuery.put("name", formattedName); return (BasicDBObject) dbBingCache.findOne(whereQuery, allFields); }
From source file:act.server.BingCacheMongoDB.java
License:Open Source License
public void cacheNameSearchResult(NameSearchResults nameSearchResults) { BasicDBObject nameSearchResultDBObject = new BasicDBObject(); nameSearchResultDBObject.put("name", nameSearchResults.getName()); Long totalCountSearchResults = nameSearchResults.getTotalCountSearchResults(); if (totalCountSearchResults >= 0) { nameSearchResultDBObject.put("totalCountSearchResults", totalCountSearchResults); }/* ww w. j av a 2s . c o m*/ Set<SearchResult> topSearchResults = nameSearchResults.getTopSearchResults(); if (topSearchResults != null) { BasicDBList topSearchResultsList = new BasicDBList(); for (SearchResult topSearchResult : topSearchResults) { topSearchResultsList.add(topSearchResult.getBasicDBObject()); } nameSearchResultDBObject.put("topSearchResults", topSearchResultsList); } dbBingCache.save(nameSearchResultDBObject); }
From source file:act.server.BingCacheMongoDB.java
License:Open Source License
public void updateTotalCountSearchResults(String formattedName, NameSearchResults nameSearchResults) { BasicDBObject whereQuery = new BasicDBObject(); whereQuery.put("name", formattedName); // Update the existing document in the cache BasicDBObject newTotalCountSearchResults = new BasicDBObject(); newTotalCountSearchResults.append("$set", new BasicDBObject().append("totalCountSearchResults", nameSearchResults.getTotalCountSearchResults())); dbBingCache.update(whereQuery, newTotalCountSearchResults); }
From source file:act.server.BingCacheMongoDB.java
License:Open Source License
public void updateTopSearchResults(String formattedName, NameSearchResults nameSearchResults) { BasicDBObject whereQuery = new BasicDBObject(); whereQuery.put("name", formattedName); // Transform Set into BasicDBList for storage BasicDBList topSearchResultsList = new BasicDBList(); for (SearchResult topSearchResult : nameSearchResults.getTopSearchResults()) { topSearchResultsList.add(topSearchResult.getBasicDBObject()); }//from w w w. ja v a 2 s . com // Update the existing document in the cache BasicDBObject newTopSearchResults = new BasicDBObject(); newTopSearchResults.append("$set", new BasicDBObject().append("topSearchResults", topSearchResultsList)); dbBingCache.update(whereQuery, newTopSearchResults); }
From source file:act.server.MongoDB.java
License:Open Source License
private static DBObject findOneDoc(DBCollection c, String id_key, Object id) { BasicDBObject query = new BasicDBObject(); query.put(id_key, id);//from ww w . j a v a 2s. c om DBObject res = c.findOne(query); return res; }