Search in sources :

Example 26 with UserInfo

use of org.alfresco.rest.api.model.UserInfo in project alfresco-remote-api by Alfresco.

the class ResultMapper method toCollectionWithPagingInfo.

/**
 * Turns the results into a CollectionWithPagingInfo
 * @param params
 * @param searchQuery
 *@param results  @return CollectionWithPagingInfo<Node>
 */
public CollectionWithPagingInfo<Node> toCollectionWithPagingInfo(Params params, SearchRequestContext searchRequestContext, SearchQuery searchQuery, ResultSet results) {
    SearchContext context = null;
    Integer total = null;
    List<Node> noderesults = new ArrayList<Node>();
    Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
    Map<NodeRef, List<Pair<String, List<String>>>> hightLighting = results.getHighlighting();
    int notFound = 0;
    boolean isHistory = searchRequestContext.getStores().contains(StoreMapper.HISTORY);
    for (ResultSetRow row : results) {
        Node aNode = getNode(row, params, mapUserInfo, isHistory);
        if (aNode != null) {
            float f = row.getScore();
            List<HighlightEntry> highlightEntries = null;
            List<Pair<String, List<String>>> high = hightLighting.get(row.getNodeRef());
            if (high != null && !high.isEmpty()) {
                highlightEntries = new ArrayList<HighlightEntry>(high.size());
                for (Pair<String, List<String>> highlight : high) {
                    highlightEntries.add(new HighlightEntry(highlight.getFirst(), highlight.getSecond()));
                }
            }
            aNode.setSearch(new SearchEntry(f, highlightEntries));
            noderesults.add(aNode);
        } else {
            logger.debug("Unknown noderef returned from search results " + row.getNodeRef());
            notFound++;
        }
    }
    SolrJSONResultSet solrResultSet = findSolrResultSet(results);
    if (solrResultSet != null) {
        // We used Solr for this query
        context = toSearchContext(solrResultSet, searchRequestContext, searchQuery, notFound);
    }
    total = setTotal(results);
    return CollectionWithPagingInfo.asPaged(params.getPaging(), noderesults, results.hasMore(), total, null, context);
}
Also used : HashMap(java.util.HashMap) Node(org.alfresco.rest.api.model.Node) ArrayList(java.util.ArrayList) SearchContext(org.alfresco.rest.api.search.context.SearchContext) UserInfo(org.alfresco.rest.api.model.UserInfo) ResultSetRow(org.alfresco.service.cmr.search.ResultSetRow) SolrJSONResultSet(org.alfresco.repo.search.impl.lucene.SolrJSONResultSet) NodeRef(org.alfresco.service.cmr.repository.NodeRef) List(java.util.List) TupleList(org.alfresco.rest.api.search.model.TupleList) ArrayList(java.util.ArrayList) SearchEntry(org.alfresco.rest.api.search.model.SearchEntry) HighlightEntry(org.alfresco.rest.api.search.model.HighlightEntry) Pair(org.alfresco.util.Pair)

Aggregations

UserInfo (org.alfresco.rest.api.model.UserInfo)26 HashMap (java.util.HashMap)22 NodeRef (org.alfresco.service.cmr.repository.NodeRef)18 AbstractList (java.util.AbstractList)13 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)13 FileInfo (org.alfresco.service.cmr.model.FileInfo)13 QName (org.alfresco.service.namespace.QName)12 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Node (org.alfresco.rest.api.model.Node)7 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)6 LinkedList (java.util.LinkedList)5 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)5 Map (java.util.Map)4 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)4 Date (java.util.Date)3 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 AuditEntry (org.alfresco.rest.api.model.AuditEntry)3 AuditQueryParameters (org.alfresco.service.cmr.audit.AuditQueryParameters)3 AuditQueryCallback (org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback)3