本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Session.query方法的典型用法代码示例。如果您正苦于以下问题:Java Session.query方法的具体用法?Java Session.query怎么用?Java Session.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.client.api.Session
的用法示例。
在下文中一共展示了Session.query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullTextQuery
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static List<String> fullTextQuery(Session lSession, String pStrText) {
List<String> lListResults = null;
int lIntDocumentsFound = 0;
mLog.debug("Start fullTextQuery(String) - ", pStrText);
ItemIterable<QueryResult> lItemIterableQueryResult =
lSession.query("SELECT cmis:objectId FROM cmis:document where CONTAINS('" + pStrText + "')", false);
lListResults = new ArrayList<String>();
for (QueryResult lQueryResult : lItemIterableQueryResult) {
for (PropertyData<?> lPropertyData : lQueryResult.getProperties()) {
lListResults.add((String) lPropertyData.getFirstValue());
}
}
if (lListResults != null) {
lIntDocumentsFound = lListResults.size();
}
mLog.debug("End fullTextQuery(String) - ", pStrText, " - found ", lIntDocumentsFound, " documents.");
return lListResults;
}
示例2: runQuerySingleHit
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
protected QueryResult runQuerySingleHit(Session session, String stmt) {
try {
QueryResult result = null;
int count = 0;
for (QueryResult qr : session.query(stmt, false)) {
count++;
result = qr;
}
if (count != 1) {
addResult(createResult(FAILURE, "The query '" + stmt
+ "' should return exactly one result, but it returned " + count + " results!"));
return null;
}
return result;
} catch (Exception e) {
addResult(createResult(FAILURE, "The query '" + stmt + "' failed with this exception: " + e.toString(), e,
false));
return null;
}
}
示例3: searchDocuments
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static List<Document> searchDocuments(Session pSession, String pQuery) {
mLog.debug("START searchDocuments(String");
mLog.debug("CMIS query: {}", pQuery);
// per evitare il problema dei documenti duplicati
LinkedHashMap<String, Document> lHashMapResults = new LinkedHashMap<String, Document>();
ItemIterable<QueryResult> lResults = pSession.query(pQuery, false);
// XXX (Alessio): sarà il modo giusto? Prestazioni?
if (lResults != null) {
int i = 0;
//
for (Iterator<QueryResult> iterator = lResults.iterator(); i < ((CollectionIterator<QueryResult>)iterator).getTotalNumItems();) {
QueryResult qResult = iterator.next();
//} (QueryResult qResult : lResults) {
if (qResult != null) {
PropertyData<?> lPropData = qResult.getPropertyById("cmis:objectId");
if (lPropData != null) {
String lObjectId = (String) lPropData.getFirstValue();
CmisObject lObj = pSession.getObject(pSession.createObjectId(lObjectId));
lHashMapResults.put(lObjectId, (Document) lObj);
}
}
i++;
}
}
mLog.debug("END searchDocuments(String");
return new ArrayList<Document>(lHashMapResults.values());
}
示例4: testCreate
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public void testCreate()
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
for(int i = 0; i < 50; i++)
{
AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("user"+i);
List<String> permissions = new ArrayList<String>(1);
permissions.add(BasicPermissions.READ);
List<Ace> addAces = new ArrayList<Ace>(1);
addAces.add(new AccessControlEntryImpl(principal, permissions));
newFolder.addAcl(addAces, AclPropagation.PROPAGATE);
Map<String, Object> updateProperties = new HashMap<String, Object>();
updateProperties.put("cm:title", "Update title "+i);
newFolder.updateProperties(properties);
if(i % 10 == 0)
{
System.out.println("@ "+i);
}
}
ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
assertTrue(result.getTotalNumItems() > 0);
result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertTrue(result.getTotalNumItems() > 0);
}
示例5: runQueryNoException
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
protected boolean runQueryNoException(Session session, String stmt) {
try {
for (QueryResult qr : session.query(stmt, false)) {
qr.getPropertyByQueryName("cmis:name");
}
return true;
} catch (Exception e) {
addResult(createResult(FAILURE, "The query '" + stmt + "' failed with this exception: " + e.toString(), e,
false));
return false;
}
}
示例6: testCreateLots
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public void testCreateLots() throws Exception
{
Session session = getSession("admin", "admin");
Folder root = session.getRootFolder();
String folderNameBase = getRootFolderName();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderNameBase);
Folder base = root.createFolder(properties);
for(int i = 0; i < 10; i++)
{
AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(""+i+i+i);
List<String> permissions = new ArrayList<String>(1);
permissions.add(BasicPermissions.ALL);
List<Ace> addAces = new ArrayList<Ace>(1);
addAces.add(new AccessControlEntryImpl(principal, permissions));
base.addAcl(addAces, AclPropagation.PROPAGATE);
}
Thread last = null;
for(int i = 0; i < 10; i++)
{
Creator creator = new Creator(base.getPath(), i);
Thread thread = new Thread(creator);
thread.start();
last = thread;
}
if(last != null)
{
last.join();
}
ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
assertTrue(result.getTotalNumItems() > 0);
//result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
//assertTrue(result.getTotalNumItems() > 0);
}
示例7: testQueryFolderProperties
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public void testQueryFolderProperties()
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertEquals(1, result.getTotalNumItems());
String uniqueName = getUniqueName();
Map<String, Object> uProperties = new HashMap<String, Object>();
uProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
uProperties.put(PropertyIds.NAME, uniqueName);
Folder uniqueFolder = newFolder.createFolder(uProperties);
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND IN_FOLDER('"+ uniqueFolder.getParentId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where IN_FOLDER('"+ uniqueFolder.getParentId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:createdBy = '"+ uniqueFolder.getCreatedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:objectId = '"+ uniqueFolder.getId()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:lastModifiedBy = '"+ uniqueFolder.getLastModifiedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+ uniqueFolder.getName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
String creationDate = ISO8601DateFormat.format(uniqueFolder.getCreationDate().getTime());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:creationDate = '"+ creationDate +"'" , false);
assertEquals(1, result.getTotalNumItems());
String modificationDate = ISO8601DateFormat.format(uniqueFolder.getLastModificationDate().getTime());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:lastModificationDate = '"+ modificationDate+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:objectTypeId = '"+ uniqueFolder.getType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:baseTypeId = '"+ uniqueFolder.getBaseType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
}
示例8: testQueryDocumentProperties
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public void testQueryDocumentProperties() throws Exception
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertEquals(1, result.getTotalNumItems());
Document uniqueDocument = createUniqueDocument(newFolder);
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND IN_FOLDER('"+ newFolder.getId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where IN_FOLDER('"+ newFolder.getId() + "')" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:createdBy = '"+ uniqueDocument.getCreatedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:objectId = '"+ uniqueDocument.getId()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:lastModifiedBy = '"+ uniqueDocument.getLastModifiedBy()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+ uniqueDocument.getName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
String creationDate = ISO8601DateFormat.format(uniqueDocument.getCreationDate().getTime());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:creationDate = '"+ creationDate +"'" , false);
assertEquals(1, result.getTotalNumItems());
String modificationDate = ISO8601DateFormat.format(uniqueDocument.getLastModificationDate().getTime());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:lastModificationDate = '"+ modificationDate+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:objectTypeId = '"+ uniqueDocument.getType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:baseTypeId = '"+ uniqueDocument.getBaseType().getQueryName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamFileName = '"+ uniqueDocument.getContentStreamFileName()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamLength = '"+ uniqueDocument.getContentStreamLength()+"'" , false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamMimeType = '"+ uniqueDocument.getContentStreamMimeType()+"'" , false);
assertEquals(1, result.getTotalNumItems());
}
示例9: testQueryForMultipleDocumentProperties
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public void testQueryForMultipleDocumentProperties() throws Exception
{
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
assertEquals(1, result.getTotalNumItems());
Document document1 = createUniqueDocument(newFolder);
Document document2 = createUniqueDocument(newFolder);
//result = session.query("SELECT * FROM cmis:folder d join sys:hidden t on d.cmis:objectId = t.cmis:objectId", false);
//assertTrue(0 < result.getTotalNumItems());
//result = session.query("SELECT * FROM cmis:folder d join sys:hidden t on d.cmis:objectId = t.cmis:objectId where t.sys:cascadeHidden = false", false);
//assertTrue(0 < result.getTotalNumItems());
result = session.query("SELECT * FROM cmis:document d join exif:exif t on d.cmis:objectId = t.cmis:objectId", false);
long count = result.getTotalNumItems();
Map<String, Object> props = new HashMap<String, Object>();
props.put("exif:focalLength", 10.33d);
ArrayList<String> aspects = new ArrayList<String>();
aspects.add("P:exif:exif");
props.put("cmis:secondaryObjectTypeIds", aspects);
document1.updateProperties(props);
result = session.query("SELECT * FROM cmis:document d join exif:exif t on d.cmis:objectId = t.cmis:objectId", false);
assertEquals(count+1, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+document1.getName()+"' OR cmis:name = '"+document2.getName()+"'", false);
assertEquals(2, result.getTotalNumItems());
result = session.query("select * from cmis:document where cmis:name = '"+document1.getName()+"' AND cmis:contentStreamLength = 5 AND cmis:contentStreamMimeType = 'text/plain'", false);
assertEquals(1, result.getTotalNumItems());
}