public boolean updateGameLog(String pbfId, String oldUsername, String newUsername) { List<GameLog> gameLogs = gameLogCollection.find(DBQuery.is("pbfId", pbfId).is("username", oldUsername)).toArray(); for (GameLog gl : gameLogs) { gl.setUsername(newUsername); gameLogCollection.updateById(gl.getId(), gl); } return !gameLogs.isEmpty(); }
/*================================================================= | Function storeMailContext | Propósito: Store the mail settings for a particular worlflow | Return values: ERROR / SUCCES code (int) ===================================================================*/ public int storeMailContext(MailContext mailContext) { try { this.db = getConnection(); this.dbCollectionMail = this.db.getCollection(this.config.getMailCollection()); JacksonDBCollection<MailContext, String> coll; coll = JacksonDBCollection.wrap(this.dbCollectionMail, MailContext.class, String.class); // if exist update if (coll.getCount(DBQuery.is("_id", mailContext.getAsociatedWorflow())) != 0) { coll.updateById(mailContext.getAsociatedWorflow(), mailContext); } else { coll.insert(mailContext); } } catch (UnknownHostException ex) { Logger.getLogger(DaoMailContext.class.getName()).log(Level.SEVERE, null, ex); return ERROR_STORING_DATA; } return DATA_SUCCESSFULLY_STORED; }
public WriteResult<GameLog, String> updateGameLogById(GameLog gameLog) { return gameLogCollection.updateById(gameLog.getId(), gameLog); }
@Override public void updateShipment(Shipment s) { shipments.updateById(s.getId(), s); }