Search in sources :

Example 1 with CMISQueryOptions

use of org.alfresco.opencmis.search.CMISQueryOptions in project SearchServices by Alfresco.

the class AlfrescoSolrDataModel method parseCMISQueryToAlfrescoAbstractQuery.

public org.alfresco.repo.search.impl.querymodel.Query parseCMISQueryToAlfrescoAbstractQuery(CMISQueryMode mode, SearchParameters searchParameters, SolrQueryRequest req, String alternativeDictionary, CmisVersion cmisVersion) {
    // convert search parameters to cmis query options
    // TODO: how to handle store ref
    CMISQueryOptions options = new CMISQueryOptions(searchParameters.getQuery(), StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    options.setDefaultFieldName(searchParameters.getDefaultFieldName());
    // TODO: options.setDefaultFTSConnective()
    // TODO: options.setDefaultFTSFieldConnective()
    options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
    options.setLocales(searchParameters.getLocales());
    options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
    options.setQueryParameterDefinitions(searchParameters.getQueryParameterDefinitions());
    for (String name : searchParameters.getQueryTemplates().keySet()) {
        String template = searchParameters.getQueryTemplates().get(name);
        options.addQueryTemplate(name, template);
    }
    // parse cmis syntax
    CapabilityJoin joinSupport = (mode == CMISQueryMode.CMS_STRICT) ? CapabilityJoin.NONE : CapabilityJoin.INNERANDOUTER;
    CmisFunctionEvaluationContext functionContext = getCMISFunctionEvaluationContext(mode, cmisVersion, alternativeDictionary);
    CMISDictionaryService cmisDictionary = getCMISDictionary(alternativeDictionary, cmisVersion);
    CMISQueryParser parser = new CMISQueryParser(options, cmisDictionary, joinSupport);
    org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new LuceneQueryModelFactory<Query, Sort, SyntaxError>(), functionContext);
    if (queryModelQuery.getSource() != null) {
        List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext);
        if (selectorGroups.size() == 0) {
            throw new UnsupportedOperationException("No selectors");
        }
    }
    return queryModelQuery;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CmisFunctionEvaluationContext(org.alfresco.opencmis.search.CmisFunctionEvaluationContext) Query(org.apache.lucene.search.Query) CapabilityJoin(org.apache.chemistry.opencmis.commons.enums.CapabilityJoin) CMISQueryOptions(org.alfresco.opencmis.search.CMISQueryOptions) CMISDictionaryService(org.alfresco.opencmis.dictionary.CMISDictionaryService) SyntaxError(org.apache.solr.search.SyntaxError) Sort(org.apache.lucene.search.Sort) CMISQueryParser(org.alfresco.opencmis.search.CMISQueryParser)

Example 2 with CMISQueryOptions

use of org.alfresco.opencmis.search.CMISQueryOptions in project alfresco-repository by Alfresco.

the class LuceneOpenCMISAlfrescoSqlQueryLanguage method executeQuery.

public ResultSet executeQuery(SearchParameters searchParameters) {
    CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
}
Also used : CMISQueryOptions(org.alfresco.opencmis.search.CMISQueryOptions) ResultSetSPIWrapper(org.alfresco.repo.search.results.ResultSetSPIWrapper)

Example 3 with CMISQueryOptions

use of org.alfresco.opencmis.search.CMISQueryOptions in project alfresco-repository by Alfresco.

the class LuceneAlfrescoSqlQueryLanguage method executeQuery.

public ResultSet executeQuery(SearchParameters searchParameters) {
    CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
}
Also used : CMISQueryOptions(org.alfresco.opencmis.search.CMISQueryOptions) ResultSetSPIWrapper(org.alfresco.repo.search.results.ResultSetSPIWrapper)

Example 4 with CMISQueryOptions

use of org.alfresco.opencmis.search.CMISQueryOptions in project alfresco-repository by Alfresco.

the class LuceneCmisStrictSqlQueryLanguage 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));
}
Also used : CMISQueryOptions(org.alfresco.opencmis.search.CMISQueryOptions) ResultSetSPIWrapper(org.alfresco.repo.search.results.ResultSetSPIWrapper)

Example 5 with CMISQueryOptions

use of org.alfresco.opencmis.search.CMISQueryOptions in project alfresco-repository by Alfresco.

the class DbCmisQueryLanguage method executeQueryImpl.

private ResultSet executeQueryImpl(SearchParameters searchParameters) {
    CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
    options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
    CapabilityJoin joinSupport = CapabilityJoin.INNERANDOUTER;
    BaseTypeId[] validScopes = CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
    CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
    functionContext.setCmisDictionaryService(cmisDictionaryService);
    functionContext.setValidScopes(validScopes);
    CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
    org.alfresco.repo.search.impl.querymodel.Query queryModelQuery = parser.parse(new DBQueryModelFactory(), functionContext);
    // TODO: Remove as this appears to be dead code
    // // build lucene query
    // Set<String> selectorGroup = null;
    // if (queryModelQuery.getSource() != null)
    // {
    // List<Set<String>> selectorGroups = queryModelQuery.getSource().getSelectorGroups(functionContext);
    // if (selectorGroups.size() == 0)
    // {
    // throw new UnsupportedOperationException("No selectors");
    // }
    // if (selectorGroups.size() > 1)
    // {
    // throw new UnsupportedOperationException("Advanced join is not supported");
    // }
    // selectorGroup = selectorGroups.get(0);
    // }
    // 
    QueryEngineResults results = queryEngine.executeQuery(queryModelQuery, options, functionContext);
    ResultSet resultSet = results.getResults().values().iterator().next();
    return resultSet;
}
Also used : QueryEngineResults(org.alfresco.repo.search.impl.querymodel.QueryEngineResults) CmisFunctionEvaluationContext(org.alfresco.opencmis.search.CmisFunctionEvaluationContext) BaseTypeId(org.apache.chemistry.opencmis.commons.enums.BaseTypeId) CapabilityJoin(org.apache.chemistry.opencmis.commons.enums.CapabilityJoin) CMISQueryOptions(org.alfresco.opencmis.search.CMISQueryOptions) ResultSet(org.alfresco.service.cmr.search.ResultSet) CMISQueryParser(org.alfresco.opencmis.search.CMISQueryParser) DBQueryModelFactory(org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryModelFactory)

Aggregations

CMISQueryOptions (org.alfresco.opencmis.search.CMISQueryOptions)7 ResultSetSPIWrapper (org.alfresco.repo.search.results.ResultSetSPIWrapper)4 CMISQueryParser (org.alfresco.opencmis.search.CMISQueryParser)2 CmisFunctionEvaluationContext (org.alfresco.opencmis.search.CmisFunctionEvaluationContext)2 CapabilityJoin (org.apache.chemistry.opencmis.commons.enums.CapabilityJoin)2 Serializable (java.io.Serializable)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 CMISDictionaryService (org.alfresco.opencmis.dictionary.CMISDictionaryService)1 DocumentTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper)1 ItemTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)1 TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)1 CMISResultSet (org.alfresco.opencmis.search.CMISResultSet)1 CMISResultSetColumn (org.alfresco.opencmis.search.CMISResultSetColumn)1 CMISResultSetRow (org.alfresco.opencmis.search.CMISResultSetRow)1 QueryEngineResults (org.alfresco.repo.search.impl.querymodel.QueryEngineResults)1 DBQueryModelFactory (org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryModelFactory)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 ResultSet (org.alfresco.service.cmr.search.ResultSet)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1