List of usage examples for com.mongodb DBCollection save
public WriteResult save(final DBObject document)
From source file:MDBInt.DBMongo.java
License:Apache License
public void insert(String dbName, String collectionName, String docJSON) { DB dataBase = this.getDB(dbName); DBCollection collezione = this.getCollection(dataBase, collectionName); BasicDBObject obj = (BasicDBObject) JSON.parse(docJSON); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); }
From source file:MDBInt.DBMongo.java
License:Apache License
public void updateUser(String dbName, String collectionName, String docJSON) { DB dataBase = this.getDB(dbName); DBCollection collezione = this.getCollection(dataBase, collectionName); BasicDBObject obj = (BasicDBObject) JSON.parse(docJSON); String userName;// w w w . ja v a2 s . c o m userName = obj.getString("federationUser"); obj.append("_id", userName); collezione.save(obj); }
From source file:MDBInt.DBMongo.java
License:Apache License
public void insertFederatedCloud(String dbName, String collectionName, String docJSON) { DB dataBase = this.getDB(dbName); DBCollection collezione = this.getCollection(dataBase, collectionName); BasicDBObject obj = (BasicDBObject) JSON.parse(docJSON); String userName;//from w ww . ja va 2 s . c om userName = obj.getString("cloudId"); obj.append("_id", userName); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); }
From source file:MDBInt.DBMongo.java
License:Apache License
public boolean updateStateRunTimeInfo(String dbName, String phisicalResourceId, boolean newState) { boolean result = true; BasicDBObject first = new BasicDBObject(); first.put("phisicalResourceId", phisicalResourceId); DB database = this.getDB(dbName); DBCollection collection = database.getCollection("runTimeInfo"); BasicDBObject obj = null;/*from www.ja v a2s .com*/ obj = (BasicDBObject) collection.findOne(first); obj.append("state", newState); collection.save(obj); return result; }
From source file:MDBInt.DBMongo.java
License:Apache License
public void insertfedsdnSite(String json) { DB dataBase = this.getDB(this.identityDB); DBCollection collezione = dataBase.getCollection("fedsdnSite"); BasicDBObject obj = (BasicDBObject) JSON.parse(json); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); }
From source file:MDBInt.DBMongo.java
License:Apache License
public void insertfedsdnFednet(String json) { DB dataBase = this.getDB(this.identityDB); DBCollection collezione = dataBase.getCollection("fedsdnFednet"); BasicDBObject obj = (BasicDBObject) JSON.parse(json); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); }
From source file:MDBInt.DBMongo.java
License:Apache License
public void insertfedsdnNetSeg(String json) { DB dataBase = this.getDB(this.identityDB); DBCollection collezione = dataBase.getCollection("fedsdnNetSeg"); BasicDBObject obj = (BasicDBObject) JSON.parse(json); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); }
From source file:MDBInt.DBMongo.java
License:Apache License
/** * This method is used to add inside "netIDMatch" collection, the document that represent netsegment infoes * make a correlation with internal OpenstackID. * @param dbName/* ww w . j a v a 2s.c o m*/ * @param fedsdnID * @param cloudId * @param internalNetworkId * @return * @author gtricomi */ public boolean storeInternalNetworkID(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.put("internalNetworkId", internalNetworkId); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); return true; }
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/*w w w . j a v a 2 s . co 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
/** * //ww w .ja v a2 s.co m * @param tenantName * @param cidr * @param fednets * @param netsegments * @param cloudId * @author gtricomi */ public void insertcidrInfoes(String tenantName, String cidr, String fednets, String netsegments, String cloudId) { DB dataBase = this.getDB(tenantName); DBCollection collezione = this.getCollection(dataBase, "cidrInfo"); BasicDBObject obj = new BasicDBObject(); obj.put("netsegments", netsegments); obj.put("cloudId", cloudId); obj.put("fednets", fednets); obj.put("cidr", cidr); obj.append("insertTimestamp", System.currentTimeMillis()); collezione.save(obj); }