List of usage examples for com.mongodb DBObject put
Object put(String key, Object v);
From source file:com.eywa.impl.app.mongo.services.ProductService.java
License:Open Source License
public DBObject getByUid(final String parentId, final String uid) { final DBObject query = new BasicDBObject(); query.put(Product.PARENT_ID, parentId); query.put(Product.UID, uid);/* w w w . j av a 2 s . co m*/ return super.findOne(query); }
From source file:com.eywa.impl.app.mongo.services.ProductService.java
License:Open Source License
public List<DBObject> list(final String userId, final String hubId, final String parentId) { final DBObject user = UserService.getEnabled(userId); if (null != user) { final DBObject query = new BasicDBObject(Product.HUB_ID, hubId); query.put(File.PARENT_ID, parentId); return super.find(query, null, 0, 0, new String[] { Product.TYPE, Product.UID }, null); }//from ww w . j a v a2 s.co m return new ArrayList<DBObject>(); }
From source file:com.eywa.impl.app.mongo.services.ProductService.java
License:Open Source License
public List<DBObject> list(final String userId, final String parentId, final boolean includeFolders) { final List<DBObject> result = new LinkedList<>(); final DBObject query = new BasicDBObject(); query.put(Product.USER_ID, userId); if (StringUtils.hasText(parentId)) { query.put(Product.PARENT_ID, parentId); }//from w w w .j a v a 2 s. c o m final List<DBObject> list = super.find(query); for (final DBObject item : list) { if (Product.isDirectory(item) && !includeFolders) { result.addAll(this.list(userId, Product.getId(item), false)); } else { result.add(item); } } return result; }
From source file:com.eywa.impl.app.mongo.services.ProductService.java
License:Open Source License
public MongoPage lookup(final String hubId, final int skip, final int limit, final Collection<String> keywords) { final DBObject query = new BasicDBObject(); query.put(Product.HUB_ID, hubId); MongoUtils.queryIn(query, Product.KEYWORDS, keywords.toArray(new String[keywords.size()])); final String[] fieldNames = null; final String[] sortAsc = new String[] { Product.UID }; final String[] sortDes = new String[] {}; return super.paged(query, fieldNames, skip, limit, sortAsc, sortDes); }
From source file:com.eywa.impl.app.mongo.services.ProductService.java
License:Open Source License
public MongoPage lookup(final String hubId, final int skip, final int limit, final String searchText) { DBObject query1 = null;//from ww w .j a va2s . com DBObject query2 = null; if (!StringUtils.isNULL(hubId)) { // lookup in current hub query1 = new BasicDBObject(); MongoUtils.queryEquals(query1, Product.HUB_ID, hubId, MongoUtils.CASE_INSENSITIVE); } if (!StringUtils.isNULL(searchText)) { if (searchText.startsWith("#")) { query2 = new BasicDBObject(); query2.put(Product.KEYWORDS, searchText.substring(1)); } else { query2 = new BasicDBObject(); final BasicDBList conditions = new BasicDBList(); conditions.add(MongoUtils.queryEquals(Product.ID, searchText, MongoUtils.CASE_INSENSITIVE)); conditions.add(MongoUtils.queryContains(Product.UID, searchText, MongoUtils.CASE_INSENSITIVE)); conditions.add(MongoUtils.queryEquals(Product.KEYWORDS, searchText, MongoUtils.CASE_INSENSITIVE)); query2.put(MongoUtils.OP_OR, conditions); } } DBObject query = null; if (null != query1 && null != query2) { query = new BasicDBObject(); final BasicDBList conditions = new BasicDBList(); conditions.add(query1); conditions.add(query2); query.put(MongoUtils.OP_AND, conditions); } else if (null == query2) { query = query1; } else { query = query2; } final String[] fieldNames = null; final String[] sortAsc = new String[] { File.NAME }; final String[] sortDes = new String[] {}; return super.paged(query, fieldNames, skip, limit, sortAsc, sortDes); }
From source file:com.eywa.impl.app.mongo.services.ProductService.java
License:Open Source License
public static String getFileId(final String id) { try {/*w ww .ja v a2 s . c o m*/ final ProductService srvc = new ProductService(); final DBObject query = new BasicDBObject(); query.put(Product.ID, id); final DBObject product = srvc.findOne(query, new String[] { Product.FILE_ID }); return Product.getFileId(product); } catch (Throwable ignored) { } return ""; }
From source file:com.eywa.impl.app.mongo.services.ProductTemplateListService.java
License:Open Source License
private DBObject getByProductId(final String productId) { final DBObject query = new BasicDBObject(); query.put(ProductTemplateList.PRODUCT_ID, productId); return super.findOne(query); }
From source file:com.eywa.impl.app.mongo.services.ProductTemplateListService.java
License:Open Source License
public static List<DBObject> getList(final String lang, final String uid) { try {//from ww w .j ava 2 s . com final ProductTemplateListService srvc = new ProductTemplateListService(); final List<DBObject> result; if (StringUtils.hasText(uid)) { final BasicDBList or = new BasicDBList(); or.add(new BasicDBObject(ProductTemplateList.UID, uid)); or.add(new BasicDBObject(ProductTemplateList.UID, '*')); final DBObject query = new BasicDBObject(); query.put(MongoUtils.OP_OR, or); result = srvc.find(query); } else { result = srvc.find(); } srvc.localize(result, lang); return result; } catch (Throwable ignored) { } return null; }
From source file:com.eywa.impl.app.mongo.services.ProductTransactionService.java
License:Open Source License
public static List<DBObject> getBySeller(final String sellerId) { try {/*from ww w.j a v a2s.co m*/ final ProductTransactionService srvc = new ProductTransactionService(); final DBObject query = new BasicDBObject(); query.put(ProductTransaction.SELLER_ID, sellerId); return srvc.find(query); } catch (Throwable ignored) { } return null; }
From source file:com.eywa.impl.app.mongo.services.ProductTransactionService.java
License:Open Source License
public static List<DBObject> getByBuyer(final String buyerId) { try {//w w w. j a va 2 s . com final ProductTransactionService srvc = new ProductTransactionService(); final DBObject query = new BasicDBObject(); query.put(ProductTransaction.BUYER_ID, buyerId); return srvc.find(query); } catch (Throwable ignored) { } return null; }