List of usage examples for com.mongodb DBCollection toString
@Override
public String toString()
From source file:com.ibm.bluemix.smartveggie.dao.UserDaoImpl.java
@Override public BasicDBObject updateUser(UserDTO userDTO) { BasicDBObject updates = null;/*from w w w .j a v a2 s. c o m*/ try { System.out.println("Updating Users..."); DB db = MongodbConnection.getMongoDB(); DBCollection col = db.getCollection(ICollectionName.COLLECTION_USERS); BasicDBObject query = new BasicDBObject(); query.append("userName", userDTO.getUserName()); System.out.println("Updating Record: " + query); updates = new BasicDBObject(); if ((userDTO.getFirstName() != null) && (userDTO.getFirstName() != "")) updates.append("firstName", userDTO.getFirstName()); if ((userDTO.getLastName() != null) && (userDTO.getLastName() != "")) updates.append("lastName", userDTO.getLastName()); if ((userDTO.getAddressLine1() != null) && (userDTO.getAddressLine1() != "")) updates.append("addressLine1", userDTO.getAddressLine1()); if ((userDTO.getAddressLine2() != null) && (userDTO.getAddressLine2() != "")) updates.append("addressLine2", userDTO.getAddressLine2()); if ((userDTO.getAge() > 0) && (userDTO.getAge() < 100)) updates.append("age", userDTO.getAge()); if ((userDTO.getSex() != null) && (userDTO.getSex() != "")) updates.append("sex", userDTO.getSex()); if ((userDTO.getUserName() != null) && (userDTO.getUserName() != "")) updates.append("userName", userDTO.getUserName()); if ((userDTO.getPassword() != null) && (userDTO.getPassword() != "")) updates.append("password", userDTO.getPassword()); if ((userDTO.getCity() != null) && (userDTO.getCity() != "")) updates.append("city", userDTO.getCity()); if ((userDTO.getPinCode() != null) && (userDTO.getPinCode() != "")) updates.append("pin", userDTO.getPinCode()); if ((userDTO.getUserTypeCode() != null) && (userDTO.getUserTypeCode() != "")) { updates.append("userType", userDTO.getUserTypeCode()); if (userDTO.getUserTypeCode().equalsIgnoreCase("vendor")) { if ((userDTO.getLicenseNo() != null) && (userDTO.getLicenseNo() != "")) { updates.append("licenseNo", userDTO.getLicenseNo()); //Process the date field SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy"); String validFrom = userDTO.getValidFrom(); String validTo = userDTO.getValidTo(); try { Date validFromDate = formatter.parse(validFrom); Date validToDate = formatter.parse(validTo); System.out.println(validFromDate); updates.append("validFrom", validFromDate); updates.append("validTo", validToDate); //System.out.println(formatter.format(validFromDate)); } catch (Exception e) { e.printStackTrace(); } } } else if (userDTO.getUserTypeCode().equalsIgnoreCase("regulator")) { if (userDTO.getRegulatingCityCode() != null && userDTO.getRegulatingCityCode() != null) { updates.append("regulatingCityCode", userDTO.getRegulatingCityCode()); } if (userDTO.getRegulatingCityCode() != null && userDTO.getRegulatingCityCode() != null) { updates.append("regulatingCityName", userDTO.getRegulatingCityName()); } } } System.out.println("Querying for update: " + query); col.update(query, updates); System.out.println("col after update" + col.toString() + col.getCount()); } catch (Exception e) { throw e; } return updates; }
From source file:com.qbao.cat.plugin.db.nosql.OldMongoPluginTemplate.java
License:Apache License
protected Transaction beginLog(ProceedingJoinPoint pjp) { Transaction transaction = null;/*from w ww . ja v a 2 s . c o m*/ transaction = newTransaction("MongoDB", String.valueOf(pjp.getSignature().toShortString())); DBCollection collector = (DBCollection) pjp.getTarget(); Cat.logEvent("Host", collector.getDB().getMongo().getServerAddressList().toString()); Cat.logEvent("Connection", collector.toString()); Cat.logEvent("DB", collector.getDB().getName()); Cat.logEvent("Method", pjp.getSignature().toString()); return transaction; }