本文整理汇总了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);
}
}
示例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);
}
示例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);
}