当前位置: 首页>>代码示例>>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;未经允许,请勿转载。