當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicDBList.clear方法代碼示例

本文整理匯總了Java中com.mongodb.BasicDBList.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicDBList.clear方法的具體用法?Java BasicDBList.clear怎麽用?Java BasicDBList.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mongodb.BasicDBList的用法示例。


在下文中一共展示了BasicDBList.clear方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: packBackgroundsInToScenarios

import com.mongodb.BasicDBList; //導入方法依賴的package包/類
/**
 * go through find all the backgrounds elements and nest them in their scenarios (simplifies application logic downstream)
 */
protected void packBackgroundsInToScenarios(final DBObject feature) {
	final List<DBObject> packedScenarios = new ArrayList<DBObject>();
	// go through all the backgrounds /scenarios
	final BasicDBList elements = (BasicDBList) feature.get("elements");
	if (elements != null) {
		for (int i = 0; i < elements.size(); i++) {
			final DBObject element = (DBObject) elements.get(i);
			if (element.get("type").equals("background")) { // if its a background
				((DBObject) elements.get(i + 1)).put("background", element); // push it in to the next element.
			} else {
				// assume this is a scenario/other top level element and push it to the packed array.
				packedScenarios.add(element);
			}
		}
		elements.clear();
		elements.addAll(packedScenarios);
	}
}
 
開發者ID:orionhealth,項目名稱:XBDD,代碼行數:22,代碼來源:Report.java

示例2: deleteOldestNExpired

import com.mongodb.BasicDBList; //導入方法依賴的package包/類
private int deleteOldestNExpired(String containerId, int size) {
		
		log.debug("deleteOldestNExpired containerId:{}, size:{}", containerId, size);
		MongoCollection<Document> collection = context.getDatabaseManager()
				.getCollection(collectionName);
		BasicDBList and = new BasicDBList();
		DeleteResult result;
		
		if (size >= 0) {
			and.clear();	
			and.add(new BasicDBObject(PARENTID_KEY, containerId));
			and.add(new BasicDBObject(RESTYPE_KEY, RESOURCE_TYPE.CONTENT_INST.Value()));
			
			MongoCursor<Document> cursor = collection.find(new BasicDBObject("$and", and))
											.sort(new BasicDBObject(CREATETIME_KEY, 1))
											.limit(size).iterator();
			
			int deletedCount = 0;
			if (cursor.hasNext()) {
				Document doc = cursor.next();
//				and.clear();
//				and.add(new BasicDBObject(PARENTID_KEY, containerId));
//				and.add(new BasicDBObject(RESTYPE_KEY, RESOURCE_TYPE.CONTENT_INST.Value()));
//				and.add(new BasicDBObject(CREATETIME_KEY, new BasicDBObject("$lt", doc.get(CREATETIME_KEY))));
//				
				result = collection.deleteOne(new BasicDBObject(RESID_KEY, doc.get(RESID_KEY)));
	
				deletedCount += result.getDeletedCount();
			}
			log.debug("Deleted oldest contentInstance:{}", deletedCount);
			return deletedCount;
		}
		return 0;
		
	}
 
開發者ID:iotoasis,項目名稱:SI,代碼行數:36,代碼來源:ContentInstanceAnncDAO.java

示例3: deleteOldestNExpired

import com.mongodb.BasicDBList; //導入方法依賴的package包/類
private int deleteOldestNExpired(String containerId, int size) {
		
		log.debug("deleteOldestNExpired containerId:{}, size:{}", containerId, size);
		MongoCollection<Document> collection = context.getDatabaseManager()
				.getCollection(collectionName);
		BasicDBList and = new BasicDBList();
		DeleteResult result;
		/*
		
		String now = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"));
		
		and.add(new BasicDBObject(EXPIRETIME_KEY, new BasicDBObject("$lt", now)));
		and.add(new BasicDBObject(PARENTID_KEY, containerId));
		
		result = collection.deleteMany(new BasicDBObject("$and", and));
		size -= result.getDeletedCount();
		
		log.debug("Deleted expired contentInstance:{}", result.getDeletedCount());
		*/
		
		if (size >= 0) {
			and.clear();	
			and.add(new BasicDBObject(PARENTID_KEY, containerId));
			and.add(new BasicDBObject(RESTYPE_KEY, RESOURCE_TYPE.CONTENT_INST.Value()));
			
			MongoCursor<Document> cursor = collection.find(new BasicDBObject("$and", and))
											.sort(new BasicDBObject(CREATETIME_KEY, 1))
											.limit(size).iterator();
			
			int deletedCount = 0;
			if (cursor.hasNext()) {
				Document doc = cursor.next();
//				and.clear();
//				and.add(new BasicDBObject(PARENTID_KEY, containerId));
//				and.add(new BasicDBObject(RESTYPE_KEY, RESOURCE_TYPE.CONTENT_INST.Value()));
//				and.add(new BasicDBObject(CREATETIME_KEY, new BasicDBObject("$lt", doc.get(CREATETIME_KEY))));
//				
				result = collection.deleteOne(new BasicDBObject(RESID_KEY, doc.get(RESID_KEY)));
	
				deletedCount += result.getDeletedCount();
			}
			log.debug("Deleted oldest contentInstance:{}", deletedCount);
			return deletedCount;
		}
		return 0;
		
	}
 
開發者ID:iotoasis,項目名稱:SI,代碼行數:48,代碼來源:ContentInstanceDAO.java


注:本文中的com.mongodb.BasicDBList.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。