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


Java Session.createQueryStatement方法代码示例

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


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

示例1: runObjectIdQuery

import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
private void runObjectIdQuery(Session session, String stmt, String objectId, boolean objectIdTwice) {
	QueryStatement queryStmt = session.createQueryStatement(stmt);

	if (objectIdTwice) {
		queryStmt.setString(1, new String[] { objectId, objectId });
	} else {
		queryStmt.setString(1, objectId);
	}

	QueryResult result = runQuerySingleHit(session, queryStmt.toQueryString());

	if (result != null) {
		CmisTestResult failure = createResult(FAILURE,
				"The query '" + queryStmt.toQueryString() + "' returned the wrong object!");
		assertEquals(objectId, result.getPropertyByQueryName("cmis:objectId"), null, failure);
	}
}
 
开发者ID:SAP,项目名称:cloud-cmis-workbench,代码行数:18,代码来源:SDCSyncTest.java

示例2: doPost

import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException {

	String q = getStringParameter(request, PARAM_Q);
	int skip = getIntParameter(request, PARAM_SKIP, 0);

	request.setAttribute(ATTR_Q, q);

	boolean supportCombinedFulltext = (session.getRepositoryInfo()
			.getCapabilities().getQueryCapability() == CapabilityQuery.BOTHCOMBINED);

	QueryStatement stmt = session
			.createQueryStatement("SELECT cmis:objectId, cmis:objectTypeId, "
					+ "cmis:name, cmis:lastModificationDate "
					+ "FROM cmis:document "
					+ "WHERE IN_TREE(?) AND (cmis:name LIKE ? OR "
					+ "cmis:contentStreamFileName LIKE ?"
					+ (supportCombinedFulltext ? " OR CONTAINS(?)" : "")
					+ ") " + "ORDER BY cmis:lastModificationDate DESC");
	stmt.setString(1, getApplicationRootFolderId(request));
	stmt.setStringLike(2, "%" + q + "%");
	stmt.setStringLike(3, "%" + q + "%");
	stmt.setStringContains(4, q);

	request.setAttribute(ATTR_CQL, stmt.toQueryString());

	ItemIterable<QueryResult> results = stmt.query(false);

	// get only a page
	List<Map<String, Object>> resultsList = new ArrayList<Map<String, Object>>();
	ItemIterable<QueryResult> resultsPage = results.skipTo(
			skip * QUERY_PAGE_SIZE).getPage(QUERY_PAGE_SIZE);

	for (QueryResult qr : resultsPage) {
		Map<String, Object> row = new HashMap<String, Object>();

		row.put("cmis:name",
				qr.getPropertyValueByQueryName("cmis:name"));
		row.put("cmis:objectId",
				qr.getPropertyValueByQueryName("cmis:objectId"));

		ObjectType type = session.getTypeDefinition((String) qr
				.getPropertyValueByQueryName("cmis:objectTypeId"));
		row.put("type", type.getDisplayName());

		row.put("cmis:lastModificationDate",
				qr.getPropertyValueByQueryName("cmis:lastModificationDate"));

		resultsList.add(row);
	}

	request.setAttribute(ATTR_RESULTS, resultsList);

	// show search page
	dispatch("search.jsp", "Search. The Blend.", request, response);
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:59,代码来源:SearchServlet.java

示例3: doGet

import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request,
		HttpServletResponse response, Session session)
		throws ServletException, IOException {

	String tag = getStringParameter(request, PARAM_TAG);
	int skip = getIntParameter(request, PARAM_SKIP, 0);

	request.setAttribute(ATTR_TAG, tag);

	if (tag != null) {
		tag = tag.trim();

		QueryStatement stmt = session
				.createQueryStatement("SELECT cmis:objectId, cmis:objectTypeId, "
						+ "cmis:name, cmis:lastModificationDate, "
						+ IdMapping
								.getRepositoryPropertyQueryName("cmisbook:tags")
						+ " AS tags "
						+ "FROM "
						+ IdMapping
								.getRepositoryTypeQueryName("cmisbook:taggable")
						+ " "
						+ "WHERE IN_TREE(?) "
						+ "AND ? = ANY "
						+ IdMapping
								.getRepositoryPropertyQueryName("cmisbook:tags")
						+ " " + "ORDER BY cmis:lastModificationDate DESC");
		stmt.setString(1, getApplicationRootFolderId(request));
		stmt.setString(2, tag);

		request.setAttribute(ATTR_CQL, stmt.toQueryString());

		ItemIterable<QueryResult> results = stmt.query(false);

		// get only a page
		List<Map<String, Object>> resultsList = new ArrayList<Map<String, Object>>();
		ItemIterable<QueryResult> resultsPage = results.skipTo(
				skip * QUERY_PAGE_SIZE).getPage(QUERY_PAGE_SIZE);

		for (QueryResult qr : resultsPage) {
			Map<String, Object> row = new HashMap<String, Object>();

			row.put("cmis:name",
					qr.getPropertyValueByQueryName("cmis:name"));
			row.put("cmis:objectId",
					qr.getPropertyValueByQueryName("cmis:objectId"));

			ObjectType type = session.getTypeDefinition((String) qr
					.getPropertyValueByQueryName("cmis:objectTypeId"));
			row.put("type", type.getDisplayName());

			row.put("cmis:lastModificationDate", qr
					.getPropertyValueByQueryName("cmis:lastModificationDate"));

			row.put("cmisbook:tags",
					qr.getPropertyMultivalueByQueryName("tags")); // using the
																												// alias

			resultsList.add(row);
		}

		request.setAttribute(ATTR_RESULTS, resultsList);
	}

	// show tags page
	dispatch("tags.jsp", "Tags. The Blend.", request, response);
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:69,代码来源:TagsServlet.java


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