• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MongoCursor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jongo.MongoCursor的典型用法代码示例。如果您正苦于以下问题:Java MongoCursor类的具体用法?Java MongoCursor怎么用?Java MongoCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MongoCursor类属于org.jongo包,在下文中一共展示了MongoCursor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: removedItems

import org.jongo.MongoCursor; //导入依赖的package包/类
public List<Document> removedItems(String collection, long fromSequence, long newSequence) {
    List<Document> documentList = new ArrayList<>();
    MongoCollection userCollection = jongo.getCollection(collection);

    MongoCursor<NitriteDocument> removeLogs = userCollection
        .find("{" +
            " $and: [" +
            " {" + DELETED + ": { $eq: true }}," +
            " {" + DELETE_TIME + ": { $gte: # }}," +
            " {" + DELETE_TIME + ": { $lte: # }}" +
            " ]}", fromSequence, newSequence)
        .as(NitriteDocument.class);

    if (removeLogs != null) {
        for (NitriteDocument logEntry : removeLogs) {
            Document document = new Document(logEntry.getDocument());
            document.remove(DOC_SOURCE);
            documentList.add(document);
        }
    }

    return documentList;
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:24,代码来源:ReplicaStoreService.java


示例2: modifiedItems

import org.jongo.MongoCursor; //导入依赖的package包/类
public List<Document> modifiedItems(String collection, long fromSequence, long newSequence) {
    MongoCollection userCollection = jongo.getCollection(collection);
    MongoCursor<NitriteDocument> documents = userCollection
        .find("{" +
            " $and: [" +
            " {" + DELETED + ": { $eq: false }}," +
            " {" + SYNC_TIME + ": { $gte: # }}," +
            " {" + SYNC_TIME + ": { $lte: # }}" +
            " ]}", fromSequence, newSequence)
        .as(NitriteDocument.class);

    List<Document> result = new ArrayList<>();
    for (NitriteDocument nitriteDocument : documents) {
        Document doc = new Document(nitriteDocument.getDocument());
        doc.remove(DOC_SOURCE);
        result.add(doc);
    }

    return result;
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:21,代码来源:ReplicaStoreService.java


示例3: getModerationLogs

import org.jongo.MongoCursor; //导入依赖的package包/类
public static Optional<List<ModerationLog>> getModerationLogs(CurseGUID channelId) {
    try {
        List<ModerationLog> commandRet = new ArrayList<>();
        MongoCursor<ModerationLog> commands = jongo.getCollection(MONGO_MODERATION_LOGGING_COLLECTION).find("{channelID: '" + channelId.serialize() + "'}")
                .as(ModerationLog.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting moderation data", e);
        return Optional.empty();
    }

}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:17,代码来源:MongoConnection.java


示例4: getMessageLog

import org.jongo.MongoCursor; //导入依赖的package包/类
public static Optional<List<ModerationLog>> getMessageLog(CurseGUID channelId, Date eventTime) {
    try {
        List<ModerationLog> commandRet = new ArrayList<>();
        MongoCursor<ModerationLog> commands = jongo.getCollection(MONGO_MODERATION_LOGGING_COLLECTION)
                .find("{channelID: '" + channelId.serialize() + "' , messageTime: 'ISODate(" + eventTime.toString() + ")'}")
                .as(ModerationLog.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting moderation data", e);
        return Optional.empty();
    }
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:17,代码来源:MongoConnection.java


示例5: getCurseChecksForAuthor

import org.jongo.MongoCursor; //导入依赖的package包/类
public static Optional<List<MongoCurseforgeCheck>> getCurseChecksForAuthor(@Nonnull String author) {
    try {
        List<MongoCurseforgeCheck> commandRet = new ArrayList<>();
        MongoCursor<MongoCurseforgeCheck> commands = jongo.getCollection(MONGO_COMMANDS_COLLECTION).find("{author: '" + author + "'}")
                .as(MongoCurseforgeCheck.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting checks", e);
        return Optional.empty();
    }

}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:17,代码来源:MongoConnection.java


示例6: getCommandsForServer

import org.jongo.MongoCursor; //导入依赖的package包/类
@Nonnull
//TODO should this use streams?
public static Optional<List<MongoCommand>> getCommandsForServer(CurseGUID serverID) {
    try {
        List<MongoCommand> commandRet = new ArrayList<>();
        MongoCursor<MongoCommand> commands = jongo.getCollection(MONGO_COMMANDS_COLLECTION).find("{serverID: '" + serverID.serialize() + "'}")
                .as(MongoCommand.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting commands for server", e);
        return Optional.empty();
    }
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:18,代码来源:MongoConnection.java


示例7: send

import org.jongo.MongoCursor; //导入依赖的package包/类
@Override
public void send() {
    Map<String, T> jobs = getJobs();
    MongoCollection collection = mongoDBService.getCollection(Constants.DB.TO_SEND);
    for (Map.Entry<String, T> entry : jobs.entrySet()) {
        String toSendQuery = "{jobId:'" + entry.getKey() + "'}";
        try {
            MongoCursor<ToSend> messageCursor = collection.find(toSendQuery).as(ToSend.class);
            for (ToSend message : messageCursor) {
                send(entry.getValue(), message);
            }
            collection.remove(toSendQuery);
            messageCursor.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

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


示例8: getPluginConfigs

import org.jongo.MongoCursor; //导入依赖的package包/类
/**
 * @return active configs set for selected plugin
 */
protected Set<T> getPluginConfigs() {
    HashSet<T> configsByType = Sets.newHashSet();
    MongoCollection collection = mongoDBService.getCollection(getConfigTableName());
    try {
        MongoCursor<? extends ConfigDTO> mongoCursor = collection.find("{type:'" + configTemplate.getType() + "'}")
                .as(configTemplate.getClass());

        for (ConfigDTO configDTO : mongoCursor) {
            configsByType.add((T) configDTO);
        }
        mongoCursor.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return configsByType;
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:20,代码来源:AbstractPlugin.java


示例9: process

import org.jongo.MongoCursor; //导入依赖的package包/类
@Override
public void process() {
    MongoCollection builds = mongoDBService.getCollection(Constants.DB.BUILDS);
    for (Map.Entry<String, WatchdogProcessorConfigDTO> entry : getJobs().entrySet()) {
        long boundTime = System.currentTimeMillis() - Integer.parseInt(entry.getValue().getTimeout()) * 60000;
        String queryToSend = String.format("{jobId:'%s', processed:'false', startTime:{$lt: '%s'}, status: '%s'}",
                entry.getKey(), boundTime, CiReport.Status.IN_PROGRESS);
        try {
            MongoCursor<CiReport> ciReports = builds.find(queryToSend).as(CiReport.class);
            if (ciReports.count() > 0) {
                putMessage(entry.getKey(), SUBJECT, BODY);
            }
            markReportsAsProcessed(builds, ciReports);
            ciReports.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:20,代码来源:StatusWatchdogProcessor.java


示例10: findAll

import org.jongo.MongoCursor; //导入依赖的package包/类
public List<Document> findAll(String collection, FindOptions findOptions) {
    MongoCollection mongoCollection = jongo.getCollection(collection);
    MongoCursor<NitriteDocument> documents = mongoCollection
        .find("{" + DELETED + ": { $eq: false }}")
        .skip(findOptions.getOffset())
        .limit(findOptions.getSize())
        .as(NitriteDocument.class);

    return StreamSupport.stream(documents.spliterator(), false)
        .map(NitriteDocument::getDocument)
        .collect(Collectors.toList());
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:13,代码来源:ReplicaStoreService.java


示例11: getDocumentCount

import org.jongo.MongoCursor; //导入依赖的package包/类
public long getDocumentCount() {
    long sum = 0;
    Set<String> collectionNames = new HashSet<>();
    MongoCursor<Attributes> cursor = jongo.getCollection(ATTRIBUTE_REPO).find().as(Attributes.class);
    for (Attributes attributes : cursor) {
        collectionNames.add(attributes.getCollection());
    }

    for (String name : collectionNames) {
        sum = sum + jongo.getCollection(name).count();
    }
    return sum;
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:14,代码来源:AnalyticsService.java


示例12: findUsersByAuthorities

import org.jongo.MongoCursor; //导入依赖的package包/类
public List<UserAccount> findUsersByAuthorities(String... authorities) {
    MongoCursor<UserAccount> userAccounts = userRepository.find("{authorities: { $in: [#]}}",
        String.join(",", authorities))
        .as(UserAccount.class);
    return StreamSupport
        .stream(userAccounts.spliterator(), false)
        .collect(Collectors.toList());
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:9,代码来源:UserAccountService.java


示例13: cursorToArray

import org.jongo.MongoCursor; //导入依赖的package包/类
/**
 * Takes a MongoCurson containing User object and moving them to an ArrayList.
 *
 * @param cursor    MongoCursor to be conveted to an ArrayList
 * @return          An ArrayList containing all user object from the cursor
 */
private ArrayList<User> cursorToArray(MongoCursor<User> cursor) {
    ArrayList<User> list = new ArrayList<>();

    while(cursor.hasNext()) {
        list.add(cursor.next());
    }

    return list;
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:16,代码来源:UserDAOMongo.java


示例14: cursorToArray

import org.jongo.MongoCursor; //导入依赖的package包/类
/**
 * Takes a MongoCursor containing Event objects and moves them to an ArrayList.
 *
 * @param cursor    MongoCursor to be converted to an ArrayList.
 * @return          An ArrayList containing all Event objects from the cursor.
 * @author Axel Nilsson (axnion)
 */
private static List<Event> cursorToArray(MongoCursor<Event> cursor) {
    List<Event> list = new ArrayList<>();

    while(cursor.hasNext()) {
        list.add(cursor.next());
    }

    return list;
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:17,代码来源:EventDAOMongo.java


示例15: getCurseChecks

import org.jongo.MongoCursor; //导入依赖的package包/类
public static Optional<List<MongoCurseforgeCheck>> getCurseChecks() {
    try {
        List<MongoCurseforgeCheck> commandRet = new ArrayList<>();
        MongoCursor<MongoCurseforgeCheck> commands = jongo.getCollection(MONGO_CURSECHECKS_COLLECTION).find()
                .as(MongoCurseforgeCheck.class);
        while (commands.hasNext()) {
            commandRet.add(commands.next());
        }
        commands.close();
        return Optional.of(commandRet);
    } catch (IOException | NullPointerException e) {
        log.error("error getting checks", e);
        return Optional.empty();
    }
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:16,代码来源:MongoConnection.java


示例16: loadWinlist

import org.jongo.MongoCursor; //导入依赖的package包/类
@Override
public List<WinlistItem> loadWinlist(GameModeId mode) {
    long timestamp = System.currentTimeMillis() - MONTH;

    MongoCursor<WinlistItem> as =
        collection.find("{mode:#, timestamp:{$gte:#}}", mode, timestamp)
            .sort("{score:-1}")
            .limit(20)
            .as(WinlistItem.class);

    return stream(as.spliterator(), false).collect(toList());
}
 
开发者ID:nosceon,项目名称:tenorite,代码行数:13,代码来源:MongoWinlistRepository.java


示例17: 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


示例18: 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


示例19: listByUserID

import org.jongo.MongoCursor; //导入依赖的package包/类
public MongoCursor<T> listByUserID(String userid) {
    return db.getColletion(getCollectionName()).find("{userID: '" + userid + "'").as(clazz);
}
 
开发者ID:alikemalocalan,项目名称:Spark-API,代码行数:4,代码来源:BaseService.java


示例20: findByUserID

import org.jongo.MongoCursor; //导入依赖的package包/类
protected MongoCursor<T> findByUserID(String userid) {
    return db.getColletion(getCollectionName()).find("{userID: '" + userid + "'").as(clazz);
}
 
开发者ID:alikemalocalan,项目名称:Spark-API,代码行数:4,代码来源:BaseService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JXStatusBar类代码示例发布时间:2022-05-22
下一篇:
Java ExpressionFactoryImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap