use of org.alfresco.opencmis.search.CMISResultSet in project alfresco-repository by Alfresco.
the class SolrOpenCMISQueryServiceImpl method query.
@Override
public CMISResultSet query(CMISQueryOptions options) {
SearchParameters searchParameters = options.getAsSearchParmeters();
searchParameters.addExtraParameter("cmisVersion", options.getCmisVersion().toString());
ResultSet rs = solrQueryLanguage.executeQuery(searchParameters);
CapabilityJoin joinSupport = getJoinSupport();
if (options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS) {
joinSupport = CapabilityJoin.INNERANDOUTER;
}
// TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser
BaseTypeId[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
functionContext.setCmisDictionaryService(cmisDictionaryService);
functionContext.setNodeService(nodeService);
functionContext.setValidScopes(validScopes);
CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
Query query = parser.parse(new LuceneQueryModelFactory(), functionContext);
Map<String, ResultSet> wrapped = new HashMap<String, ResultSet>();
for (Set<String> group : query.getSource().getSelectorGroups(functionContext)) {
for (String selector : group) {
wrapped.put(selector, rs);
}
}
LimitBy limitBy = null;
limitBy = rs.getResultSetMetaData().getLimitedBy();
CMISResultSet cmis = new CMISResultSet(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService);
return cmis;
}
use of org.alfresco.opencmis.search.CMISResultSet 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;
}
Aggregations