org.alfresco.opencmis.search.CMISQueryOptions Java Examples

The following examples show how to use org.alfresco.opencmis.search.CMISQueryOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DbCmisQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
    }
 
Example #2
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #3
Source File: LuceneOpenCMISStrictSqlQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ResultSet executeQuery(SearchParameters searchParameters)
{
    CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
    options.setQueryMode(CMISQueryMode.CMS_STRICT);
    return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
}
 
Example #4
Source File: LuceneCmisStrictSqlQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ResultSet executeQuery(SearchParameters searchParameters)
{
    CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
    options.setQueryMode(CMISQueryMode.CMS_STRICT);
    return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
}
 
Example #5
Source File: LuceneOpenCMISAlfrescoSqlQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
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));
}
 
Example #6
Source File: LuceneAlfrescoSqlQueryLanguage.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
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));
}