Search in sources :

Example 1 with CMISDictionaryService

use of org.alfresco.opencmis.dictionary.CMISDictionaryService 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 CMISDictionaryService

use of org.alfresco.opencmis.dictionary.CMISDictionaryService in project SearchServices by Alfresco.

the class AlfrescoSolrDataModel method getCMISDictionary.

/**
 * Gets the CMISDictionaryService, if an Alternative dictionary is specified it tries to get that.
 * It will attempt to get the DEFAULT dictionary service if null is specified or it can't find
 * a dictionary with the name of "alternativeDictionary"
 * @param alternativeDictionary - can be null;
 * @return CMISDictionaryService
 */
public CMISDictionaryService getCMISDictionary(String alternativeDictionary, CmisVersion cmisVersion) {
    CMISDictionaryService cmisDictionary = null;
    if (alternativeDictionary != null && !alternativeDictionary.trim().isEmpty()) {
        DictionaryKey key = new DictionaryKey(cmisVersion, alternativeDictionary);
        cmisDictionary = cmisDictionaryServices.get(key);
    }
    if (cmisDictionary == null) {
        DictionaryKey key = new DictionaryKey(cmisVersion, CMISStrictDictionaryService.DEFAULT);
        cmisDictionary = cmisDictionaryServices.get(key);
    }
    return cmisDictionary;
}
Also used : DictionaryKey(org.alfresco.solr.AlfrescoClientDataModelServicesFactory.DictionaryKey) CMISDictionaryService(org.alfresco.opencmis.dictionary.CMISDictionaryService)

Aggregations

CMISDictionaryService (org.alfresco.opencmis.dictionary.CMISDictionaryService)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 CMISQueryOptions (org.alfresco.opencmis.search.CMISQueryOptions)1 CMISQueryParser (org.alfresco.opencmis.search.CMISQueryParser)1 CmisFunctionEvaluationContext (org.alfresco.opencmis.search.CmisFunctionEvaluationContext)1 DictionaryKey (org.alfresco.solr.AlfrescoClientDataModelServicesFactory.DictionaryKey)1 CapabilityJoin (org.apache.chemistry.opencmis.commons.enums.CapabilityJoin)1 Query (org.apache.lucene.search.Query)1 Sort (org.apache.lucene.search.Sort)1 SyntaxError (org.apache.solr.search.SyntaxError)1