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


Java MongoCursor类代码示例

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


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


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