Java Code Examples for org.alfresco.service.cmr.search.SearchParameters#setQueryConsistency()

The following examples show how to use org.alfresco.service.cmr.search.SearchParameters#setQueryConsistency() . 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: BasicConstraint.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public SearchParameters apply(ActualEnvironment environment, VirtualQuery query) throws VirtualizationException
{
    SearchParameters searchParameters = new SearchParameters();

    String storeRefString = query.getStoreRef();
    if (storeRefString != null)
    {
        searchParameters.addStore(new StoreRef(storeRefString));
    }
    else
    {
        searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    }

    searchParameters.setLanguage(query.getLanguage());
    searchParameters.setQuery(query.getQueryString());
    searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);

    return searchParameters;
}
 
Example 2
Source File: SearchServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testHybridDisabledByDefault()
{
    try
    {
        authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
        SearchParameters sp = new SearchParameters();
        sp.setQueryConsistency(QueryConsistency.HYBRID);
        sp.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
        sp.setQuery("select * from cmis:document where cmis:name like '%alfresco%'");
        sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
        
        pubSearchService.query(sp);
        
        fail("Hybrid search should be disabled.");
    }
    catch (DisabledFeatureException e)
    {
        // Got here, good.
    }
}
 
Example 3
Source File: VirtualQueryImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private SearchParameters createSearchParameters(boolean files, boolean folders, PagingRequest pagingRequest)
            throws VirtualizationException
{
    SearchParameters searchParameters = new SearchParameters();

    if (store != null)
    {
        searchParameters.addStore(new StoreRef(store));
    }
    else
    {
        searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    }
    searchParameters.setLanguage(language);
    searchParameters.setQuery(filter(language,
                                     query,
                                     files,
                                     folders));
    searchParameters.setQueryConsistency(QueryConsistency.TRANSACTIONAL_IF_POSSIBLE);

    if (pagingRequest != null)
    {
        searchParameters.setSkipCount(pagingRequest.getSkipCount());
        searchParameters.setMaxItems(pagingRequest.getMaxItems());
    }

    return searchParameters;
}
 
Example 4
Source File: DBQueryTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void queryWithCount(String ql, String query, int count, QName property, Boolean ascending)
{
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(ql);
    sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
    sp.setQuery(query);
    sp.addStore(rootNodeRef.getStoreRef());
    ResultSet results = serviceRegistry.getSearchService().query(sp);
    HashSet<NodeRef> found = new HashSet<NodeRef>();
    Comparable last = null;
    for(ResultSetRow row :results)
    {
        assertFalse(found.contains( row.getNodeRef()));
        found.add(row.getNodeRef());
        if(property != null)
        {
            Comparable current = (Comparable)nodeService.getProperty(row.getNodeRef(), property);
            if(last != null)
            {
                if((ascending == null) || (ascending))
                {
                    assert(last.compareTo(current) >= 0);
                }
                else
                {
                    assert(last.compareTo(current) <= 0);
                }
                        
            }
            last = current;
        }
    }
    assertEquals(count, results.length());
    results.getResultSetMetaData();
    results.close();
}
 
Example 5
Source File: QueryOptions.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return SearchParameters
 */
public SearchParameters getAsSearchParmeters()
{
    SearchParameters searchParameters = new SearchParameters();
    searchParameters.setDefaultFieldName(this.getDefaultFieldName());
    searchParameters.setDefaultFTSFieldConnective(this.getDefaultFTSFieldConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
    searchParameters.setDefaultFTSOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
    searchParameters.setDefaultOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
    searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
    if(this.getMaxItems() > 0)
    {
        searchParameters.setLimit(this.getMaxItems());
        searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
        searchParameters.setMaxItems(this.getMaxItems());
    }
    searchParameters.setMaxPermissionChecks(this.getMaxPermissionChecks());
    searchParameters.setMaxPermissionCheckTimeMillis(this.getMaxPermissionCheckTimeMillis());
    searchParameters.setMlAnalaysisMode(this.getMlAnalaysisMode());
    //searchParameters.setNamespace()   TODO: Fix
    //searchParameters.setPermissionEvaluation()
    searchParameters.setQuery(this.getQuery());
    searchParameters.setSkipCount(this.getSkipCount());
    //searchParameters.addAllAttribute()
    for(Locale locale : this.getLocales())
    {
        searchParameters.addLocale(locale);
    }
    for(QueryParameterDefinition queryParameterDefinition: this.getQueryParameterDefinitions())
    {
        searchParameters.addQueryParameterDefinition(queryParameterDefinition);
    }
    //searchParameters.addQueryTemplate(name, template)
    //searchParameters.addSort()
    for(StoreRef storeRef : this.getStores())
    {
        searchParameters.addStore(storeRef);
    }
    //searchParameters.addTextAttribute()
    searchParameters.setQueryConsistency(this.getQueryConsistency());
    searchParameters.setSinceTxId(getSinceTxId());
    for(String name : getQueryTemplates().keySet())
    {
    	String template = getQueryTemplates().get(name);
    	searchParameters.addQueryTemplate(name, template);
    }
    
    return searchParameters;
}
 
Example 6
Source File: CMISQueryOptions.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @return SearchParameters
 */
public SearchParameters getAsSearchParmeters()
{
    SearchParameters searchParameters = new SearchParameters();
    searchParameters.setDefaultFieldName(this.getDefaultFieldName());
    searchParameters.setDefaultFTSFieldConnective(this.getDefaultFTSFieldConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
    searchParameters.setDefaultFTSOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
    searchParameters.setDefaultOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
    searchParameters.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
    if(this.getMaxItems() > 0)
    {
        searchParameters.setLimit(this.getMaxItems());
        searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
        searchParameters.setMaxItems(this.getMaxItems());
    }
    searchParameters.setMaxPermissionChecks(this.getMaxPermissionChecks());
    searchParameters.setMaxPermissionCheckTimeMillis(this.getMaxPermissionCheckTimeMillis());
    searchParameters.setMlAnalaysisMode(this.getMlAnalaysisMode());
    //searchParameters.setNamespace()   TODO: Fix
    //searchParameters.setPermissionEvaluation()
    searchParameters.setQuery(this.getQuery());
    searchParameters.setSkipCount(this.getSkipCount());
    //searchParameters.addAllAttribute()
    for(Locale locale : this.getLocales())
    {
        searchParameters.addLocale(locale);
    }
    for(QueryParameterDefinition queryParameterDefinition: this.getQueryParameterDefinitions())
    {
        searchParameters.addQueryParameterDefinition(queryParameterDefinition);
    }
    //searchParameters.addQueryTemplate(name, template)
    //searchParameters.addSort()
    for(StoreRef storeRef : this.getStores())
    {
        searchParameters.addStore(storeRef);
    }
    //searchParameters.addTextAttribute()
    searchParameters.setBulkFetchEnabled(isBulkFetchEnabled());
    searchParameters.setQueryConsistency(this.getQueryConsistency());
    searchParameters.setSinceTxId(getSinceTxId());
    for(String name : getQueryTemplates().keySet())
    {
    	String template = getQueryTemplates().get(name);
    	searchParameters.addQueryTemplate(name, template);
    }
    return searchParameters;
}