List of usage examples for com.mongodb BasicDBObject getInt
public int getInt(final String key)
From source file:Vehicle_exit.java
private void Exit_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Exit_buttonActionPerformed // TODO add your handling code here: try {/*www .ja va 2s. c o m*/ vehno = vehno_combo.getSelectedItem().toString(); vehno_copy = vehno; System.out.println("in button number niald" + vehno); MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection = db.getCollection("entry_info"); BasicDBObject query_time = new BasicDBObject(); BasicDBObject field_time = new BasicDBObject(); field_time.put("intime", 1); DBCursor cursor = collection.find(query_time, field_time); BasicDBObject query_token = new BasicDBObject(); BasicDBObject field_token = new BasicDBObject(); field_time.put("vehno", 1); DBCursor cursor_token = collection.find(query_token, field_token); while (cursor.hasNext()) { BasicDBObject obj_time = (BasicDBObject) cursor.next(); in_time_mills = Long.parseLong(obj_time.getString("intime")); BasicDBObject obj_token = (BasicDBObject) cursor_token.next(); //db_token = obj_token.getInt("_id"); vehno_db = obj_token.getString("vehno"); System.out.println(vehno_db); System.out.println("hello"); System.out.println("hey ayu"); DBCollection collection1 = db.getCollection("vehicle_count"); DBCollection collection2 = db.getCollection("statistics"); vehno = vehno_copy; if (veh_count == 2) { //vehno = vehno + "W2"; if (vehno.equals(vehno_db)) { flag = 1; BasicDBObject deleteObject = new BasicDBObject(); //deleteObject.put("_id",Token); deleteObject.put("vehno", vehno); DBCursor findQuery = collection.find(deleteObject); collection.remove(deleteObject); int count_bike; BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("wheeler_2", 1); DBCursor cursor1 = collection1.find(query, field); BasicDBObject obj = (BasicDBObject) cursor1.next(); count_bike = obj.getInt("wheeler_2"); System.out.println(count_bike); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_2", count_bike); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_2", count_bike - 1)); collection1.update(searchUpdate, UpdateObject); System.out.println("Checking..."); time_diff = exit_time_mills - in_time_mills; time_diff = time_diff / 1000; time_diff = time_diff / 60; System.out.println("difftime" + time_diff); if (time_diff > 60) charges = 20 + (time_diff) / 2; else charges = 20; //updating session... int income_bike; BasicDBObject query2 = new BasicDBObject(); BasicDBObject field2 = new BasicDBObject(); field2.put("2wheeler_income", 1); DBCursor cursor2 = collection2.find(query2, field2); BasicDBObject obj2 = (BasicDBObject) cursor2.next(); income_bike = obj2.getInt("2wheeler_income"); System.out.println(income_bike); BasicDBObject searchUpdate2 = new BasicDBObject(); searchUpdate2.append("2wheeler_income", income_bike); BasicDBObject UpdateObject2 = new BasicDBObject(); UpdateObject2.append("$set", new BasicDBObject("2wheeler_income", income_bike + charges)); collection2.update(searchUpdate2, UpdateObject2); JOptionPane.showMessageDialog(null, "Vehicle Out !\n" + /*"In Time : " + in_time_mills + "\n" +*/ "Extra Parking Time : " + time_diff + "Min.\n" + "Charges : " + charges); System.out.println("Checked..."); setVisible(false); new Entry_OR_Exit().setVisible(true); break; } } else if (veh_count == 4) { //vehno = vehno + "W4"; if (vehno.equals(vehno_db)) { flag = 1; BasicDBObject deleteObject = new BasicDBObject(); //deleteObject.put("_id",Token); deleteObject.put("vehno", vehno); DBCursor findQuery = collection.find(deleteObject); collection.remove(deleteObject); int count_car; BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("wheeler_4", 1); DBCursor cursor1 = collection1.find(query, field); BasicDBObject obj = (BasicDBObject) cursor1.next(); count_car = obj.getInt("wheeler_4"); System.out.println(count_car); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_4", count_car); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_4", count_car - 1)); collection1.update(searchUpdate, UpdateObject); System.out.println("Checking...2"); time_diff = exit_time_mills - in_time_mills; time_diff = time_diff / 1000; time_diff = time_diff / 60; System.out.println("difftime" + time_diff); if (time_diff > 60) charges = 40 + (time_diff) * 3 / 2; else charges = 40; //Session update.... int income_car; BasicDBObject query2 = new BasicDBObject(); BasicDBObject field2 = new BasicDBObject(); field2.put("4wheeler_income", 1); DBCursor cursor2 = collection2.find(query2, field2); BasicDBObject obj2 = (BasicDBObject) cursor2.next(); income_car = obj2.getInt("4wheeler_income"); System.out.println(income_car); BasicDBObject searchUpdate2 = new BasicDBObject(); searchUpdate2.append("4wheeler_income", income_car); BasicDBObject UpdateObject2 = new BasicDBObject(); UpdateObject2.append("$set", new BasicDBObject("4wheeler_income", income_car + charges)); collection2.update(searchUpdate2, UpdateObject2); JOptionPane.showMessageDialog(null, "Vehicle Out !\n" + /*"In Time : " + in_time_mills + "\n" +*/ "Extra Parking Time : " + time_diff + "Min.\n" + "Charges : " + charges); System.out.println("Checking...2"); setVisible(false); new Entry_OR_Exit().setVisible(true); break; } } else { //vehno = vehno + "W6"; if (vehno.equals(vehno_db)) { flag = 1; BasicDBObject deleteObject = new BasicDBObject(); //deleteObject.put("_id",Token); deleteObject.put("vehno", vehno); DBCursor findQuery = collection.find(deleteObject); collection.remove(deleteObject); int count_other; BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("other", 1); DBCursor cursor1 = collection1.find(query, field); BasicDBObject obj = (BasicDBObject) cursor1.next(); count_other = obj.getInt("other"); System.out.println(count_other); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("other", count_other); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("other", count_other - 1)); collection1.update(searchUpdate, UpdateObject); System.out.println("Checking...3"); time_diff = exit_time_mills - in_time_mills; time_diff = time_diff / 1000; time_diff = time_diff / 60; System.out.println("difftime" + time_diff); if (time_diff > 60) charges = 60 + (time_diff); else charges = 60; //sessiuon update.... int income_other; BasicDBObject query2 = new BasicDBObject(); BasicDBObject field2 = new BasicDBObject(); field2.put("other_income", 1); DBCursor cursor2 = collection2.find(query2, field2); BasicDBObject obj2 = (BasicDBObject) cursor2.next(); income_other = obj2.getInt("other_income"); System.out.println(income_other); BasicDBObject searchUpdate2 = new BasicDBObject(); searchUpdate2.append("other_income", income_other); BasicDBObject UpdateObject2 = new BasicDBObject(); UpdateObject2.append("$set", new BasicDBObject("other_income", income_other + charges)); collection2.update(searchUpdate2, UpdateObject2); JOptionPane.showMessageDialog(null, "Vehicle Out !\n" + /*"In Time : " + in_time_mills + "\n" +*/ "Extra Parking Time : " + time_diff + "Min.\n" + "Charges : " + charges); System.out.println("Checked...3"); setVisible(false); new Entry_OR_Exit().setVisible(true); break; } } //} } if (flag == 0) { JOptionPane.showMessageDialog(null, "Invalid Vehicle Number or Type"); setVisible(false); new Entry_OR_Exit().setVisible(true); } /* BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_2", count_bike); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_2", count_bike + 1)); collection.update(searchUpdate, UpdateObject); */ //} } catch (Exception e) { } }
From source file:Session_details.java
public void updateSession(String s1)//, String s2) { try {/*w w w . j a va 2 s. co m*/ int count; MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection2 = db.getCollection("statistics"); BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put(s1, 1); DBCursor cursor = collection2.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count = obj.getInt(s1); System.out.println(count); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append(s1, count); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject(s1, 0)); collection2.update(searchUpdate, UpdateObject); } catch (Exception e) { } }
From source file:Veehicle_entry.java
private void Entry_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Entry_buttonActionPerformed // TODO add your handling code here: try {//w w w .j a v a 2 s . c o m String name, vehno, mobno; Random rand = new Random(); token = rand.nextInt(10000); name = Name_field.getText(); mobno = mobno_field.getText(); vehno = vehno_strt1.getSelectedItem().toString() + "-" + vehno_strt2.getText() + "-" + vehno_strt3.getSelectedItem().toString() + "-" + vehno_strt4.getText(); //System.out.println(vehno); MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection = db.getCollection("entry_info"); DBCollection collection1 = db.getCollection("vehicle_count"); DBCollection collection2 = db.getCollection("statistics"); if (veh_count == 2) { vehno = vehno + "W2"; BasicDBObject queryx = new BasicDBObject(); BasicDBObject fieldx = new BasicDBObject(); fieldx.put("vehno", 1); DBCursor cursorx = collection.find(queryx, fieldx); while (cursorx.hasNext()) { BasicDBObject objx = (BasicDBObject) cursorx.next(); String temp; temp = objx.getString("vehno"); if (temp.equals(vehno)) { JOptionPane.showMessageDialog(null, "vehicle number already exits!\n Entry Rejected!"); exists = 1; setVisible(false); new Veehicle_entry(veh_count).setVisible(true); } } if (exists == 0) { int count_bike; BasicDBObject doc = new BasicDBObject("_id", token).append("name", name) .append("mobileno", mobno).append("vehno", vehno).append("intime", time_mills); validator = validate(collection, doc); if (validator == 1) { //Updating vehicle count.... BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("wheeler_2", 1); DBCursor cursor = collection1.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count_bike = obj.getInt("wheeler_2"); System.out.println(count_bike); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_2", count_bike); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_2", count_bike + 1)); collection1.update(searchUpdate, UpdateObject); //updating session... int cnt_bike; BasicDBObject query2 = new BasicDBObject(); BasicDBObject field2 = new BasicDBObject(); field2.put("2wheeler_count", 1); DBCursor cursor2 = collection2.find(query2, field2); BasicDBObject obj2 = (BasicDBObject) cursor2.next(); cnt_bike = obj2.getInt("2wheeler_count"); System.out.println(cnt_bike); BasicDBObject searchUpdate2 = new BasicDBObject(); searchUpdate2.append("2wheeler_count", cnt_bike); BasicDBObject UpdateObject2 = new BasicDBObject(); UpdateObject2.append("$set", new BasicDBObject("2wheeler_count", cnt_bike + 1)); collection2.update(searchUpdate2, UpdateObject2); setVisible(false); new Entry_OR_Exit().setVisible(true); } } } else if (veh_count == 4) { vehno = vehno + "W4"; BasicDBObject queryx = new BasicDBObject(); BasicDBObject fieldx = new BasicDBObject(); fieldx.put("vehno", 1); DBCursor cursorx = collection.find(queryx, fieldx); while (cursorx.hasNext()) { BasicDBObject objx = (BasicDBObject) cursorx.next(); String temp; temp = objx.getString("vehno"); if (temp.equals(vehno)) { JOptionPane.showMessageDialog(null, "vehicle number already exits!\n Entry Rejected!"); exists = 1; setVisible(false); new Veehicle_entry(veh_count).setVisible(true); } } if (exists == 0) { int count_car; BasicDBObject doc = new BasicDBObject("_id", token).append("name", name) .append("mobileno", mobno).append("vehno", vehno).append("intime", time_mills); validator = validate(collection, doc); if (validator == 1) { BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("wheeler_4", 1); DBCursor cursor = collection1.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count_car = obj.getInt("wheeler_4"); System.out.println(count_car); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_4", count_car); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_4", count_car + 1)); collection1.update(searchUpdate, UpdateObject); //updating session... int cnt_car; BasicDBObject query2 = new BasicDBObject(); BasicDBObject field2 = new BasicDBObject(); field2.put("4wheeler_count", 1); DBCursor cursor2 = collection2.find(query2, field2); BasicDBObject obj2 = (BasicDBObject) cursor2.next(); cnt_car = obj2.getInt("4wheeler_count"); System.out.println(cnt_car); BasicDBObject searchUpdate2 = new BasicDBObject(); searchUpdate2.append("4wheeler_count", cnt_car); BasicDBObject UpdateObject2 = new BasicDBObject(); UpdateObject2.append("$set", new BasicDBObject("4wheeler_count", cnt_car + 1)); collection2.update(searchUpdate2, UpdateObject2); setVisible(false); new Entry_OR_Exit().setVisible(true); } } } else { vehno = vehno + "W6"; BasicDBObject queryx = new BasicDBObject(); BasicDBObject fieldx = new BasicDBObject(); fieldx.put("vehno", 1); DBCursor cursorx = collection.find(queryx, fieldx); while (cursorx.hasNext()) { BasicDBObject objx = (BasicDBObject) cursorx.next(); String temp; temp = objx.getString("vehno"); if (temp.equals(vehno)) { JOptionPane.showMessageDialog(null, "vehicle number already exits!\n Entry Rejected!"); exists = 1; setVisible(false); new Veehicle_entry(veh_count).setVisible(true); } } if (exists == 0) { int count_other; BasicDBObject doc = new BasicDBObject("_id", token).append("name", name) .append("mobileno", mobno).append("vehno", vehno).append("intime", time_mills); validator = validate(collection, doc); if (validator == 1) { System.out.println("Came 1"); BasicDBObject query = new BasicDBObject(); BasicDBObject field = new BasicDBObject(); field.put("other", 1); DBCursor cursor = collection1.find(query, field); BasicDBObject obj = (BasicDBObject) cursor.next(); count_other = obj.getInt("other"); System.out.println(count_other); BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("other", count_other); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("other", count_other + 1)); collection1.update(searchUpdate, UpdateObject); //updating session... int cnt_other; BasicDBObject query2 = new BasicDBObject(); BasicDBObject field2 = new BasicDBObject(); field2.put("other_count", 1); DBCursor cursor2 = collection2.find(query2, field2); BasicDBObject obj2 = (BasicDBObject) cursor2.next(); cnt_other = obj2.getInt("other_count"); System.out.println(cnt_other); BasicDBObject searchUpdate2 = new BasicDBObject(); searchUpdate2.append("other_count", cnt_other); BasicDBObject UpdateObject2 = new BasicDBObject(); UpdateObject2.append("$set", new BasicDBObject("other_count", cnt_other + 1)); collection2.update(searchUpdate2, UpdateObject2); setVisible(false); new Entry_OR_Exit().setVisible(true); } } } } catch (Exception e) { } }
From source file:Vehicle_type_check.java
private void bike_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bike_buttonActionPerformed // TODO add your handling code here: try {// w w w. j av a 2 s.co m int count_bike; System.out.println("Hello_End"); MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection = db.getCollection("vehicle_count"); 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 < 50) { BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_2", count_bike); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_2", count_bike + 1)); collection.update(searchUpdate, UpdateObject); setVisible(false); new Veehicle_entry().setVisible(true); } else { JOptionPane.showMessageDialog(null, "No Available Space For Parking 2 Wheelers"); } } catch (Exception e) { } }
From source file:Vehicle_type_check.java
private void other_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_other_buttonActionPerformed // TODO add your handling code here: try {//from w w w. j a v a2 s . c o m int count_other; MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection = db.getCollection("vehicle_count"); 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 < 50) { BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("other", count_other); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("other", count_other + 1)); collection.update(searchUpdate, UpdateObject); setVisible(false); new Veehicle_entry().setVisible(true); } else { JOptionPane.showMessageDialog(null, "No Available Space For Parking Trucks"); } } catch (Exception e) { } }
From source file:Vehicle_type_check.java
private void car_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_car_buttonActionPerformed // TODO add your handling code here: try {/*from ww w . j a v a2 s. c o m*/ int count_car; MongoClient mc = new MongoClient("localhost", 27017); DB db = mc.getDB("parking_system"); DBCollection collection = db.getCollection("vehicle_count"); 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 < 50) { BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_4", count_car); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_4", count_car + 1)); collection.update(searchUpdate, UpdateObject); setVisible(false); new Veehicle_entry().setVisible(true); } else { JOptionPane.showMessageDialog(null, "No Available Space For Parking 2 Wheelers"); } } catch (Exception e) { } }
From source file:Entry_OR_Exit.java
private void Entry_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Entry_buttonActionPerformed // TODO add your handling code here: /*/*from www .ja va 2s .c o m*/ setVisible(false); new Vehicle_type_check().setVisible(true); */ try { 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 < 50) { /*BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_2", count_bike); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_2", count_bike + 1)); collection.update(searchUpdate, UpdateObject); */ setVisible(false); new Veehicle_entry(radio_vehicle_check).setVisible(true); } else { JOptionPane.showMessageDialog(null, "No Available Space For Parking 2 Wheelers"); } } 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 < 50) { /* BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("wheeler_4", count_car); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("wheeler_4",count_car+1)); collection.update(searchUpdate, UpdateObject); */ setVisible(false); new Veehicle_entry(radio_vehicle_check).setVisible(true); } else { JOptionPane.showMessageDialog(null, "No Available Space For Parking 2 Wheelers"); } } 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 < 50) { /* BasicDBObject searchUpdate = new BasicDBObject(); searchUpdate.append("other", count_other); BasicDBObject UpdateObject = new BasicDBObject(); UpdateObject.append("$set", new BasicDBObject("other", count_other + 1)); collection.update(searchUpdate, UpdateObject); */ setVisible(false); new Veehicle_entry(radio_vehicle_check).setVisible(true); } else { JOptionPane.showMessageDialog(null, "No Available Space For Parking Trucks"); } } } } catch (Exception e) { } }
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 {// www . java 2 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:br.bireme.scl.BrokenLinks.java
License:Open Source License
private static int getIsisIdField(final String mstName, final DBCollection coll) throws IOException { assert mstName != null; assert coll != null; final BasicDBObject query = new BasicDBObject(MST_FIELD, mstName); final BasicDBObject doc = (BasicDBObject) coll.findOne(query); if (doc == null) { throw new IOException( "Missing fields: collection[" + coll.getName() + "] or master name[" + mstName + "]"); }//from w w w.j ava 2 s . c om return doc.getInt(ID_TAG_FIELD); }
From source file:br.bireme.scl.BrokenLinks.java
License:Open Source License
private static int getIsisUrlFields(final String mstName, final DBCollection coll) throws IOException { assert mstName != null; assert coll != null; final BasicDBObject query = new BasicDBObject(MST_FIELD, mstName); final BasicDBObject doc = (BasicDBObject) coll.findOne(query); if (doc == null) { throw new IOException( "Missing fields: collection[" + coll.getName() + "] or master name[" + mstName + "]"); }//from ww w . ja v a 2 s.c o m return doc.getInt(URL_TAG_FIELD); }