private SortedMap < Integer , List < AutocompleteResultsModel > > getCleanedAndSortedMapResults ( ConcurrentMap < String , List < Tuple < SearchResult , String > > > resultsMap , int maxTextLength ) { SortedMap < Integer , List < AutocompleteResultsModel > > prioritizedResultsMap = createAutocompletePriorityMap ( ) ; // Put the results into the map of <priority,list> for ( Map . Entry < String , List < Tuple < SearchResult , String > > > entry : resultsMap . entrySet ( ) ) { for ( Tuple < SearchResult , String > tupleSearchResult : entry . getValue ( ) ) { SearchResult searchResult = tupleSearchResult . getFirst ( ) ; List < String > resultTypes = searchResult . getType ( ) ; // If the search result doesn't have a type defined, use the undefined result type. if ( resultTypes . size ( ) == 0 ) { resultTypes = UNDEFINED_SEARCH_RESULT_TYPE ; } for ( String category : resultTypes ) { // Exclude the result if it is a result type that's in the ignore list. if ( ! autocompleteIgnoreResultTypes . contains ( category ) ) { int priority = calculatePriorityFromCategory ( category ) ; AutocompleteResultsModel result = new AutocompleteResultsModel ( cleanAndTrimString ( searchResult . getTitle ( ) , maxTextLength ) , cleanAndTrimString ( searchResult . getSummary ( ) , maxTextLength ) , tupleSearchResult . getSecond ( ) , category ) ; prioritizedResultsMap . get ( priority ) . add ( result ) ; } } } } return prioritizedResultsMap ; }
Return the search results in a sorted map based on priority of the search result type