List of usage examples for com.mongodb DBObject put
Object put(String key, Object v);
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
@Override public void deleteTableValues(long tableId) { try {//from w w w . j a va2 s . co m ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(tableId); DBCollection dbCollection = MongoDBUtil.getCollection(expandoTable); DBObject valueDBObject = new BasicDBObject(); List<ExpandoColumn> expandoColumns = ExpandoColumnLocalServiceUtil.getColumns(tableId); for (ExpandoColumn expandoColumn : expandoColumns) { valueDBObject.put(expandoColumn.getName(), null); } DBObject operatorDBObject = new BasicDBObject(MongoOperator.SET, valueDBObject); dbCollection.update(new BasicDBObject(), operatorDBObject, false, true); } catch (PortalException pe) { throw new SystemException(pe); } }
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
@Override public void deleteValue(long companyId, long classNameId, String tableName, String columnName, long classPK) throws PortalException { ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId, tableName); DBCollection dbCollection = MongoDBUtil.getCollection(expandoTable); DBObject queryDBObject = new BasicDBObject(); queryDBObject.put("companyId", expandoTable.getCompanyId()); queryDBObject.put("tableId", expandoTable.getTableId()); queryDBObject.put("rowId", classPK); queryDBObject.put("classNameId", expandoTable.getClassNameId()); queryDBObject.put("classPK", classPK); DBObject valueDBObject = new BasicDBObject(); valueDBObject.put(columnName, null); DBObject operatorDBObject = new BasicDBObject(MongoOperator.SET, valueDBObject); dbCollection.update(queryDBObject, operatorDBObject); }
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
@Override public void deleteValues(long classNameId, long classPK) { long companyId = CompanyThreadLocal.getCompanyId(); List<ExpandoTable> expandoTables = ExpandoTableLocalServiceUtil.getTables(companyId, classNameId); for (ExpandoTable expandoTable : expandoTables) { DBCollection dbCollection = MongoDBUtil.getCollection(expandoTable); DBObject queryDBObject = new BasicDBObject(); queryDBObject.put("companyId", expandoTable.getCompanyId()); queryDBObject.put("tableId", expandoTable.getTableId()); queryDBObject.put("rowId", classPK); queryDBObject.put("classNameId", expandoTable.getClassNameId()); queryDBObject.put("classPK", classPK); dbCollection.remove(queryDBObject); }//from w w w .j av a 2 s .c o m }
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
@Override public List<ExpandoValue> getColumnValues(long companyId, long classNameId, String tableName, String columnName, String data, int start, int end) { try {/* w w w . j a va2 s. co m*/ ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(companyId, classNameId, tableName, columnName); DBCollection dbCollection = MongoDBUtil.getCollection(companyId, classNameId, tableName); DBCursor dbCursor = null; if (Validator.isNotNull(data)) { DBObject queryDBObject = new BasicDBObject(); ExpandoValue expandoValue = ExpandoValueUtil.create(0); expandoValue.setColumnId(expandoColumn.getColumnId()); expandoValue.setData(data); queryDBObject.put(columnName, getData(expandoColumn, expandoValue)); dbCursor = dbCollection.find(queryDBObject); } else { dbCursor = dbCollection.find(); } if ((start != QueryUtil.ALL_POS) && (end != QueryUtil.ALL_POS)) { dbCursor = dbCursor.skip(start).limit(end - start); } List<ExpandoValue> expandoValues = new ArrayList<ExpandoValue>(); for (DBObject dbObject : dbCursor.toArray()) { BasicDBObject expandoValueDBObject = (BasicDBObject) dbObject; ExpandoValue expandoValue = toExpandoValue(expandoValueDBObject, expandoColumn); expandoValues.add(expandoValue); } return expandoValues; } catch (PortalException pe) { throw new SystemException(pe); } }
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
@Override public int getColumnValuesCount(long companyId, long classNameId, String tableName, String columnName, String data) {/*from www . ja va2s .co m*/ try { ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(companyId, classNameId, tableName, columnName); DBCollection dbCollection = MongoDBUtil.getCollection(companyId, classNameId, tableName); DBCursor dbCursor = null; if (Validator.isNotNull(data)) { DBObject queryDBObject = new BasicDBObject(); ExpandoValue expandoValue = ExpandoValueUtil.create(0); expandoValue.setColumnId(expandoColumn.getColumnId()); expandoValue.setData(data); queryDBObject.put(columnName, getData(expandoColumn, expandoValue)); dbCursor = dbCollection.find(queryDBObject); } else { dbCursor = dbCollection.find(); } return dbCursor.count(); } catch (PortalException pe) { throw new SystemException(pe); } }
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
@Override public ExpandoValue getValue(long companyId, long classNameId, String tableName, String columnName, long classPK) { try {// www . ja v a 2 s .c o m ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId, tableName); ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), columnName); DBCollection dbCollection = MongoDBUtil.getCollection(expandoTable); DBObject queryDBObject = new BasicDBObject(); queryDBObject.put("companyId", expandoTable.getCompanyId()); queryDBObject.put("tableId", expandoTable.getTableId()); queryDBObject.put("rowId", classPK); queryDBObject.put("classNameId", expandoTable.getClassNameId()); queryDBObject.put("classPK", classPK); BasicDBObject expandoValueDBObject = (BasicDBObject) dbCollection.findOne(queryDBObject); if (expandoValueDBObject == null) { return null; } return toExpandoValue(expandoValueDBObject, expandoColumn); } catch (NoSuchColumnException nsce) { return null; } catch (NoSuchTableException nste) { return null; } catch (PortalException pe) { throw new SystemException(pe); } }
From source file:com.liferay.mongodb.hook.service.impl.MongoExpandoValueLocalServiceImpl.java
License:Open Source License
protected void updateExpandoValueDBObject(DBObject expandoValueDBObject, List<ExpandoColumn> expandoColumns, Map<String, String> data, ExpandoValue expandoValue) throws PortalException { for (ExpandoColumn expandoColumn : expandoColumns) { String dataString = data.get(expandoColumn.getName()); if (Validator.isNull(dataString)) { continue; }//ww w.j a v a2 s . c om expandoValue.setColumnId(expandoColumn.getColumnId()); expandoValue.setData(dataString); expandoValueDBObject.put(expandoColumn.getName(), getData(expandoColumn, expandoValue)); } }
From source file:com.linuxbox.enkive.docstore.mongogrid.MongoGridDocStoreService.java
License:Open Source License
void setFileMetaData(GridFSInputFile newFile, Document document, int shardKey) { newFile.setContentType(document.getMimeType()); // store the encoding as meta-data for EncodedDocuments DBObject metaData = newFile.getMetaData(); if (metaData == null) { metaData = new BasicDBObject(); }/*from ww w .j a v a 2 s . co m*/ metaData.put(INDEX_STATUS_KEY, STATUS_UNINDEXED); metaData.put(FILE_EXTENSION_KEY, document.getFileExtension()); metaData.put(BINARY_ENCODING_KEY, document.getBinaryEncoding()); metaData.put(INDEX_SHARD_KEY, shardKey); newFile.setMetaData(metaData); }
From source file:com.linuxbox.enkive.imap.mailbox.mongo.MongoEnkiveImapMailboxMapper.java
License:Open Source License
protected DBObject getMailboxList() { String user = session.getUser().getUserName(); DBObject mailboxQuery = new BasicDBObject(); mailboxQuery.put(MongoEnkiveImapConstants.USER, user); return imapCollection.findOne(mailboxQuery); }
From source file:com.linuxbox.enkive.imap.mailbox.mongo.MongoEnkiveImapMailboxMapper.java
License:Open Source License
protected DBObject buildMailboxQuery(String mailboxPath) { String user = session.getUser().getUserName(); DBObject mailboxQuery = new BasicDBObject(); mailboxQuery.put(MongoEnkiveImapConstants.USER, user); return mailboxQuery; }