当前位置: 首页>>代码示例>>Java>>正文


Java SearchParameters.setLanguage方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setLanguage方法的具体用法?Java SearchParameters.setLanguage怎么用?Java SearchParameters.setLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.search.SearchParameters的用法示例。


在下文中一共展示了SearchParameters.setLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * Execute the query
 * 
 * Removes any duplicates that may be present (ID search can cause duplicates -
 * it is better to remove them here)
 * 
 * @param store         StoreRef to search against - null for default configured store
 * @param search        Lucene search to execute
 * @param sort          Columns to sort by
 * @param language      Search language to use e.g. SearchService.LANGUAGE_LUCENE
 * @param maxResults    Maximum results to return if > 0
 * @param skipResults   Results to skip in the result set
 * 
 * @return Array of Node objects
 */
protected Object[] query(String store, String search, SortColumn[] sort, String language, int maxResults, int skipResults)
{   
    SearchParameters sp = new SearchParameters();
    sp.addStore(store != null ? new StoreRef(store) : this.storeRef);
    sp.setLanguage(language != null ? language : SearchService.LANGUAGE_LUCENE);
    sp.setQuery(search);
    if (maxResults > 0)
    {
        sp.setLimit(maxResults);
        sp.setLimitBy(LimitBy.FINAL_SIZE);
    }
    if (skipResults > 0)
    {
        sp.setSkipCount(skipResults);
    }
    if (sort != null)
    {
        for (SortColumn sd : sort)
        {
            sp.addSort(sd.column, sd.asc);
        }
    }
    
    return query(sp, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:Search.java

示例2: executeImpl

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
protected void executeImpl(NodeRef actionedUponNodeRef) {
	
	final SearchParameters sp = new SearchParameters();
	sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
	sp.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
	sp.setQuery(QUERY);
	try {
		final ResultSet rs = searchService.query(sp);
		LOGGER.info("Actual number of sites: {}", rs.length());
		final String message = rs.length() < 5000?"Count of sites is OK":"Count of sites exceed recomended limit";
		setOutput(actionedUponNodeRef, new JSONSitesBuilder().setSitesCount(rs.length()).generateOutput());
		updateStatus(actionedUponNodeRef, JobStatus.Status.FINISHED, message);
	} catch (RuntimeException e) {
		updateStatus(actionedUponNodeRef, JobStatus.Status.ERROR, "Error to get number of sites.");
	}
}
 
开发者ID:Vitezslav-Sliz,项目名称:tieto-alfresco-repository_monitor,代码行数:18,代码来源:MonitorSitesCountAction.java

示例3: fromQuery

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * SearchParameters from the Query object
 * @param sp SearchParameters
 * @param q Query
 */
public void fromQuery(SearchParameters sp, Query q)
{
    ParameterCheck.mandatoryString("query", q.getQuery());
    String lang = q.getLanguage()==null?AFTS:q.getLanguage();

    switch (lang.toLowerCase())
    {
        case AFTS:
            sp.setLanguage(LANGUAGE_FTS_ALFRESCO);
            break;
        case LUCENE:
            sp.setLanguage(LANGUAGE_LUCENE);
            break;
        case CMIS:
            sp.setLanguage(LANGUAGE_CMIS_ALFRESCO);
            break;
        default:
            throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
                        new Object[] { ": language allowed values: afts,lucene,cmis" });
    }
    sp.setQuery(q.getQuery());
    sp.setSearchTerm(q.getUserQuery());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:29,代码来源:SearchMapper.java

示例4: testAuditSearchServiceSearchParametersQuery

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * Test for <a href="https://issues.alfresco.com/jira/browse/MNT-16748">MNT-16748</a> <br>
 * Use {@link SearchService#query(SearchParameters)} to perform a query.
 */
public void testAuditSearchServiceSearchParametersQuery() throws Exception
{
    // Run as admin
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();

    // Create SearchParameters to be used in query
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_XPATH);
    sp.setQuery("/app:company_home/app:dictionary");
    sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Perform a search
    @SuppressWarnings("unused")
    ResultSet rs = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<ResultSet>()
    {
        @Override
        public ResultSet execute() throws Throwable
        {
            return searchService.query(sp);
        }

    }, true, false);

    // Check the audit entries
    checkAuditEntries(APPLICATION_NAME_MNT_16748, SearchService.LANGUAGE_XPATH, "/app:company_home/app:dictionary", 1);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:AuditMethodInterceptorTest.java

示例5: searchForName

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
private ResultSet searchForName(StoreRef storeRef, String name)
{
    SearchParameters sp = new SearchParameters();
    sp.addStore(storeRef);
    sp.setLanguage("lucene");
    sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_NAME.toString()) + ":\"" + name + "\"");
    sp.addLocale(new Locale("en"));
    return searchService.query(sp);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:HiddenAspect.java

示例6: queryWithCount

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
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();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:DBQueryTest.java

示例7: isTxnIdPresentInIndex

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * @return                  Returns true if the given transaction is present in the index
 */
private boolean isTxnIdPresentInIndex(StoreRef storeRef, Transaction txn)
{
    long txnId = txn.getId();
    String changeTxnId = txn.getChangeTxnId();
    // do the most update check, which is most common
    ResultSet results = null;
    try
    {
        SearchParameters sp = new SearchParameters();
        sp.addStore(storeRef);
        // search for it in the index, sorting with youngest first, fetching only 1
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery("TX:" + SearchLanguageConversion.escapeLuceneQuery(changeTxnId));
        sp.setLimit(1);
        
        results = searcher.query(sp);
        
        if (results.length() > 0)
        {
            if (logger.isTraceEnabled())
            {
                logger.trace("Index has results for txn " + txnId + " for store " + storeRef);
            }
            return true;        // there were updates/creates and results for the txn were found
        }
        else
        {
            if (logger.isTraceEnabled())
            {
                logger.trace("Transaction " + txnId + " not in index for store " + storeRef + ".  Possibly out of date.");
            }
            return false;
        }
    }
    finally
    {
        if (results != null) { results.close(); }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:AbstractReindexComponent.java

示例8: findSites

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public List<SiteInfo> findSites(String filter, String sitePresetFilter, int size)
{
    List<SiteInfo> result;
    
    NodeRef siteRoot = getSiteRoot();
    if (siteRoot == null)
    {
        result = Collections.emptyList();
    }
    else
    {
        // get the sites that match the specified names
        StringBuilder query = new StringBuilder(128);
        query.append("+PARENT:\"").append(siteRoot.toString()).append('"');

        final boolean filterIsPresent = filter != null && filter.length() > 0;
        // The filter string is only used in the Lucene query if it restricts results.
        // A search for name/title/description = "*" does not need to be put into the Lucene query.
        // This allows users to search for "*" in the site-finder.
        final boolean filterIsPresentAndNecessary = filterIsPresent && !filter.equals("*");
        final boolean sitePresetFilterIsPresent = sitePresetFilter != null && sitePresetFilter.length() > 0;
        
        if (filterIsPresentAndNecessary || sitePresetFilterIsPresent)
        {
            query.append(" +(");
            if (filterIsPresentAndNecessary)
            {
                String escNameFilter = SearchLanguageConversion.escapeLuceneQuery(filter.replace('"', ' '));
                
                query.append(" @cm\\:name:\"*" + escNameFilter + "*\"")
                     .append(" @cm\\:title:\"" + escNameFilter + "\"")
                     .append(" @cm\\:description:\"" + escNameFilter + "\"");
            }
            if (sitePresetFilterIsPresent)
            {
                String escPresetFilter = SearchLanguageConversion.escapeLuceneQuery(sitePresetFilter.replace('"', ' '));
                query.append(" @st\\:sitePreset:\"" + escPresetFilter + "\"");
            }
            
            query.append(")");
        }
        
        SearchParameters sp = new SearchParameters();
        sp.addStore(siteRoot.getStoreRef());
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery(query.toString());
        if (size > 0)
        {
            sp.setLimit(size);
            sp.setLimitBy(LimitBy.FINAL_SIZE);
        }
        ResultSet results = this.searchService.query(sp);
        try
        {
            result = new ArrayList<SiteInfo>(results.length());
            for (NodeRef site : results.getNodeRefs())
            {
                // Ignore any node type that is not a "site"
                QName siteClassName = this.nodeService.getType(site);
                if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE))
                {
                    result.add(createSiteInfo(site));
                }
            }
        }
        finally
        {
            results.close();
        }
    }
    
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:75,代码来源:SiteServiceImpl.java

示例9: findLinks

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
public CollectionWithPagingInfo<QuickShareLink> findLinks(Parameters parameters)
{
    checkEnabled();

    String queryString =
            "ASPECT:\"" + QuickShareModel.ASPECT_QSHARE.toString() + "\"";

    SearchParameters sp = new SearchParameters();

    // note: REST API query parameter (ie. where clause filter) - not to be confused with search query ;-)
    Query q = parameters.getQuery();
    if (q != null)
    {
        // filtering via "where" clause
        MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(FIND_SHARED_LINKS_QUERY_PROPERTIES, null);
        QueryHelper.walk(q, propertyWalker);

        String sharedByUserId = propertyWalker.getProperty(PARAM_SHAREDBY, WhereClauseParser.EQUALS, String.class);

        if (sharedByUserId != null)
        {
            if (People.DEFAULT_USER.equalsIgnoreCase(sharedByUserId))
            {
                sharedByUserId =  AuthenticationUtil.getFullyAuthenticatedUser();
            }

            QueryParameterDefinition qpd = new QueryParameterDefImpl(QuickShareModel.PROP_QSHARE_SHAREDBY, dictionaryService.getDataType(DataTypeDefinition.TEXT),
                    true, sharedByUserId);
            sp.addQueryParameterDefinition(qpd);

            String qsharedBy = QuickShareModel.PROP_QSHARE_SHAREDBY.toPrefixString(namespaceService);
            queryString += " [email protected]"+SearchLanguageConversion.escapeLuceneQuery(qsharedBy)+":\"${"+qsharedBy+"}\"";
        }
    }

    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery(queryString);
    sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    Paging paging = parameters.getPaging();
    PagingRequest pagingRequest = Util.getPagingRequest(paging);

    sp.setSkipCount(pagingRequest.getSkipCount());
    sp.setMaxItems(pagingRequest.getMaxItems());

    sp.addSort("@" + ContentModel.PROP_MODIFIED, false);

    ResultSet results = searchService.query(sp);

    List<QuickShareLink> qsLinks = new ArrayList<>(results.length());

    List<String> includeParam = parameters.getInclude();

    for (ResultSetRow row : results)
    {
        NodeRef nodeRef = row.getNodeRef();
        qsLinks.add(getQuickShareInfo(nodeRef, false, includeParam));
    }

    results.close();

    return CollectionWithPagingInfo.asPaged(paging, qsLinks, results.hasMore(), new Long(results.getNumberFound()).intValue());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:64,代码来源:QuickShareLinksImpl.java

示例10: testExecute_vanillaISO9075ActualPath

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Category(RedundantTests.class)
@Test
public void testExecute_vanillaISO9075ActualPath() throws Exception
{
    ChildAssociationRef iso9075FolderAssoc = createFolder(testRootFolder.getNodeRef(),
                                                          "Acutal ISO9075 Node");
    NodeRef iso9075Folder = iso9075FolderAssoc.getChildRef();

    NewVirtualReferenceMethod newVirtualReferenceMethod = new NewVirtualReferenceMethod(TEST_TEMPLATE_5_JSON_SYS_PATH,
                                                                                        "/",
                                                                                        iso9075Folder,
                                                                                        VANILLA_PROCESSOR_JS_CLASSPATH);

    ApplyTemplateMethod applyTemplateMethod = new ApplyTemplateMethod(environment);

    Reference ref = Protocols.VANILLA.protocol.dispatch(newVirtualReferenceMethod,
                                                        null);
    VirtualFolderDefinition structure = ref.execute(applyTemplateMethod);

    VirtualFolderDefinition sfp5 = structure.findChildByName("SpecialFilingPath5");
    VirtualQuery query = sfp5.getQuery();

    assertEquals("(PATH:'/app:company_home/cm:TestFolder/cm:Acutal_x0020_ISO9075_x0020_Node/cm:Space_x0020_Sub_x0020_Folder/*')  and =cm:description:'SpecialFilingPath_5'",
                 query.getQueryString());

    ChildAssociationRef iso9075SubFolderAssoc = createFolder(iso9075Folder,
                                                             "Space Sub Folder");

    ChildAssociationRef someContentAssoc = createContent(iso9075SubFolderAssoc.getChildRef(),
                                                         "someContent");

    nodeService.setProperty(someContentAssoc.getChildRef(),
                            ContentModel.PROP_DESCRIPTION,
                            "SpecialFilingPath_5");

    // check query for validity
    SearchParameters searchParameters = new SearchParameters();
    
    searchParameters.setQuery(query.getQueryString());
    searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    searchParameters.setLanguage(query.getLanguage());
    
    /* Code commented out as part of REPO-2028
     * If this test needs to be reactivated, please refactor this to use the prepareMocks/resetMocks methods
     */ 
    // ResultSet qresult = searchService.query(searchParameters);
    // assertEquals(1, qresult.getNumberFound());

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:50,代码来源:ApplyTemplateMethodTest.java

示例11: find

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
public CollectionWithPagingInfo<T> find(Parameters parameters,
    String termName, int minTermLength, String queryTemplateName,
    Sort sort, Map<String, QName> sortParamsToQNames, SortColumn... defaultSort)
{
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
    sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    sp.setDefaultFieldName(queryTemplateName);
    
    String term = getTerm(parameters, termName, minTermLength);

    StringBuilder query = new StringBuilder();
    buildQuery(query, term, sp, queryTemplateName);
    sp.setQuery(query.toString());

    Paging paging = parameters.getPaging();
    PagingRequest pagingRequest = Util.getPagingRequest(paging);
    
    List<SortColumn> defaultSortCols = (defaultSort != null ? Arrays.asList(defaultSort) : Collections.emptyList());
    if (sort == IN_QUERY_SORT)
    {
        addSortOrder(parameters, sortParamsToQNames, defaultSortCols, sp);

        sp.setSkipCount(pagingRequest.getSkipCount());
        sp.setMaxItems(pagingRequest.getMaxItems());
    }
    
    ResultSet queryResults = null;
    List<T> collection = null;
    try
    {
        queryResults = searchService.query(sp);
        
        List<NodeRef> nodeRefs = queryResults.getNodeRefs();
        
        if (sort == POST_QUERY_SORT)
        {
            nodeRefs = postQuerySort(parameters, sortParamsToQNames, defaultSortCols, nodeRefs);
        }
        
        collection = newList(nodeRefs.size());
        List<String> includeParam = parameters.getInclude();

        for (NodeRef nodeRef : nodeRefs)
        {
            T t = convert(nodeRef, includeParam);
            collection.add(t);
        }

        if (sort == POST_QUERY_SORT)
        {
            return listPage(collection, paging);
        }
        else
        {
            return CollectionWithPagingInfo.asPaged(paging, collection, queryResults.hasMore(), new Long(queryResults.getNumberFound()).intValue());
        }
    }
    finally
    {
        if (queryResults != null)
        {
            queryResults.close();
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:67,代码来源:QueriesImpl.java

示例12: getTopCategories

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public List<Pair<NodeRef, Integer>> getTopCategories(StoreRef storeRef, QName aspectName, int count)
{
    AspectDefinition definition = dictionaryService.getAspect(aspectName);
    if(definition == null)
    {
        throw new IllegalStateException("Unknown aspect");
    }
    QName catProperty = null;
    Map<QName, PropertyDefinition> properties = definition.getProperties();
    for(QName pName : properties.keySet())
    {
        if(pName.getNamespaceURI().equals(aspectName.getNamespaceURI()))
        {
            if(pName.getLocalName().equalsIgnoreCase(aspectName.getLocalName()))
            {
                PropertyDefinition def = properties.get(pName);
                if(def.getDataType().getName().equals(DataTypeDefinition.CATEGORY))
                {
                    catProperty = pName;
                }
            }
        }
    }
    if(catProperty == null)
    {
        throw new IllegalStateException("Aspect does not have category property mirroring the aspect name");
    }
    
    String field = "@" + catProperty;
    
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO);
    sp.addStore(storeRef);
    sp.setQuery(catProperty+":*");
    FieldFacet ff = new FieldFacet(field);
    ff.setLimitOrNull(count);
    sp.addFieldFacet(ff);
    
    ResultSet resultSet = null;
    try
    {
        resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(sp);
        List<Pair<String, Integer>> facetCounts = resultSet.getFieldFacet(field);
        List<Pair<NodeRef, Integer>> answer = new LinkedList<Pair<NodeRef, Integer>>();
        for (Pair<String, Integer> term : facetCounts)
        {
            Pair<NodeRef, Integer> toAdd;
            NodeRef nodeRef = new NodeRef(term.getFirst());
            if (nodeService.exists(nodeRef))
            {
                toAdd = new Pair<NodeRef, Integer>(nodeRef, term.getSecond());
            }
            else
            {
                toAdd = new Pair<NodeRef, Integer>(null, term.getSecond());
            }
            answer.add(toAdd);
        }
        return answer;
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:71,代码来源:SolrCategoryServiceImpl.java

示例13: contains

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern, Operator defaultOperator) throws InvalidNodeRefException
{
    ResultSet resultSet = null;
    try
    {
        // build Lucene search string specific to the node
        StringBuilder sb = new StringBuilder();
        sb.append("+ID:\"").append(nodeRef.toString()).append("\" +(TEXT:(").append(googleLikePattern.toLowerCase()).append(") ");
        if (propertyQName != null)
        {
            sb.append(" OR @").append(SearchLanguageConversion.escapeLuceneQuery(QName.createQName(propertyQName.getNamespaceURI(), ISO9075.encode(propertyQName.getLocalName())).toString()));
            sb.append(":(").append(googleLikePattern.toLowerCase()).append(")");
        }
        else
        {
            for (QName key : nodeService.getProperties(nodeRef).keySet())
            {
                sb.append(" OR @").append(SearchLanguageConversion.escapeLuceneQuery(QName.createQName(key.getNamespaceURI(), ISO9075.encode(key.getLocalName())).toString()));
                sb.append(":(").append(googleLikePattern.toLowerCase()).append(")");
            }
        }
        sb.append(")");

        SearchParameters sp = new SearchParameters();
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery(sb.toString());
        sp.setDefaultOperator(defaultOperator);
        sp.addStore(nodeRef.getStoreRef());

        resultSet = this.query(sp);
        boolean answer = resultSet.length() > 0;
        return answer;
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:SolrSearchService.java

示例14: findBlogPosts

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Override
public PagingResults<BlogPostInfo> findBlogPosts(
      final NodeRef blogContainerNode, final RangedDateProperty dateRange, 
      final String tag, final PagingRequest pagingReq)
{
    StringBuilder luceneQuery = new StringBuilder();
    luceneQuery.append("+TYPE:\"").append(ContentModel.TYPE_CONTENT).append("\" ")
               .append("+PARENT:\"").append(blogContainerNode.toString()).append("\" ");
    if (tag != null && !tag.trim().isEmpty())
    {
        luceneQuery.append("+PATH:\"/cm:taggable/cm:").append(ISO9075.encode(tag)).append("/member\"");
    }
    if (dateRange != null)
    {
        luceneQuery.append(createDateRangeQuery(dateRange.getFromDate(), dateRange.getToDate(), dateRange.getDateProperty()));
    }

    SearchParameters sp = new SearchParameters();
    sp.addStore(blogContainerNode.getStoreRef());
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery(luceneQuery.toString());
    sp.addSort(ContentModel.PROP_PUBLISHED.toString(), false);

    sp.setMaxItems(pagingReq.getMaxItems() * MIN_NUMBER_OF_PAGES_FOR_THE_USER_TO_LOOP_THROUGH); 
    sp.setSkipCount(pagingReq.getSkipCount());
    ResultSet luceneResults = null;
    PagingResults<BlogPostInfo> results = null;
    try
    {
        luceneResults = searchService.query(sp);
        final ResultSet finalLuceneResults = luceneResults;
        
        final List<NodeRef> nodeRefs = finalLuceneResults.getNodeRefs().subList(0, min(pagingReq.getMaxItems(), finalLuceneResults.length()));
        
        results = new PagingResults<BlogPostInfo>()
        {
            
            @Override
            public List<BlogPostInfo> getPage()
            {
                List<BlogPostInfo> blogPostInfos = new ArrayList<BlogPostInfo>(nodeRefs.size());
                for (NodeRef nodeRef : nodeRefs)
                {
                    String postName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); 
                    blogPostInfos.add(new BlogPostInfoImpl(nodeRef, blogContainerNode, postName));
                }
                return blogPostInfos;
            }
            
            @Override
            public String getQueryExecutionId()
            {
                return null;
            }
            
            @Override
            public Pair<Integer, Integer> getTotalResultCount()
            { 
                long totalResultCount = finalLuceneResults.getNumberFound();
                /*if (finalLuceneResults.hasMore()){
                    totalResultCount++;
                }*/ 
                return new Pair<Integer, Integer>((int)totalResultCount, (int)totalResultCount);
            }
            
            @Override
            public boolean hasMoreItems()
            {
                return finalLuceneResults.length() > pagingReq.getMaxItems();
            }
        };
    }
    finally
    {
        if (luceneResults != null) luceneResults.close();
    }
    
    
    return results;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:81,代码来源:BlogServiceImpl.java

示例15: getAsSearchParmeters

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * @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;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:51,代码来源:CMISQueryOptions.java


注:本文中的org.alfresco.service.cmr.search.SearchParameters.setLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。