List of usage examples for com.mongodb BasicDBObject append
@Override public BasicDBObject append(final String key, final Object val)
From source file:act.installer.reachablesexplorer.ReachablesProjectionUpdate.java
License:Open Source License
public void updateDatabase(DBCollection reachables) { for (String product : products) { // The query object for this product BasicDBObject newProductQuery = new BasicDBObject().append(INCHI_KEY, product); // DB list of the substrates of this projection BasicDBList substrateList = new BasicDBList(); substrateList.addAll(substrates); // DB list of the one RO associated with this projection BasicDBList roList = new BasicDBList(); roList.addAll(ros);//from w w w .ja v a 2 s .co m // The full entry to be added to the product's precursor list BasicDBObject precursorEntry = new BasicDBObject().append(SUBSTRATES_KEY, substrateList).append(RO_KEY, roList); // The command to push the precursor entry onto the precursor list BasicDBObject precursors = new BasicDBObject(); precursors.append("$push", new BasicDBObject(PRECURSOR_KEY, precursorEntry)); // Do the update! reachables.update(newProductQuery, precursors, UPSERT, NO_MULTI); } }
From source file:act.server.BingCacheMongoDB.java
License:Open Source License
public void updateTotalCountSearchResults(String formattedName, NameSearchResults nameSearchResults) { BasicDBObject whereQuery = new BasicDBObject(); whereQuery.put("name", formattedName); // Update the existing document in the cache BasicDBObject newTotalCountSearchResults = new BasicDBObject(); newTotalCountSearchResults.append("$set", new BasicDBObject().append("totalCountSearchResults", nameSearchResults.getTotalCountSearchResults())); dbBingCache.update(whereQuery, newTotalCountSearchResults); }
From source file:act.server.BingCacheMongoDB.java
License:Open Source License
public void updateTopSearchResults(String formattedName, NameSearchResults nameSearchResults) { BasicDBObject whereQuery = new BasicDBObject(); whereQuery.put("name", formattedName); // Transform Set into BasicDBList for storage BasicDBList topSearchResultsList = new BasicDBList(); for (SearchResult topSearchResult : nameSearchResults.getTopSearchResults()) { topSearchResultsList.add(topSearchResult.getBasicDBObject()); }// w w w . ja v a 2s .c om // Update the existing document in the cache BasicDBObject newTopSearchResults = new BasicDBObject(); newTopSearchResults.append("$set", new BasicDBObject().append("topSearchResults", topSearchResultsList)); dbBingCache.update(whereQuery, newTopSearchResults); }
From source file:act.server.MongoDB.java
License:Open Source License
public Map<String, Long> constructAllInChIs() { Map<String, Long> chems = new HashMap<String, Long>(); BasicDBObject keys = new BasicDBObject(); keys.append("_id", true); keys.append("InChI", true); DBCursor cur = constructCursorForMatchingChemicals(null, null, keys); while (cur.hasNext()) { DBObject o = cur.next();/*w w w .j av a2 s. c o m*/ long uuid = (Long) o.get("_id"); // checked: db type IS long String inchi = (String) o.get("InChI"); chems.put(inchi, uuid); } cur.close(); return chems; }
From source file:App.modules.users.Client.Model.dao.Client_DB_DAO.java
public static void update_Client(Client c) { //Prepara para insertar un nuevo campo BasicDBObject update = new BasicDBObject(); update.append("$set", new BasicDBObject(c.to_DB_Client())); /**// w w w . j a v a 2s .c o m update.append("$set", new BasicDBObject().append("nom", c.getNom()) .append("cognom", c.getCognom()) .append("date_birthday", c.getDate_birthday().toStrinng()) .append("mobil", c.getMobil()) .append("email", c.getEmail()) .append("avatar", c.getAvatar()) .append("user", c.getUser()) .append("pass", c.getPass()) .append("pass", c.getPass()) .append("status", c.getstatus()) .append("f_alta", c.getF_alta().toStrinng()) .append("compra$", c.getCompra$()) .append("premium", c.isPremium()) .append("client_type", c.getClient_type()) .append("benefits", c.getbenefits()) .append("age", c.getAge()) .append("antiguedad", c.getAntiguedad()) ); */ //Busca el/los registro/s con el nombre indicado BasicDBObject searchById = new BasicDBObject(); searchById.append("dni", c.getDni()); //Realiza la actualizacin Singleton_App.collection.updateMulti(searchById, update); }
From source file:app.modules.users.client.model.DAO.DAO_Mongo.java
/** * Selecciona un cliente por el DNI y modifica sus campos * @param dni /*from www.j a v a2 s . com*/ */ public static void update_client(String dni) { fecha aux = new fecha(); //Prepara para insertar un nuevo campo BasicDBObject updateDni = new BasicDBObject(), updateName = new BasicDBObject(), updateSurname = new BasicDBObject(), updateMobile = new BasicDBObject(), updateEmail = new BasicDBObject(), updateDate_birthday = new BasicDBObject(), updateName_user = new BasicDBObject(), updatePasswd = new BasicDBObject(), updateAvatar = new BasicDBObject(), updateState = new BasicDBObject(), updateUp_date = new BasicDBObject(), updateShopping = new BasicDBObject(), updatePremium = new BasicDBObject(), updateClient_type = new BasicDBObject(); updateDni.append("$set", new BasicDBObject().append("dni", clientnew_view.adddnic.getText())); updateName.append("$set", new BasicDBObject().append("name", clientnew_view.caddname.getText())); updateSurname.append("$set", new BasicDBObject().append("subname", clientnew_view.caddsurname.getText())); updateMobile.append("$set", new BasicDBObject().append("mobile", clientnew_view.caddmobile.getText())); updateEmail.append("$set", new BasicDBObject().append("email", clientnew_view.caddemail.getText())); updateDate_birthday.append("$set", new BasicDBObject().append("date_birthday", aux.calendartostring(clientnew_view.cadddatebirthday.getCalendar(), 0))); updateName_user.append("$set", new BasicDBObject().append("user", clientnew_view.caddnameuser.getText())); updatePasswd.append("$set", new BasicDBObject().append("pass", clientnew_view.caddpassword.getText())); updateAvatar.append("$set", new BasicDBObject().append("avatar", clientnew_view.caddavatar.getText())); updateState.append("$set", new BasicDBObject().append("state", clientnew_view.cadd_status.getSelectedItem().toString())); updateUp_date.append("$set", new BasicDBObject().append("up_date", aux.calendartostring(clientnew_view.caddreg.getCalendar(), 0))); updateShopping.append("$set", new BasicDBObject().append("shopping", Float.parseFloat(clientnew_view.caddshopping.getText()))); updatePremium.append("$set", new BasicDBObject().append("premium", clientnew_view.caddpremium.getSelectedItem().toString())); updateClient_type.append("$set", new BasicDBObject().append("client_type", clientnew_view.caddtype.getText())); //Busca el/los registro/s con el nombre indicado BasicDBObject searchById = new BasicDBObject(); searchById.append("dni", dni); //Realiza la actualizacin singleton_global.collection.updateMulti(searchById, updateDni); singleton_global.collection.updateMulti(searchById, updateName); singleton_global.collection.updateMulti(searchById, updateSurname); singleton_global.collection.updateMulti(searchById, updateMobile); singleton_global.collection.updateMulti(searchById, updateEmail); singleton_global.collection.updateMulti(searchById, updateDate_birthday); singleton_global.collection.updateMulti(searchById, updateName_user); singleton_global.collection.updateMulti(searchById, updatePasswd); singleton_global.collection.updateMulti(searchById, updateAvatar); singleton_global.collection.updateMulti(searchById, updateState); singleton_global.collection.updateMulti(searchById, updateUp_date); singleton_global.collection.updateMulti(searchById, updateShopping); singleton_global.collection.updateMulti(searchById, updatePremium); singleton_global.collection.updateMulti(searchById, updateClient_type); }
From source file:applango.common.services.DB.mongo.mongoDB.java
public static DBObject getRollupValue(DBCollection coll, String userId) { logger.info("Getting today's rollup record for user " + userId); DBCursor cursor;/*from w w w. j a va 2s .c o m*/ int maxWait = 10; try { DateTime jsonToday = new DateTime(); DateTime yesterday = new DateTime().minusDays(1); Date yesterdayDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse(yesterday.toString()); BasicDBObject dateQueryObj = new BasicDBObject("beginDate", new BasicDBObject("$gt", yesterdayDate)); dateQueryObj.append("userId", userId); dateQueryObj.append("customerId", "automationCustomer"); dateQueryObj.append("appName", "salesforce"); cursor = coll.find(dateQueryObj); while ((cursor.count() == 0) && maxWait > 0) { sleep(1000); maxWait--; } } catch (Exception ex) { cursor = null; logger.error(ex.getMessage()); } return cursor.next(); }
From source file:application.modules.client.model.DAO.daoC.java
public static void update_worker(String dni) { //Prepara para insertar un nuevo campo BasicDBObject updateDni = new BasicDBObject(), updateName = new BasicDBObject(), updateSurname = new BasicDBObject(), updatePhone = new BasicDBObject(), updateEmail = new BasicDBObject(), updateUser = new BasicDBObject(), updatePass = new BasicDBObject(), updateAvatar = new BasicDBObject(), updateState = new BasicDBObject(), updateDate_birthday = new BasicDBObject(), updateClient_type = new BasicDBObject(), updatePremium = new BasicDBObject(), updateDischarge_date = new BasicDBObject(); updateDni.append("$set", new BasicDBObject().append("dni", new_client_view.dniField.getText())); updateName.append("$set", new BasicDBObject().append("name", new_client_view.nameField.getText())); updateSurname.append("$set", new BasicDBObject().append("subname", new_client_view.subnameField.getText())); updatePhone.append("$set", new BasicDBObject().append("phone_number", new_client_view.phoneField.getText())); updateEmail.append("$set", new BasicDBObject().append("email", new_client_view.emailField.getText())); updateUser.append("$set", new BasicDBObject().append("user", new_client_view.usernameField.getText())); updatePass.append("$set", new BasicDBObject().append("pass", new_client_view.passwordField.getText())); updateAvatar.append("$set", new BasicDBObject().append("avatar", new_client_view.avatarField.getText())); updateState.append("$set", new BasicDBObject().append("state", new_client_view.statusField.getText())); updateClient_type.append("$set", new BasicDBObject().append("client_type", new_client_view.client_typeField.getText())); Dates d = new Dates(""); updateDate_birthday.append("$set", new BasicDBObject().append("date_birthday", d.DateToString(new_client_view.datebirthdayField.getCalendar(), 0))); updateDischarge_date.append("discharge_date", d.DateToString(new_client_view.dischargedateField.getCalendar(), 0)); updatePremium.append("$set", new BasicDBObject().append("premium", new_client_view.premiumCheckbox.isSelected())); //Busca el/los registro/s con el nombre indicado BasicDBObject searchById = new BasicDBObject(); searchById.append("dni", dni); //Realiza la actualizacin SingletonF.collection.updateMulti(searchById, updateDni); SingletonF.collection.updateMulti(searchById, updateName); SingletonF.collection.updateMulti(searchById, updateSurname); SingletonF.collection.updateMulti(searchById, updatePhone); SingletonF.collection.updateMulti(searchById, updateEmail); SingletonF.collection.updateMulti(searchById, updateUser); SingletonF.collection.updateMulti(searchById, updatePass); SingletonF.collection.updateMulti(searchById, updateAvatar); SingletonF.collection.updateMulti(searchById, updateState); SingletonF.collection.updateMulti(searchById, updateDate_birthday); SingletonF.collection.updateMulti(searchById, updateClient_type); SingletonF.collection.updateMulti(searchById, updatePremium); }
From source file:at.ac.tuwien.dsg.smartcom.services.dao.MongoDBMessageInfoDAO.java
License:Apache License
BasicDBObject serializeMessageInfo(MessageInformation mi) { BasicDBObject doc = new BasicDBObject(); doc.append("_id", serializeKey(mi.getKey())); doc.append("purpose", mi.getPurpose()); doc.append("validAnswer", mi.getValidAnswer()); BasicDBList types = new BasicDBList(); for (MessageInformation.Key key : mi.getValidAnswerTypes()) { types.add(serializeKey(key));//from w ww. j ava 2 s . c o m } doc.append("validAnswerTypes", types); BasicDBList rel = new BasicDBList(); for (MessageInformation.Key key : mi.getRelatedMessages()) { rel.add(serializeKey(key)); } doc.append("relatedMessages", rel); log.trace("Saving message info in mongoDB: {}", doc); return doc; }
From source file:at.oneminutedistraction.mongodbrealm.UserCollection.java
private BasicDBObject create(String username, String password) { BasicDBObject user = new BasicDBObject(); user.append(ATTR_USERNAME, username).append(ATTR_PASSWORD, passwordMgr.encrypt(password)); return (user); }