本文整理汇总了Java中com.mongodb.BasicDBList.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBList.addAll方法的具体用法?Java BasicDBList.addAll怎么用?Java BasicDBList.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.BasicDBList
的用法示例。
在下文中一共展示了BasicDBList.addAll方法的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);
}
}
示例2: getSearchResults
import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@GET
@Path("/{product}/{major}.{minor}.{servicePack}/{build}")
@Produces("application/json")
public BasicDBList getSearchResults(@BeanParam final Coordinates coordinates, @QueryParam("keywords") final String keyword) {
final String[] searchCategories = { "name", "description", "tags.name", "elements.name", "elements.description",
"elements.steps.name", "elements.tags.name" };
final List<String> searchWords = Arrays.asList(keyword.split("\\s+"));
final DB db = this.client.getDB("bdd");
final DBCollection collection = db.getCollection("features");
final List<DBObject> searchResults = new ArrayList<DBObject>();
final QueryBuilder queryBuilder = QueryBuilder.getInstance();
final DBCursor results = collection.find(queryBuilder.getSearchQuery(searchWords, coordinates, searchCategories));
while (results.hasNext()) {
final DBObject doc = results.next();
searchResults.add(doc);
}
Collections.sort(searchResults, new DBObjectComparator(searchWords));
while (searchResults.size() > SEARCH_LIMIT) {
searchResults.remove(searchResults.size() - 1);
}
final BasicDBList basicDBList = new BasicDBList();
basicDBList.addAll(searchResults);
return basicDBList;
}
示例3: putReport
import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@PUT
@Path("/{product}/{major}.{minor}.{servicePack}/{build}")
public DBObject putReport(@BeanParam final Coordinates coordinates, final DBObject root) throws IOException {
final BasicDBList doc = (BasicDBList) root;
final DB grid = this.client.getDB("grid");
final GridFS gridFS = new GridFS(grid);
final DB bdd = this.client.getDB("bdd");
final DBCollection features = bdd.getCollection("features");
updateSummaryDocument(bdd, coordinates);
for (int i = 0; i < doc.size(); i++) {
// take each feature and give it a unique id.
final BasicDBObject feature = (BasicDBObject) doc.get(i);
final String _id = coordinates.getFeature_Id((String) feature.get("id"));
feature.put("_id", _id);
embedSteps(feature, gridFS, coordinates); // extract embedded content and hyperlink to it.
packBackgroundsInToScenarios(feature); // nest background elements within their scenarios
final BasicDBObject featureCo = coordinates.getReportCoordinates();
feature.put("coordinates", featureCo);
final BasicDBList newElements = mergeExistingScenarios(features, feature, _id);
feature.put("elements", newElements);
final String originalStatus = StatusHelper.getFeatureStatus(feature);
feature.put("calculatedStatus", originalStatus);
feature.put("originalAutomatedStatus", originalStatus);
this.log.info("Saving: " + feature.get("name") + " - " + feature.get("calculatedStatus"));
this.log.trace("Adding feature:" + feature.toJson());
features.save(feature);
}
final DBCursor cursor = features.find(coordinates.getReportCoordinatesQueryObject()); // get new co-ordinates to exclude the "version"
// field
final List<DBObject> returns = new ArrayList<DBObject>();
try {
while (cursor.hasNext()) {
returns.add(cursor.next());
}
} finally {
cursor.close();
}
final BasicDBList list = new BasicDBList();
list.addAll(returns);
updateStatsDocument(bdd, coordinates, list);
return list;
}