use of org.alfresco.opencmis.search.CMISQueryOptions in project alfresco-repository by Alfresco.
the class CMISConnector method query.
@SuppressWarnings("unchecked")
public ObjectList query(String statement, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount) /*, CmisVersion cmisVersion*/
{
// prepare results
ObjectListImpl result = new ObjectListImpl();
result.setObjects(new ArrayList<ObjectData>());
// prepare query
CMISQueryOptions options = new CMISQueryOptions(statement, getRootStoreRef());
CmisVersion cmisVersion = getRequestCmisVersion();
options.setCmisVersion(cmisVersion);
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
int skip = 0;
if ((skipCount != null) && (skipCount.intValue() >= 0)) {
skip = skipCount.intValue();
options.setSkipCount(skip);
}
if ((maxItems != null) && (maxItems.intValue() >= 0)) {
options.setMaxItems(maxItems.intValue());
}
boolean fetchObject = includeAllowableActions || (includeRelationships != IncludeRelationships.NONE) || (!RENDITION_NONE.equals(renditionFilter));
// query
CMISResultSet rs = getOpenCMISQueryService().query(options);
try {
CMISResultSetColumn[] columns = rs.getMetaData().getColumns();
for (CMISResultSetRow row : rs) {
NodeRef nodeRef = row.getNodeRef();
if (!nodeService.exists(nodeRef) || filter(nodeRef)) {
continue;
}
TypeDefinitionWrapper type = getType(nodeRef);
if (type == null) {
continue;
}
ObjectDataImpl hit = new ObjectDataImpl();
PropertiesImpl properties = new PropertiesImpl();
hit.setProperties(properties);
Map<String, Serializable> values = row.getValues();
for (CMISResultSetColumn column : columns) {
AbstractPropertyData<?> property = getProperty(column.getCMISDataType(), column.getCMISPropertyDefinition(), values.get(column.getName()));
property.setQueryName(column.getName());
properties.addProperty(property);
}
if (fetchObject) {
// set allowable actions
if (includeAllowableActions) {
CMISNodeInfoImpl nodeInfo = createNodeInfo(nodeRef);
if (!nodeInfo.getObjectVariant().equals(CMISObjectVariant.NOT_EXISTING)) {
hit.setAllowableActions(getAllowableActions(nodeInfo));
}
}
// set relationships
if (includeRelationships != IncludeRelationships.NONE) {
hit.setRelationships(getRelationships(nodeRef, includeRelationships));
}
// set renditions
if (!RENDITION_NONE.equals(renditionFilter)) {
List<RenditionData> renditions = getRenditions(nodeRef, renditionFilter, null, null);
if ((renditions != null) && (!renditions.isEmpty())) {
hit.setRenditions(renditions);
} else {
hit.setRenditions(Collections.EMPTY_LIST);
}
}
}
result.getObjects().add(hit);
}
long numberFound = rs.getNumberFound();
if (numberFound != -1) {
result.setNumItems(BigInteger.valueOf(numberFound));
}
result.setHasMoreItems(rs.hasMore());
} finally {
rs.close();
}
return result;
}
use of org.alfresco.opencmis.search.CMISQueryOptions in project alfresco-repository by Alfresco.
the class LuceneOpenCMISStrictSqlQueryLanguage method executeQuery.
public ResultSet executeQuery(SearchParameters searchParameters) {
CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
options.setQueryMode(CMISQueryMode.CMS_STRICT);
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
}
Aggregations