List of usage examples for com.mongodb DBCollection findOne
@Nullable public DBObject findOne(final Object id)
From source file:MDBInt.DBMongo.java
License:Apache License
public String getfedsdnFednet(String federationTenantName) { DB database = this.getDB(this.identityDB); DBCollection collection = database.getCollection("fedsdnFednet"); BasicDBObject researchField = new BasicDBObject("federationTenantName", federationTenantName); DBObject risultato = collection.findOne(researchField); return risultato.toString(); }
From source file:MDBInt.DBMongo.java
License:Apache License
public int getfedsdnFednetID(String federationTenantName) { DB database = this.getDB(this.identityDB); DBCollection collection = database.getCollection("fedsdnFednet"); BasicDBObject researchField = new BasicDBObject("federationTenantName", federationTenantName); DBObject risultato = collection.findOne(researchField); return ((Number) risultato.get("id")).intValue();//((Number) mapObj.get("autostart")).intValue()//(float) ((double) result.get(v)) }
From source file:MDBInt.DBMongo.java
License:Apache License
public String getfedsdnNetSeg(String vnetName, String CloudID) { DB database = this.getDB(this.identityDB); DBCollection collection = database.getCollection("fedsdnNetSeg"); BasicDBObject researchField = new BasicDBObject("CloudID", CloudID).append("vnetName", vnetName); DBObject risultato = collection.findOne(researchField); return risultato.toString(); }
From source file:MDBInt.DBMongo.java
License:Apache License
public int getfedsdnNetSegID(String vnetName, String CloudID) { DB database = this.getDB(this.identityDB); DBCollection collection = database.getCollection("fedsdnNetSeg"); BasicDBObject researchField = new BasicDBObject("CloudID", CloudID).append("vnetName", vnetName); DBObject risultato = collection.findOne(researchField); return ((Number) risultato.get("id")).intValue();//((Number) mapObj.get("autostart")).intValue()//(float) ((double) result.get(v)) }
From source file:MDBInt.DBMongo.java
License:Apache License
/** * This method is used to update inside "netIDMatch" collection, the document that represent netsegment infoes * make a correlation with internal OpenstackID. * @param dbName, tenant name//from w w w . jav a 2s . c o m * @param fedsdnID, netsegment id stored on FEDSDN * @param cloudId * @param internalNetworkId * @return * @author gtricomi */ public boolean updateInternalNetworkID(String dbName, String fedsdnID, String cloudId, String internalNetworkId) { DB dataBase = this.getDB(dbName); DBCollection collezione = this.getCollection(dataBase, "netIDMatch"); BasicDBObject obj = new BasicDBObject(); obj.put("fedsdnID", fedsdnID); obj.put("cloudId", cloudId); obj = (BasicDBObject) collezione.findOne(obj); if (obj == null) { LOGGER.error("Document with fedsdnID:" + fedsdnID + " ,cloudId :" + cloudId + " for tenant :" + dbName + " isn't found!"); return false; } obj.replace("internalNetworkId", internalNetworkId); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); return true; }
From source file:MDBInt.DBMongo.java
License:Apache License
/** * // w w w . j av a 2 s.c om * @param fedsdnID * @param dbName, name of the Db where execute the operation * @return * @author gtricomi */ public String getInternalNetworkID(String dbName, String fedsdnID, String cloudId) { DB dataBase = this.getDB(dbName); DBCollection collezione = dataBase.getCollection("netIDMatch"); BasicDBObject obj = new BasicDBObject("fedsdnID", fedsdnID); obj.put("cloudId", cloudId); DBObject risultato = collezione.findOne(obj); if (risultato == null) return null; return risultato.get("internalNetworkId").toString(); }
From source file:MDBInt.DBMongo.java
License:Apache License
/** * This function take from Collection "cidrInfo" the element that match with field contained inside hashmap researchParams. * @param tenantName, DbName where the collection is stored * @param researchParams, container for research params * @return JSONObject/null, JSONObject when the criteria match, null object in other cases. * @author gtricomi/*from w ww . j a v a 2 s. c om*/ */ public org.json.JSONObject getcidrInfoes(String tenantName, HashMap researchParams) throws Exception { DB dataBase = this.getDB(tenantName); DBCollection collezione = dataBase.getCollection("cidrInfo"); Iterator i = researchParams.keySet().iterator(); BasicDBObject obj = new BasicDBObject(); while (i.hasNext()) { String tmpkey = (String) i.next(); obj.put(tmpkey, researchParams.get(tmpkey)); } DBObject risultato = collezione.findOne(obj); if (risultato == null) return null; try { return new org.json.JSONObject(risultato.toString()); } catch (Exception e) { LOGGER.error("Error occurred in DBObject parsing operation for getcidrInfoes.\n" + e.getMessage()); throw e; } }
From source file:me.yyam.mongodbutils.MongoDbOperater.java
public <T> T findOneObj(String dbName, String collName, Map queryMap, Class<T> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException { DB db = mongoClient.getDB(dbName);/*from w ww .ja v a 2 s.c o m*/ DBCollection coll = db.getCollection(collName); BasicDBObject query = new BasicDBObject(queryMap); DBObject map = coll.findOne(query); if (map == null) { return null; } T obj = clazz.newInstance(); ConvertUtils.register(new DateConverter(null), Date.class); BeanUtils.populate(obj, map.toMap()); return obj; }
From source file:me.yyam.mongodbutils.MongoDbOperater.java
public Map findOne(String dbName, String collName, Map queryMap) throws InstantiationException, IllegalAccessException, InvocationTargetException { DB db = mongoClient.getDB(dbName);/* ww w . ja va 2s.c o m*/ DBCollection coll = db.getCollection(collName); BasicDBObject query = new BasicDBObject(queryMap); DBObject map = coll.findOne(query); if (map == null) { return null; } return map.toMap(); }
From source file:model.DocumentoDAO.java
public static void removerPorNome(String nomeTexto) { DB db = ConnectionFactory.create();/* w w w. j a va 2 s . c o m*/ DBCollection coll = db.getCollection("documentos"); DBObject query = new BasicDBObject("nome", nomeTexto); DBObject resultado = coll.findOne(query); coll.remove(resultado); }