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


Java JacksonDBCollection.find方法代码示例

本文整理汇总了Java中org.mongojack.JacksonDBCollection.find方法的典型用法代码示例。如果您正苦于以下问题:Java JacksonDBCollection.find方法的具体用法?Java JacksonDBCollection.find怎么用?Java JacksonDBCollection.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mongojack.JacksonDBCollection的用法示例。


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

示例1: fetch

import org.mongojack.JacksonDBCollection; //导入方法依赖的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

示例2: get

import org.mongojack.JacksonDBCollection; //导入方法依赖的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

示例3: loadResources

import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
   public <T> List<T> loadResources(String collection, Class<T> cl) {
// Shell query: db.xxx.find();
List<T> results = new ArrayList<T>();
DBCollection collec = db.getCollection("Fridges");
try {
    JacksonDBCollection<T, String> collecMj = JacksonDBCollection.wrap(collec,
	    cl, String.class);
    Iterable<T> all = collecMj.find();
    for (T current : all) {
	results.add(current);
    }
} catch (Exception ex) {
    ex.printStackTrace();
    System.out.println(ex);
}
return results;
   }
 
开发者ID:domguinard,项目名称:mongodb-3-drivers-tutorial,代码行数:19,代码来源:DatasourceProviderMongoJack.java

示例4: getHubs

import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public List<Hub> getHubs() {
	JacksonDBCollection<Hub, String> col = JacksonDBCollection.wrap(
			mongoDB.getCollection("hubs"), Hub.class, String.class);
	List<Hub> res = new ArrayList<Hub>();
	for (Hub s : col.find()) {
		res.add(s);
	}
	return res;
}
 
开发者ID:IBMDecisionOptimization,项目名称:DOcloud-GreenTruck-sample,代码行数:11,代码来源:TruckingManagerBean.java

示例5: getSpokes

import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public List<Spoke> getSpokes() {
	JacksonDBCollection<Spoke, String> col = JacksonDBCollection.wrap(
			mongoDB.getCollection("spokes"), Spoke.class, String.class);
	List<Spoke> res = new ArrayList<Spoke>();
	for (Spoke s : col.find()) {
		res.add(s);
	}
	return res;
}
 
开发者ID:IBMDecisionOptimization,项目名称:DOcloud-GreenTruck-sample,代码行数:11,代码来源:TruckingManagerBean.java

示例6: getTruckTypes

import org.mongojack.JacksonDBCollection; //导入方法依赖的package包/类
@Override
public List<TruckType> getTruckTypes() {
	JacksonDBCollection<TruckType, String> col = JacksonDBCollection.wrap(
			mongoDB.getCollection("truckTypes"), TruckType.class,
			String.class);
	List<TruckType> res = new ArrayList<TruckType>();
	for (TruckType s : col.find()) {
		res.add(s);
	}
	return res;
}
 
开发者ID:IBMDecisionOptimization,项目名称:DOcloud-GreenTruck-sample,代码行数:12,代码来源:TruckingManagerBean.java


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