当前位置: 首页>>代码示例>>Java>>正文


Java MongoCursor.next方法代码示例

本文整理汇总了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();
        }

    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:33,代码来源:StatusChangedProcessor.java

示例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);
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:8,代码来源:StatusWatchdogProcessor.java

示例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);
        }
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:43,代码来源:DailyReportProcessor.java


注:本文中的org.jongo.MongoCursor.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。