List of usage examples for com.mongodb DBCollection find
public DBCursor find()
From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java
License:Open Source License
public static void Entitydocumentinsert(int id, String FQN, String name, String container, int potincy, String directtype)// w w w.j a v a2s .c o m { try { MongoClient mongoClient = new MongoClient(mdlocalhost, mdport); DB db = mongoClient.getDB(tmtextdb); boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray()); DBCollection collection = db.getCollection("entity"); DBCursor cursor = collection.find(); BasicDBObject document = new BasicDBObject(); document.put("MySQLid", id); document.put("name", name); document.put("FQN", FQN); document.put("container", container); document.put("potincy", potincy); collection.insert(document); } catch (UnknownHostException e) { e.printStackTrace(); } catch (MongoException e) { e.printStackTrace(); } }
From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java
License:Open Source License
public static void entityupdate(String entitychildFQN, String entityfatherFQN) { try {//from w w w . ja v a 2 s . c om MongoClient mongoClient = new MongoClient(mdlocalhost, mdport); DB db = mongoClient.getDB(tmtextdb); boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray()); DBCollection collection = db.getCollection("entity"); DBCursor curs = collection.find(); while (curs.hasNext()) { DBObject dbObject = curs.next(); String FQN = ((BasicBSONObject) dbObject).getString("FQN"); String exdirecttype = ((BasicBSONObject) dbObject).getString("directtype"); if (FQN.equals(entityfatherFQN)) { dbObject.put("directtype", entitychildFQN); collection.save(dbObject); } } } catch (UnknownHostException e) { e.printStackTrace(); } catch (MongoException e) { e.printStackTrace(); } }