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


Java ViewQuery类代码示例

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


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

示例1: getComments

import org.ektorp.ViewQuery; //导入依赖的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: testConnectRoomNoConflict

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Ignore
public void testConnectRoomNoConflict() {

    List<Site> sites = Arrays.asList(site);

    new Expectations() {{
        dbc.queryView((ViewQuery) any); returns(sites);
    }};

    docs.connectRoom(owner, info);
    System.out.println(site);

    new Verifications() {{
        dbc.update(site); times = 1;
        dbc.create(any); times = 4;
        assertNotNull( "createdOn should be set: " + site, site.getCreatedOn());
        assertNotNull( "assignedOn should be set: " + site, site.getAssignedOn());

    }};
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:21,代码来源:SiteCreateMockedTest.java

示例3: testConnectRoomUpdateConflict

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Test(expected=MapModificationException.class)
public void testConnectRoomUpdateConflict() {

    List<Site> sites = Arrays.asList(site, site);

    new Expectations() {{
        dbc.queryView((ViewQuery) any, Site.class); returns(sites);
        dbc.queryView((ViewQuery) any, JsonNode.class); returns(Collections.emptyList(), sites);
        dbc.update(site); result = new UpdateConflictException(); result = null;
    }};

    docs.connectRoom(owner, info);
    System.out.println(site);

    new Verifications() {{
        dbc.create(any); times = 4;
        dbc.update(site); times = 2;
        assertNotNull( "createdOn should be set: " + site, site.getCreatedOn());
        assertNotNull( "assignedOn should be set: " + site, site.getAssignedOn());
    }};
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:22,代码来源:SiteCreateMockedTest.java

示例4: testGetExits

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Test
public void testGetExits(@Mocked ViewResult queryResult, @Mocked ViewResult.Row row, @Mocked JsonNode key) throws Exception {

    List<ViewResult.Row> rows = Arrays.asList(row);
    Exits exits = new Exits();
    exits.setN(new Exit(site, "n"));
    site.setExits(exits);

    final ObjectMapper anyInstance = new ObjectMapper();

    new Expectations(ObjectMapper.class) {{
        anyInstance.treeToValue((TreeNode) any, Site.class); returns(site);
    }};

    new Expectations() {{
        dbc.queryView((ViewQuery) any); returns(queryResult);
        queryResult.getRows(); returns(rows);
        row.getKeyAsNode(); returns(key);
        key.get(2); returns(JsonNodeFactory.instance.textNode("n"));
     }};

    Exits e = docs.getExits(new Coordinates(1,2));
    Assert.assertEquals("Site should be bound to the north", site.getId(), e.getN().getId());
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:25,代码来源:SiteDocumentsTest.java

示例5: findByAppIdBetween

import org.ektorp.ViewQuery; //导入依赖的package包/类
public List<AppInstanceMetrics> findByAppIdBetween(String appId, long startTimestamp, long endTimestamp)
		throws Exception {

	ComplexKey startKey = ComplexKey.of(appId, startTimestamp);
	ComplexKey endKey = ComplexKey.of(appId, endTimestamp);
	ViewQuery q = createQuery("by_appId_between").includeDocs(true).startKey(startKey).endKey(endKey);

	List<AppInstanceMetrics> returnvalue = null;
	String[] input = beforeConnection("QUERY", new String[] { "by_appId_between", appId,
			String.valueOf(startTimestamp), String.valueOf(endTimestamp) });
	try {
		returnvalue = db.queryView(q, AppInstanceMetrics.class);
	} catch (Exception e) {
		e.printStackTrace();
	}
	afterConnection(input);

	return returnvalue;
}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:20,代码来源:AppInstanceMetricsDAOImpl.java

示例6: findByServiceIdBefore

import org.ektorp.ViewQuery; //导入依赖的package包/类
public List<AppInstanceMetrics> findByServiceIdBefore(String serviceId, long olderThan) throws Exception {
	ComplexKey startKey = ComplexKey.of(serviceId, 0);
	ComplexKey endKey = ComplexKey.of(serviceId, olderThan);
	ViewQuery q = createQuery("by_serviceId_before").includeDocs(true).startKey(startKey).endKey(endKey);

	List<AppInstanceMetrics> returnvalue = null;
	String[] input = beforeConnection("QUERY",
			new String[] { "by_serviceId_before", serviceId, String.valueOf(0), String.valueOf(olderThan) });
	try {
		returnvalue = db.queryView(q, AppInstanceMetrics.class);
	} catch (Exception e) {
		e.printStackTrace();
	}
	afterConnection(input);

	return returnvalue;
}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:18,代码来源:AppInstanceMetricsDAOImpl.java

示例7: findByScalingTime

import org.ektorp.ViewQuery; //导入依赖的package包/类
public List<ScalingHistory> findByScalingTime(String appId, long startTime, long endTime) {
	ComplexKey startKey = ComplexKey.of(appId, endTime);
	ComplexKey endKey = ComplexKey.of(appId, startTime);
	ViewQuery q = createQuery("findByScalingTime").includeDocs(true).startKey(startKey).endKey(endKey)
			.descending(true);

	List<ScalingHistory> returnvalue = null;
	String[] input = beforeConnection("QUERY",
			new String[] { "findByScalingTime", appId, String.valueOf(startTime), String.valueOf(endTime) });
	try {
		returnvalue = db.queryView(q, ScalingHistory.class);
	} catch (Exception e) {
		e.printStackTrace();
	}
	afterConnection(input);

	return returnvalue;
}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:19,代码来源:ScalingHistoryDAOImpl.java

示例8: getAttachments

import org.ektorp.ViewQuery; //导入依赖的package包/类
@View(name = "get_attachments", map = "function(doc) {if (doc._attachments) {"
        + "emit(doc._id, doc._attachments)}}")
public byte[] getAttachments(String id) {
    ViewQuery q = new ViewQuery()
            .viewName("get_attachments")
            .designDocId("_design/JsonNode")
            .key(id);

    ViewResult result = db.queryView(q);
    try {
        return mapper.writeValueAsBytes(result.getRows().get(0).getValueAsNode());
    } catch (JsonProcessingException ex) {
        logger.error(ex);
    }
    return null;
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:17,代码来源:CouchDbRepositoryImpl.java

示例9: getDataFromDoc

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Override
@View(name = "get_data", map = "function(doc) {if (doc.data) {"
        + "emit(doc._id, doc.data)}}")
public byte[] getDataFromDoc(String id) {
    ViewQuery q = new ViewQuery()
            .viewName("get_data")
            .designDocId("_design/JsonNode")
            .key(id);

    ViewResult result = db.queryView(q);
    try {
        return mapper.writeValueAsBytes(result.getRows().get(0).getValueAsNode());
    } catch (JsonProcessingException ex) {
        logger.error(ex);
    }
    return null;
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:18,代码来源:CouchDbRepositoryImpl.java

示例10: for

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Override
@View(name = "get_attachments_revs", map = "function(doc) {if (doc._attachments) { var revs = [];"
        + " for(var key in doc._attachments) {revs.push(key);}"
        + "emit(doc._id, revs)}}")
public List<String> getAttachmentRevisions(String id) {
    ViewQuery q = new ViewQuery()
            .viewName("get_attachments_revs")
            .designDocId("_design/JsonNode")
            .key(id);

    ViewResult result = db.queryView(q);
    try {
        return mapper.treeToValue(result.getRows().get(0).getValueAsNode(), List.class);
    } catch (JsonProcessingException ex) {
        logger.error(ex);
    }
    return null;
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:19,代码来源:CouchDbRepositoryImpl.java

示例11: getPermissionsFromDoc

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Override
@View(name = "get_permissions", map = "function(doc) {if (doc.workflow) { "
        + "emit(doc._id, doc.workflow.permissions)}}")
public Set<String> getPermissionsFromDoc(String id) {
    ViewQuery q = new ViewQuery()
            .viewName("get_permissions")
            .designDocId("_design/JsonNode")
            .key(id);

    ViewResult result = db.queryView(q);
    try {
        return mapper.treeToValue(result.getRows().get(0).getValueAsNode(), Set.class);
    } catch (JsonProcessingException ex) {
        logger.error(ex);
    }
    return null;
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:18,代码来源:CouchDbRepositoryImpl.java

示例12: doIndexingQueryIgnoreTimeout

import org.ektorp.ViewQuery; //导入依赖的package包/类
private void doIndexingQueryIgnoreTimeout() throws DbAccessException {
	boolean done = false;
	while (!done) {
		try {
			connector.queryView(new ViewQuery()
					.designDocId("_design/statements")
					.viewName(VerbRegistrationQuery.VIEWNAME).limit(1)
					.startKey("").descending(true));
			done = true;
		} catch (DbAccessException e) {
			// TODO review, seems dangerous
			if (e.getCause() instanceof SocketTimeoutException) {
				continue;
			} else {
				throw e;
			}
		}
	}
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:20,代码来源:CouchDbStatementRepository.java

示例13: materializeMainSchemaTable

import org.ektorp.ViewQuery; //导入依赖的package包/类
@Override
protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int firstRow, int maxRows) {
    // the connector represents a handle to the the couchdb "database".
    final String databaseName = table.getName();
    final CouchDbConnector connector = _couchDbInstance.createConnector(databaseName, false);

    ViewQuery query = new ViewQuery().allDocs().includeDocs(true);

    if (maxRows > 0) {
        query = query.limit(maxRows);
    }
    if (firstRow > 1) {
        final int skip = firstRow - 1;
        query = query.skip(skip);
    }

    final StreamingViewResult streamingView = connector.queryForStreamingView(query);

    final List<SelectItem> selectItems = columns.stream().map(SelectItem::new).collect(Collectors.toList());
    return new CouchDbDataSet(selectItems, streamingView);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:22,代码来源:CouchDbDataContext.java

示例14: createQueryToAppropriateView

import org.ektorp.ViewQuery; //导入依赖的package包/类
private ViewQuery createQueryToAppropriateView(String owner, String name) {
    if (owner == null && name == null) {
        return all;
    } else if (owner != null) {
        return createQueryToOwnerNameView(owner, name);
    } else {
        return createQueryToNameView(name);
    }
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:10,代码来源:SiteDocuments.java

示例15: createQueryToOwnerNameView

import org.ektorp.ViewQuery; //导入依赖的package包/类
private ViewQuery createQueryToOwnerNameView(String owner, String name) {
    ViewQuery ownerNameQuery = createQueryWithoutKeys("owner_name");
    if (name == null) {
        ownerNameQuery = addKeyRangeForAllWithSameFirstEntryInComplexKey(ownerNameQuery, owner);
    } else {
        ownerNameQuery = addComplexKey(ownerNameQuery, owner, name);
    }
    return ownerNameQuery;
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:10,代码来源:SiteDocuments.java


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