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

Java DBCursor类代码示例

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

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



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

示例1: fetch

import org.mongojack.DBCursor; //导入依赖的package包/类
@GET
@Path("/list")
public List<Log> fetch(@PathParam("collection") String collection) {

    final DBCursor<Log> cursor = entries.find();
    final List<Log> l = new ArrayList<Log>();

    try {
        while (cursor.hasNext()) {
            l.add(cursor.next());
        }
    } finally {
        cursor.close();
    }

    return l;
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:18,代码来源:LogWriterResource.java


示例2: fetchLatest

import org.mongojack.DBCursor; //导入依赖的package包/类
@GET
@Path("/latest")
public List<Log> fetchLatest(@PathParam("collection") String collection) {

    final DBCursor<Log> cursor = entries.find().sort(new BasicDBObject("timestamp", -1)).limit(100);
    final List<Log> l = new ArrayList<Log>();

    try {
        while (cursor.hasNext()) {
            l.add(cursor.next());
        }
    } finally {
        cursor.close();
    }

    return l;
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:18,代码来源:LogWriterResource.java


示例3: fetch

import org.mongojack.DBCursor; //导入依赖的package包/类
@GET
public List<MongoDocument> fetch(@PathParam("collection") String collection) {
    final JacksonDBCollection<MongoDocument, String> coll = JacksonDBCollection.wrap(mongoDB.getCollection(collection), MongoDocument.class,
            String.class);
    final DBCursor<MongoDocument> cursor = coll.find();
    final List<MongoDocument> l = new ArrayList<>();

    try {
        while(cursor.hasNext()) {
            l.add(cursor.next());
        }
    }finally {
        cursor.close();
    }

    return l;
}
 
开发者ID:eeb,项目名称:dropwizard-mongo,代码行数:18,代码来源:CollectionIdsResource.java


示例4: checkUsername

import org.mongojack.DBCursor; //导入依赖的package包/类
@POST
@Path("/register/check/username")
public Response checkUsername(CheckNameDTO nameDTO) {
    Preconditions.checkNotNull(nameDTO);

    if(CharMatcher.WHITESPACE.matchesAnyOf(nameDTO.getName())) {
        return Response.status(Response.Status.FORBIDDEN).entity("{\"space\":\"true\"}").build();
    }

    //If these doesn't match, then the username is unsafe
    if (!nameDTO.getName().equals(HtmlEscapers.htmlEscaper().escape(nameDTO.getName()))) {
        log.warn("Unsafe username " + nameDTO.getName());
        return Response.status(Response.Status.FORBIDDEN).entity("{\"invalidChars\":\"true\"}").build();
    }

    @Cleanup DBCursor<Player> dbPlayer = playerCollection.find(
            DBQuery.is("username", nameDTO.getName().trim()), new BasicDBObject());

    if (dbPlayer.hasNext()) {
        return Response.status(Response.Status.FORBIDDEN).entity("{\"isTaken\":\"true\"}").build();
    }

    return Response.ok().build();
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:25,代码来源:AuthResource.java


示例5: authenticate

import org.mongojack.DBCursor; //导入依赖的package包/类
@Override
public Optional<Player> authenticate(BasicCredentials credentials) {
    @Cleanup DBCursor<Player> dbPlayer = playerCollection.find(
            DBQuery.is("username", credentials.getUsername()), new BasicDBObject());

    if (dbPlayer == null || !dbPlayer.hasNext()) {
        return Optional.empty();
    }

    Player player = dbPlayer.next();

    CivSingleton.instance().playerCache().put(player.getId(), player.getUsername());

    if (player.getPassword().equals(DigestUtils.sha1Hex(credentials.getPassword()))) {
        return Optional.of(player);
    }
    return Optional.empty();
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:19,代码来源:CivAuthenticator.java


示例6: createPlayer

import org.mongojack.DBCursor; //导入依赖的package包/类
@Test
public void createPlayer() throws JsonProcessingException {
    @Cleanup DBCursor<Player> foobar = getApp().playerCollection.find(DBQuery.is("username", "foobar"));
    if (foobar.hasNext()) {
        getApp().playerCollection.removeById(foobar.next().getId());
    }

    Form form = new Form();
    form.param("username", "foobar");
    form.param("password", "foobar");
    form.param("email", "[email protected]");

    URI uri = UriBuilder.fromPath(BASE_URL + "/auth/register").build();
    Response response = client().target(uri)
            .request()
            .post(Entity.form(form));

    assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED_201);
    assertThat(response.getLocation().getPath()).contains(uri.getPath());
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:21,代码来源:AuthResourceTest.java


示例7: get

import org.mongojack.DBCursor; //导入依赖的package包/类
/**
 * Returns a {@link com.eeb.dropwizardmongo.cms.api.BasicPage} using the slug as a query parameter.
 * @param slug
 * @return {@code BasicPage} object or a 403 if the object can not be found.
 */
@GET
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public BasicPageView get(@PathParam("slug") String slug) {

    JacksonDBCollection<BasicPage,String> col = JacksonDBCollection.wrap(mongoDb.getCollection("assets"),
            BasicPage.class, String.class);

    //Note: MongoJack does not support the AutoClose interface
    DBCursor<BasicPage> cursor = col.find(new BasicDBObject("metadata.slug",slug));
    try  {

        if(!cursor.hasNext()) {
            Response.ResponseBuilder response = Response.status(Response.Status.FORBIDDEN);
            response.entity("{\"message\":\"Object not found\"}");
            throw new WebApplicationException(response.build());
        } else {
            return new BasicPageView(cursor.next());
        }

    } finally {
       cursor.close();
     }

}
 
开发者ID:eeb,项目名称:dropwizard-mongo-cms,代码行数:31,代码来源:BasicPageResource.java


示例8: prefillCache

import org.mongojack.DBCursor; //导入依赖的package包/类
protected void prefillCache() {
    if (LocalCache.PVE_ENABLED) {
        final DBCursor<PveEvent> pveevents = db.findPveEvents();
        pveevents.batchSize(5000);
        for (final PveEvent pveevent : pveevents) {
            pveEventCache.put(pveevent.hashCode(), pveevent);
            esper.sendEvent(pveevent);
        }
        pveevents.close();
    }

    if (LocalCache.WVW_ENABLED) {
        final DBCursor<WvwEvent> wvwevents = db.findWvwEvents();
        wvwevents.batchSize(5000);
        for (final WvwEvent wvwevent : wvwevents) {
            wvwEventCache.put(wvwevent.hashCode(), wvwevent);
            esper.sendEvent(wvwevent);
        }
        wvwevents.close();
    }

}
 
开发者ID:zyclonite,项目名称:gw2live,代码行数:23,代码来源:UpdateTimer.java


示例9: loadAll

import org.mongojack.DBCursor; //导入依赖的package包/类
@Override
public Collection<RuleDao> loadAll() {
    try {
        final DBCursor<RuleDao> ruleDaos = dbCollection.find().sort(DBSort.asc("title"));
        return ruleDaos.toArray();
    } catch (MongoException e) {
        log.error("Unable to load processing rules", e);
        return Collections.emptySet();
    }
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:11,代码来源:MongoDbRuleService.java


示例10: loadNamed

import org.mongojack.DBCursor; //导入依赖的package包/类
@Override
public Collection<RuleDao> loadNamed(Collection<String> ruleNames) {
    try {
        final DBCursor<RuleDao> ruleDaos = dbCollection.find(DBQuery.in("title", ruleNames));
        return Sets.newHashSet(ruleDaos.iterator());
    } catch (MongoException e) {
        log.error("Unable to bulk load rules", e);
        return Collections.emptySet();
    }
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:11,代码来源:MongoDbRuleService.java


示例11: loadAll

import org.mongojack.DBCursor; //导入依赖的package包/类
@Override
public Set<PipelineConnections> loadAll() {
    try {
        final DBCursor<PipelineConnections> connections = dbCollection.find();
        return Sets.newHashSet(connections.iterator());
    } catch (MongoException e) {
        log.error("Unable to load pipeline connections", e);
        return Collections.emptySet();
    }
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:11,代码来源:MongoDbPipelineStreamConnectionsService.java


示例12: loadAll

import org.mongojack.DBCursor; //导入依赖的package包/类
@Override
public Collection<PipelineDao> loadAll() {
    try {
        final DBCursor<PipelineDao> daos = dbCollection.find();
        return Sets.newHashSet(daos.iterator());
    } catch (MongoException e) {
        log.error("Unable to load pipelines", e);
        return Collections.emptySet();
    }
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:11,代码来源:MongoDbPipelineService.java


示例13: findByTags

import org.mongojack.DBCursor; //导入依赖的package包/类
public List<CollectorConfiguration> findByTags(List tags) {
    final DBCursor<CollectorConfiguration> cursor = dbCollection.find().in("tags", tags);
    final List<CollectorConfiguration> result = new ArrayList<>();
    while (cursor.hasNext()) {
        result.add(cursor.next());
    }
    return result;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:9,代码来源:CollectorConfigurationService.java


示例14: loadAllTags

import org.mongojack.DBCursor; //导入依赖的package包/类
public List<String> loadAllTags() {
    List<String> tags = new ArrayList<>();
    DBCursor cursor = dbCollection.find();
    while (cursor.hasNext()) {
        CollectorConfiguration collectorConfiguration = (CollectorConfiguration) cursor.next();
        List<String> newTags = collectorConfiguration.tags().stream()
                .filter(t -> !tags.contains(t))
                .collect(Collectors.toList());
        tags.addAll(newTags);
    }
    return tags;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:13,代码来源:CollectorConfigurationService.java


示例15: where

import org.mongojack.DBCursor; //导入依赖的package包/类
private void where(String fieldName, BiFunction<String, Object, DBCursor<OrderItemToBePreparedViewModel>> function, Object objectToBeUsedForFiltering) {
    if (objectToBeUsedForFiltering == null) {
        return;
    }

    function.apply(fieldName, objectToBeUsedForFiltering);
}
 
开发者ID:SoftwareSandbox,项目名称:Fiazard,代码行数:8,代码来源:OrderItemToBePreparedViewModelDAO.java


示例16: printAllPBFGames

import org.mongojack.DBCursor; //导入依赖的package包/类
@Test
public void printAllPBFGames() throws IOException {
    @Cleanup DBCursor<PBF> cursor = getApp().pbfCollection.find();
    while (cursor.hasNext()) {
        PBF pbf = cursor.next();
        assertNotNull(pbf);
        System.out.println(pbf.toString());
    }
}
 
开发者ID:cash1981,项目名称:civilization-boardgame-rest,代码行数:10,代码来源:MongoDBTest.java


示例17: findByPage

import org.mongojack.DBCursor; //导入依赖的package包/类
@Override
public List<Comment> findByPage(Page page) {
	final DBCursor<Comment> cursor = getDbCollection().find(DBQuery.is("pageRef", 
			new DBRef<Page, String>(page.getId(), Page.class)));
	addSortCriteria(cursor, getDefaultSortCriteria());
	return toList(cursor);
}
 
开发者ID:thiagohp,项目名称:eloquentia,代码行数:8,代码来源:CommentDAOImpl.java


示例18: toList

import org.mongojack.DBCursor; //导入依赖的package包/类
/**
 * Returns a {@link List} containing the objects returned in a {@link DBCursor}.
 * @param cursor a {@link DBCursor}.
 * @return a {@link List}.
 */
protected List<T> toList(DBCursor<T> cursor) {
	List<T> list = new ArrayList<T>();
	for (T object : cursor) {
		list.add(object);
	}
	return list;
}
 
开发者ID:thiagohp,项目名称:eloquentia,代码行数:13,代码来源:AbstractDAOImpl.java


示例19: addSortCriteria

import org.mongojack.DBCursor; //导入依赖的package包/类
/**
 * Adds sort criteria to a {@link DBCursor}.
 * @param cursor a {@link DBCursor}.
 * @param sortingCriteria an array of {@link SortCriterion}.
 */
protected void addSortCriteria(final DBCursor<T> cursor, SortCriterion... sortingCriteria) {
	if (sortingCriteria != null && sortingCriteria.length > 0) {
		BasicDBObject orderBy = new BasicDBObject();
		for (SortCriterion sortCriterion : sortingCriteria) {
			orderBy.append(sortCriterion.getProperty(), sortCriterion.isAscending() ? 1 : -1);
		}
		cursor.sort(orderBy);
	}
}
 
开发者ID:thiagohp,项目名称:eloquentia,代码行数:15,代码来源:AbstractDAOImpl.java


示例20: loadAll

import org.mongojack.DBCursor; //导入依赖的package包/类
public List<CollectorConfiguration> loadAll() {
    final DBCursor<CollectorConfiguration> cursor = dbCollection.find();
    final List<CollectorConfiguration> collectorConfigurationList = new ArrayList<>();
    Iterables.addAll(collectorConfigurationList, cursor);
    return collectorConfigurationList;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-collector,代码行数:7,代码来源:CollectorConfigurationService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MLDouble类代码示例发布时间:2022-05-22
下一篇:
Java DateParser类代码示例发布时间: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