List of usage examples for com.mongodb DBCollection drop
public void drop()
From source file:fr.eolya.utils.nosql.mongodb.MongoDBDatabase.java
License:Apache License
public void collectionDrop(String collName) { DBCollection coll = db.getCollection(collName); coll.drop(); }
From source file:it.sayservice.platform.smartplanner.otp.OTPStorage.java
License:Apache License
public void clean(MongoTemplate mongo, String collectionName) { DBCollection collection = template.getCollection(collectionName); collection.drop(); }
From source file:javaapplication15.JavaApplication15.java
/** * @param args the command line arguments * @throws java.net.UnknownHostException *///w ww.j a va 2 s. com public static void main(String[] args) throws UnknownHostException { MongoClient client = new MongoClient("localhost", 27017); DB myDB = client.getDB("m101"); DBCollection collection = myDB.getCollection("Sample2"); collection.drop(); BasicDBObject query = new BasicDBObject("x", new BasicDBObject("$gt", 10).append("$lt", 50)).append("y", new BasicDBObject("$gt", 10).append("$lt", 50)); for (int i = 0; i < 10; i++) { collection.insert( new BasicDBObject("x", new Random().nextInt(100)).append("y", new Random().nextInt(100))); } // DBObject one = collection.findOne(query); // System.out.println(one); DBCursor cursor = collection.find(query); try { while (cursor.hasNext()) { DBObject dBObject = cursor.next(); System.out.println(dBObject); } } finally { cursor.close(); } }
From source file:models.datasource.SingletonDataSource.java
public static void dropUserCollection() { DBCollection myCollection = connectDB("mongo.usersCollection"); myCollection.drop(); mongoClient.close();//from w w w. ja v a 2s.c o m }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveReport() { DBCollection reportColl = db.getCollection("report"); reportColl.drop(); BasicDBObject dbObject = (BasicDBObject) JSON.parse("{status:" + toJson(getStatus()) + ",messages:" + toJson(OntoProcessorMessageStore.getInstance()).toString() + "}"); reportColl.insert(dbObject);/*from w w w . ja v a2 s .c o m*/ }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveCategories() throws JsonProcessingException { BasicDBObject dbObject;//from w w w .j a v a 2 s. c om CarbonOntology ontology = CarbonOntology.getInstance(); DBCollection categoriesColl = db.getCollection("categories"); categoriesColl.drop(); String serialized = mapper.writeValueAsString(ontology.getCategoryTree()); dbObject = (BasicDBObject) JSON.parse(serialized); categoriesColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveImpactAndFlowTypes() throws JsonProcessingException { DBCollection impactAndFlowTypesColl = db.getCollection("impactAndFlowTypes"); impactAndFlowTypesColl.drop(); String impactTypesSerialized = mapper.writeValueAsString(ontology.getImpactTypes()); String elementaryFlowTypesSerialized = mapper.writeValueAsString(ontology.getElementaryFlowTypes()); BasicDBObject dbObject = (BasicDBObject) JSON.parse( "{impactTypes:" + impactTypesSerialized + ", flowTypes:" + elementaryFlowTypesSerialized + "}"); impactAndFlowTypesColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveOntologyTypes() throws JsonProcessingException { DBCollection impactAndFlowTypesTreeColl = db.getCollection("ontologyTypes"); impactAndFlowTypesTreeColl.drop(); String impactTypesTreeSerialized = mapper.writeValueAsString(ontology.getImpactTypesTree()); String elementaryFlowTypesTreeSerialized = mapper.writeValueAsString(ontology.getElementaryFlowTypesTree()); BasicDBObject dbObject = (BasicDBObject) JSON.parse("{impactTypesTree:" + impactTypesTreeSerialized + ", flowTypesTree:" + elementaryFlowTypesTreeSerialized + "}"); impactAndFlowTypesTreeColl.insert(dbObject); }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveRelationTypes() throws JsonProcessingException { DBCollection relationTypesColl = db.getCollection("relationTypes"); relationTypesColl.drop(); String relationTypesTreeSerialized = mapper.writeValueAsString(ontology.getRelationTypes()); BasicDBObject dbObject = (BasicDBObject) JSON.parse("{relationTypes: " + relationTypesTreeSerialized + "}"); relationTypesColl.insert(dbObject);/*from w w w . j a va 2 s. c om*/ }
From source file:models.OntoProcessor.java
License:Open Source License
protected void saveGroups() throws JsonProcessingException { DBCollection groupsColl = db.getCollection("groups"); groupsColl.drop(); for (Group group : ontology.getGroups().values()) { String serializedGroup = mapper.writeValueAsString(group); BasicDBObject dbObject = (BasicDBObject) JSON.parse(serializedGroup); dbObject.append("_id", group.getId()); groupsColl.insert(dbObject);//from w w w . j a va 2 s . c o m if (group.getType() == com.mycsense.carbondb.domain.group.Type.PROCESS) { HashMap<String, String> node = new HashMap<>(); node.put("id", group.getId()); node.put("label", group.getLabel()); nodes.add(node); processGroupsId.add(group.getId()); } } }