本文整理汇总了Java中org.jongo.MongoCursor.next方法的典型用法代码示例。如果您正苦于以下问题:Java MongoCursor.next方法的具体用法?Java MongoCursor.next怎么用?Java MongoCursor.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jongo.MongoCursor
的用法示例。
在下文中一共展示了MongoCursor.next方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Override
public void process() {
Map<String, StatusChangedProcessorConfigDTO> jobs = getJobs();
MongoCollection collection = mongoDBService.getCollection(Constants.DB.BUILDS);
for (Map.Entry<String, StatusChangedProcessorConfigDTO> entry : jobs.entrySet()) {
String toSendQuery = "{jobId:'" + entry.getKey() + "', processed:'false'}";
try {
MongoCursor<CiReport> ciReports = collection.find(toSendQuery).as(CiReport.class);
int count = ciReports.count();
CiReport firstReport = null;
for (int i = 0; i < count - 1; i++) {
CiReport report = ciReports.next();
if (firstReport == null) {
firstReport = report;
}
report.setProcessed(true);
collection.update("{id:'" + report.getId() + "'}", report);
}
if (ciReports.hasNext()) {
CiReport lastReport = ciReports.next();
CiReport.Status firstStatus = firstReport.getStatus();
generateMessage(entry.getKey(), entry.getValue(), firstStatus, lastReport);
}
ciReports.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例2: markReportsAsProcessed
import org.jongo.MongoCursor; //导入方法依赖的package包/类
private void markReportsAsProcessed(MongoCollection builds, MongoCursor<CiReport> ciReports) {
while (ciReports.hasNext()) {
CiReport report = ciReports.next();
report.setProcessed(true);
builds.update(String.format("{id:'%s'}", report.getId()), report);
}
}
示例3: process
import org.jongo.MongoCursor; //导入方法依赖的package包/类
@Override
public void process() {
if (!disableForDemo) {
// if (lastRun == null) {
// lastRun = LocalDate.now();
// } else {
// if (Duration.between(lastRun, LocalDate.now()).toDays() == 0) {
// return;
// }
// }
}
Map<String, DailyReportProcessorConfigDTO> jobs = getJobs();
MongoCollection collection = mongoDBService.getCollection(Constants.DB.BUILDS);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -1);
long timeInMills = calendar.getTimeInMillis();
for (Map.Entry<String, DailyReportProcessorConfigDTO> entry : jobs.entrySet()) {
String query = String.format("{ $and : [" + " {jobId : '%s'}, " + " {startTime : {$gt: %d}}, "
+ " {processed:false}" + "]}", entry.getKey(), timeInMills);
DailyStatistic statistic = new DailyStatistic();
try {
MongoCursor<CiReport> dailyReports = collection.find(query).as(CiReport.class);
if (dailyReports.count() > 0) {
while (dailyReports.hasNext()) {
CiReport report = dailyReports.next();
statistic.putReportToStatistic(report);
}
if (statistic.isNotEmpty()) {
generateReport(entry.getKey(), statistic);
}
dailyReports.close();
collection.update(query).with("{processed:true}");
}
} catch (IOException ex) {
LOGGER.error("Fail to close db cursor", ex);
}
}
}