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


Java CouchDbConnector.queryView方法代码示例

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


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

示例1: getComments

import org.ektorp.CouchDbConnector; //导入方法依赖的package包/类
private JSONArray getComments(String itemNumber) {
	JSONArray returnArray = new JSONArray();
	CouchDbConnector dbc = _db.createConnector(dbname, true);

	Map<String, String> doc = new HashMap<String, String>();

	ViewQuery query = new ViewQuery().allDocs().includeDocs(true);
	List<Map> result = dbc.queryView(query, Map.class);
	JSONArray jsonresult = new JSONArray();
	for (Map element : result) {
		JSONObject obj = new JSONObject();
		obj.putAll(element);
		if(itemNumber==null || obj.get("itemNumber").equals(itemNumber))
			jsonresult.add(obj);
	}

	System.out.println(jsonresult.toString());

	return jsonresult;

}
 
开发者ID:IBM-Cloud,项目名称:BluemixBoutique,代码行数:22,代码来源:CommentsServlet.java

示例2: getQueryResult

import org.ektorp.CouchDbConnector; //导入方法依赖的package包/类
@Override
public final StatementResult getQueryResult(CouchDbConnector connector,
		StatementFilter filter, QueryStrategy strategy) {

	int limit = resolveLimit(filter.getLimit());
	boolean isAscending = resolveAscending(filter.getAscending());

	ViewQuery viewQuery = getViewQuery(filter, limit, isAscending);
	viewQuery.staleOk(strategy == QueryStrategy.STALE);
	List<StatementDocument> docs = connector.queryView(viewQuery,
			StatementDocument.class);

	StatementDocument nextDoc = null;
	if (docs.size() > limit) {
		nextDoc = docs.remove(docs.size() - 1);
	}

	StatementResult result = new StatementResult(docsToStatement(docs),
			null);

	if (nextDoc != null) {
		StatementFilter moreFilter = new StatementFilter(filter);
		copyStartKeyValuesToFilter(moreFilter, nextDoc, isAscending);
		moreFilter.setStartId(nextDoc.getId());
		result.setMore(StatementFilterUtil.toMoreUrl(moreFilter));
	}
	return result;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:29,代码来源:MapQuery.java

示例3: getLastIndexed

import org.ektorp.CouchDbConnector; //导入方法依赖的package包/类
public static StatementDocument getLastIndexed(CouchDbConnector connector) {
	String nowDateStr = MapQuery.date2String(new Date());

	ViewQuery query = new ViewQuery()
			.viewName(VerbRegistrationQuery.VIEWNAME)
			.designDocId("_design/statements")
			. startKey(ComplexKey.of("ALL", null, null, nowDateStr))
			.limit(1).staleOk(true).descending(true).inclusiveEnd(true)
			.includeDocs(true);

	List<StatementDocument> qResult = connector.queryView(query,
			StatementDocument.class);
	return qResult.size() > 0 ? qResult.get(0) : null;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:15,代码来源:Util.java

示例4: testViewQueryFromWeb

import org.ektorp.CouchDbConnector; //导入方法依赖的package包/类
public void testViewQueryFromWeb() throws IOException {

        HttpClient httpClient = new CBLiteHttpClient(manager);
        CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);

        CouchDbConnector couchDbConnector = dbInstance.createConnector(DEFAULT_TEST_DB, true);

        String dDocName = "ddoc";
        String viewName = "people";
        View view = database.getView(String.format("%s/%s", dDocName, viewName));

        view.setMapReduce(new Mapper() {
                              @Override
                              public void map(Map<String, Object> document, Emitter emitter) {
                                  String type = (String) document.get("type");
                                  if ("person".equals(type)) {
                                      emitter.emit(null, document.get("_id"));
                                  }
                              }
                          }, new Reducer() {
                              @Override
                              public Object reduce(List<Object> keys, List<Object> values, boolean rereduce) {
                                  return null;
                              }
                          }, "1"
        );

        ViewQuery viewQuery = new ViewQuery().designDocId("_design/" + dDocName).viewName(viewName);
        //viewQuery.descending(true); //use this to reverse the sorting order of the view
        ViewResult viewResult = couchDbConnector.queryView(viewQuery);

        Assert.assertEquals(0, viewResult.getTotalRows());

    }
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-android-ektorp,代码行数:35,代码来源:Views.java

示例5: testViewReduceQuery

import org.ektorp.CouchDbConnector; //导入方法依赖的package包/类
public void testViewReduceQuery() throws IOException {

        HttpClient httpClient = new CBLiteHttpClient(manager);
        CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);

        CouchDbConnector dbConnector = dbInstance.createConnector(DEFAULT_TEST_DB, true);

        putDocs(dbConnector);
        createViewWithReduce(database);


        //because this view has a reduce function it should default to reduce=true
        ViewQuery query = new ViewQuery().designDocId(dDocId).viewName(viewReduceName);
        ViewResult result = dbConnector.queryView(query);

        Assert.assertEquals(1, result.getTotalRows());
        Assert.assertEquals(5, result.getRows().get(0).getValueAsInt());

        //we should still be able to override it and force reduce=false
        query = new ViewQuery().designDocId(dDocId).viewName(viewReduceName).reduce(false);
        result = dbConnector.queryView(query);

        Assert.assertEquals(5, result.getTotalRows());
    }
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-android-ektorp,代码行数:25,代码来源:Views.java


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