List of usage examples for com.mongodb DBCollection remove
public WriteResult remove(final DBObject query)
From source file:com.bbc.remarc.util.DummyDataGenerator.java
License:Apache License
private static void generateAudio(DB db) { DBCollection audio = db.getCollection("audio"); audio.remove(new BasicDBObject()); /*/* ww w.j a v a 2s. c o m*/ audio.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/audio/pirates.jpg") .add("theme", "Music").add("decade", "1970s") .add("id", "pirates") .add("mp3ContentUrl", "/remarc_resources/audio/pirates.mp3") .add("oggContentUrl", "/remarc_resources/audio/pirates.ogg") .get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/choir-der-sommer.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "choir-der-sommer") .add("mp3ContentUrl", "/remarc_resources/audio/choir-der-sommer.mp3") .add("oggContentUrl", "/remarc_resources/audio/choir-der-sommer.ogg").get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/circus-lenclume.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "circus-lenclume") .add("mp3ContentUrl", "/remarc_resources/audio/circus-lenclume.mp3") .add("oggContentUrl", "/remarc_resources/audio/circus-lenclume.ogg").get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/handel-feet.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "handel-feet") .add("mp3ContentUrl", "/remarc_resources/audio/handel-feet.mp3") .add("oggContentUrl", "/remarc_resources/audio/handel-feet.ogg").get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/krackatoa-time.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "krackatoa-time") .add("mp3ContentUrl", "/remarc_resources/audio/krackatoa-time.mp3") .add("oggContentUrl", "/remarc_resources/audio/krackatoa-time.ogg").get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/megatone-black.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "megatone-black") .add("mp3ContentUrl", "/remarc_resources/audio/megatone-black.mp3") .add("oggContentUrl", "/remarc_resources/audio/megatone-black.ogg").get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/mozart-laudate-dominum.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "mozart-laudate-dominum") .add("mp3ContentUrl", "/remarc_resources/audio/mozart-laudate-dominum.mp3") .add("oggContentUrl", "/remarc_resources/audio/mozart-laudate-dominum.ogg") .get()); audio.insert(BasicDBObjectBuilder .start() .add("imageUrl", "/remarc_resources/audio/Soniventorum-danzi.jpg") .add("theme", "Music") .add("decade", "1970s") .add("id", "Soniventorum-danzi") .add("mp3ContentUrl", "/remarc_resources/audio/Soniventorum-danzi.mp3") .add("oggContentUrl", "/remarc_resources/audio/Soniventorum-danzi.ogg") .get()); //Note: these have no images associated - this is to test the fallback audio.insert(BasicDBObjectBuilder .start() .add("theme", "Music") .add("decade", "1930s") .add("id", "audio-no-image-1") .add("mp3ContentUrl", "/remarc_resources/audio/Soniventorum-danzi.mp3") .add("oggContentUrl", "/remarc_resources/audio/Soniventorum-danzi.ogg") .get()); */ }
From source file:com.bbc.remarc.util.DummyDataGenerator.java
License:Apache License
private static void generateImages(DB db) { DBCollection images = db.getCollection("images"); images.remove(new BasicDBObject()); /*/*w w w . ja va 2 s. co m*/ images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/beatles.jpg") .add("theme", "Music").add("decade", "1970s") .add("id", "beatles").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/cars.jpg") .add("theme", "Travel").add("decade", "1960s") .add("id", "cars").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/horse_dentist.jpg") .add("theme", "Animals/Pets").add("decade", "1980s") .add("id", "horse_dentist.jpg").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/sample_1.jpg") .add("theme", "Family").add("decade", "1980s") .add("id", "sample_1").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/sample_2.jpg") .add("theme", "People").add("decade", "1950s") .add("id", "sample_2").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/sample_3.jpg") .add("theme", "Family").add("decade", "1960s") .add("id", "sample_3").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/war.jpg") .add("theme", "Events").add("decade", "1940s").add("id", "war") .get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/bbc.jpg") .add("theme", "Film").add("decade", "1960s").add("id", "bbc") .get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/hunting.jpg") .add("theme", "Work").add("decade", "1970s") .add("id", "hunting").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/indians.JPG") .add("theme", "Leisure").add("decade", "1960s") .add("id", "indians").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/new_york.jpg") .add("theme", "Travel").add("decade", "1960s") .add("id", "new_york").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/parade.jpg") .add("theme", "Events").add("decade", "1920s") .add("id", "parade").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/records.jpg") .add("theme", "Leisure").add("decade", "1980s") .add("id", "records").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/sentry.jpg") .add("theme", "Events").add("decade", "1920s") .add("id", "sentry").get()); images.insert(BasicDBObjectBuilder.start() .add("imageUrl", "/remarc_resources/images/tamer.jpg") .add("theme", "Leisure").add("decade", "1950s") .add("id", "tamer").get()); //Note: these have no images associated - this is to test the fallback images.insert(BasicDBObjectBuilder.start() .add("theme", "Work").add("decade", "1970s") .add("id", "img-no-image-1").get()); images.insert(BasicDBObjectBuilder.start() .add("theme", "Sport").add("decade", "1980s") .add("id", "img-no-image-2").get()); */ }
From source file:com.caci.dummyserver.MongoRepository.java
public void deleteObject(String table, Collection<Pair<String, String>> keys) { DB db = mongo.getDB("Objects"); DBCollection col = db.getCollection(table); DBObject queryObject = makeQueryObject(keys, null); col.remove(queryObject); }
From source file:com.callidusrobotics.droptables.model.DocumentDao.java
License:Open Source License
/** * Deletes a document from a collection. * * @param collectionName//from ww w . ja v a 2 s.c om * The collection containing the document. * @param id * The document ID * @return True if the document was deleted, false otherwise */ public WriteResult deleteDocument(String collectionName, ObjectId id) { DBCollection collection = getCollection(collectionName); return collection.remove(makeRef(id)); }
From source file:com.chdi.kundenverwaltung.KundenVerwaltungsLogic.java
public boolean deleteCustomer(String id) { DBCollection table = db.getCollection("user"); BasicDBObject searchQuery2 = new BasicDBObject().append("ID", id); DBObject user = table.findOne(searchQuery2); table.remove(user); DBObject usObject = table.findOne(searchQuery2); if (usObject == null) { return true; } else {//w w w .j a va2s . c om return false; } }
From source file:com.clavain.utils.Database.java
License:Apache License
public static void removeOldPackageTrack(int p_nodeid) { try {/*from w w w. j a va 2 s . co m*/ logger.info("Purging Package Logs for NodeID: " + p_nodeid); DB db; String dbName = com.clavain.muninmxcd.p.getProperty("mongo.dbessentials"); db = m.getDB(dbName); db.setWriteConcern(WriteConcern.SAFE); DBCollection col = db.getCollection("trackpkg"); BasicDBObject query = new BasicDBObject(); query.append("node", p_nodeid); col.remove(query); db.setWriteConcern(WriteConcern.NONE); } catch (Exception ex) { logger.error("Error in removeOldPackageTrack: " + ex.getLocalizedMessage()); } }
From source file:com.cloudbees.gasp.model.MongoConnection.java
License:Apache License
public WriteResult deleteLocationByName(String name) { DBCollection locations = getCollection(); BasicDBObject document = new BasicDBObject(); document.put("name", name); return (locations.remove(document)); }
From source file:com.cloudbees.gasp.model.MongoConnection.java
License:Apache License
public WriteResult deleteLocationByAddress(String formattedAddress) { DBCollection locations = getCollection(); BasicDBObject document = new BasicDBObject(); document.put("formattedAddress", formattedAddress); return (locations.remove(document)); }
From source file:com.damanzano.mongohw2_2.MongoHW2_2.java
public static void main(String[] args) throws UnknownHostException { MongoClient client = new MongoClient(); DB db = client.getDB("students"); DBCollection collection = db.getCollection("grades"); DBCursor allGrades = collection.find(new BasicDBObject("type", "homework")) .sort(new BasicDBObject("student_id", 1).append("score", 1)); try {/*from www.j a v a 2 s. c o m*/ String studentId = ""; while (allGrades.hasNext()) { DBObject grade = allGrades.next(); System.out.println(grade); if (!studentId.equalsIgnoreCase(((Integer) grade.get("student_id")).toString())) { System.out.println("Deleting grade " + grade.get("_id").toString() + " for student " + grade.get("student_id").toString()); collection.remove(grade); } studentId = ((Integer) grade.get("student_id")).toString(); } } finally { allGrades.close(); } }
From source file:com.data.DAO.MetodoPagoDAO.java
public static String borrarRecibo(Integer idMetodoPago) { String reciboBorrar = null;//from w ww. ja va2 s. c o m try { // To connect to mongo dbserver MongoClient mongoClient = new MongoClient("localhost", 27017); // Now connect to your databases DB db = mongoClient.getDB("hoex"); System.out.println("Connect to database successfully"); DBCollection coll = db.getCollection("Metodo_pago"); System.out.println("Collection Metodo_pago selected successfully"); BasicDBObject whereQuery = new BasicDBObject(); whereQuery.put("idMetodoPago", idMetodoPago); DBCursor cursor = coll.find(whereQuery); coll.remove(whereQuery); System.out.println("Documento elminado exitosamente"); reciboBorrar = "Success"; } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } if (reciboBorrar != null) { return "El recibo ha sido borrado exitosamente!"; } else { return "El recibo no ha sido borrado!"; } }