target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void truncateFulltext_shouldNotAddPrefixAndSuffixToText() throws Exception { String original = "text"; List<String> truncated = SearchHelper.truncateFulltext(null, original, 200, true, true); Assert.assertFalse(truncated.isEmpty()); Assert.assertEquals("text", truncated.get(0)); }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void deleteUserPublicContributions_shouldDeleteAllUserPublicContentCorrectly() throws Exception { User user = DataManager.getInstance().getDao().getUser(2); Assert.assertNotNull(user); UserTools.deleteUserPublicContributions(user); Assert.assertNull(DataManager.getInstance().getDao().getComment(2)); List<CampaignRecordStatistic> statistics = DataManager.getInstance().getDao().getCampaignStatisticsForRecord("PI_1", null); Assert.assertEquals(1, statistics.size()); Assert.assertTrue(statistics.get(0).getReviewers().isEmpty()); Assert.assertFalse(statistics.get(0).getReviewers().contains(user)); }
|
public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().deleteCampaignStatisticsForUser(user); logger.debug("Deleted user from {} campaign statistics statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.deleteUserContributions(user); if (count > 0) { logger.debug("Deleted {} user contribution(s) via the '{}' module.", count, module.getName()); } } }
|
UserTools { public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().deleteCampaignStatisticsForUser(user); logger.debug("Deleted user from {} campaign statistics statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.deleteUserContributions(user); if (count > 0) { logger.debug("Deleted {} user contribution(s) via the '{}' module.", count, module.getName()); } } } }
|
UserTools { public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().deleteCampaignStatisticsForUser(user); logger.debug("Deleted user from {} campaign statistics statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.deleteUserContributions(user); if (count > 0) { logger.debug("Deleted {} user contribution(s) via the '{}' module.", count, module.getName()); } } } }
|
UserTools { public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().deleteCampaignStatisticsForUser(user); logger.debug("Deleted user from {} campaign statistics statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.deleteUserContributions(user); if (count > 0) { logger.debug("Deleted {} user contribution(s) via the '{}' module.", count, module.getName()); } } } static boolean deleteUser(User user); static int deleteUserGroupOwnedByUser(User owner); static int deleteBookmarkListsForUser(User owner); static int deleteSearchesForUser(User owner); static void deleteUserPublicContributions(User user); static boolean anonymizeUserPublicContributions(User user); static User checkAndCreateAnonymousUser(); }
|
UserTools { public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().deleteCampaignStatisticsForUser(user); logger.debug("Deleted user from {} campaign statistics statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.deleteUserContributions(user); if (count > 0) { logger.debug("Deleted {} user contribution(s) via the '{}' module.", count, module.getName()); } } } static boolean deleteUser(User user); static int deleteUserGroupOwnedByUser(User owner); static int deleteBookmarkListsForUser(User owner); static int deleteSearchesForUser(User owner); static void deleteUserPublicContributions(User user); static boolean anonymizeUserPublicContributions(User user); static User checkAndCreateAnonymousUser(); }
|
@Test public void truncateFulltext_shouldTruncateStringTo200CharsIfNoTermsAreGiven() throws Exception { String original = LOREM_IPSUM; List<String> truncated = SearchHelper.truncateFulltext(null, original, 200, true, true); Assert.assertFalse(truncated.isEmpty()); Assert.assertEquals(original.substring(0, 200), truncated.get(0)); }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void truncateFulltext_shouldTruncateStringTo200CharsIfNoTermHasBeenFound() throws Exception { String original = LOREM_IPSUM; String[] terms = { "boogers" }; { List<String> truncated = SearchHelper.truncateFulltext(new HashSet<>(Arrays.asList(terms)), original, 200, true, true); Assert.assertFalse(truncated.isEmpty()); Assert.assertEquals(original.substring(0, 200), truncated.get(0)); } { List<String> truncated = SearchHelper.truncateFulltext(new HashSet<>(Arrays.asList(terms)), original, 200, true, false); Assert.assertTrue(truncated.isEmpty()); } }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void truncateFulltext_shouldRemoveUnclosedHTMLTags() throws Exception { List<String> truncated = SearchHelper.truncateFulltext(null, "Hello <a href", 200, true, true); Assert.assertFalse(truncated.isEmpty()); Assert.assertEquals("Hello", truncated.get(0)); truncated = SearchHelper.truncateFulltext(null, "Hello <a href ...> and then <b", 200, true, true); Assert.assertEquals("Hello and then", truncated.get(0)); }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void truncateFulltext_shouldReturnMultipleMatchFragmentsCorrectly() throws Exception { String original = LOREM_IPSUM; String[] terms = { "in" }; List<String> truncated = SearchHelper.truncateFulltext(new HashSet<>(Arrays.asList(terms)), original, 50, false, true); Assert.assertEquals(7, truncated.size()); for (String fragment : truncated) { Assert.assertTrue(fragment.contains("<span class=\"search-list--highlight\">in</span>")); } }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void truncateFulltext_shouldReplaceLineBreaksWithSpaces() throws Exception { String original = "one<br>two<br>three"; String[] terms = { "two" }; List<String> truncated = SearchHelper.truncateFulltext(new HashSet<>(Arrays.asList(terms)), original, 50, false, true); Assert.assertEquals(1, truncated.size()); for (String fragment : truncated) { Assert.assertTrue(fragment.contains("<span class=\"search-list--highlight\">two</span>")); } }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void truncateFulltext_shouldHighlightMultiWordTermsWhileRemovingStopwords() throws Exception { String original = "funky beats"; String[] terms = { "two beats one" }; List<String> truncated = SearchHelper.truncateFulltext(new HashSet<>(Arrays.asList(terms)), original, 50, false, true); Assert.assertEquals(1, truncated.size()); for (String fragment : truncated) { Assert.assertTrue(fragment.contains("<span class=\"search-list--highlight\">beats</span>")); } }
|
public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly, boolean addFragmentIfNoMatches) { if (fulltext == null) { throw new IllegalArgumentException("fulltext may not be null"); } fulltext = Jsoup.parse(fulltext).text(); List<String> ret = new ArrayList<>(); String fulltextFragment = ""; if (searchTerms != null && !searchTerms.isEmpty()) { for (String searchTerm : searchTerms) { if (searchTerm.length() == 0) { continue; } searchTerm = SearchHelper.removeTruncation(searchTerm); if (searchTerm.contains(" ")) { for (String stopword : DataManager.getInstance().getConfiguration().getStopwords()) { if (searchTerm.startsWith(stopword + " ") || searchTerm.endsWith(" " + stopword)) { logger.trace("filtered out stopword '{}' from term '{}'", stopword, searchTerm); searchTerm = searchTerm.replace(stopword, "").trim(); } } } if (searchTerm.length() > 1 && searchTerm.endsWith("*") || searchTerm.endsWith("?")) { searchTerm = searchTerm.substring(0, searchTerm.length() - 1); } if (searchTerm.length() > 1 && searchTerm.charAt(0) == '*' || searchTerm.charAt(0) == '?') { searchTerm = searchTerm.substring(1); } if (searchTerm.contains("*") || searchTerm.contains("?")) { fulltextFragment += " "; break; } Matcher m = Pattern.compile(searchTerm.toLowerCase()).matcher(fulltext.toLowerCase()); int lastIndex = -1; while (m.find()) { if (lastIndex != -1 && m.start() <= lastIndex + searchTerm.length()) { continue; } int indexOfTerm = m.start(); lastIndex = m.start(); fulltextFragment = getTextFragmentRandomized(fulltext, searchTerm, indexOfTerm, targetFragmentLength); indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); int indexOfSpace = fulltextFragment.indexOf(' '); if (indexOfTerm > indexOfSpace && indexOfSpace >= 0) { fulltextFragment = fulltextFragment.substring(indexOfSpace, fulltextFragment.length()); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm < fulltextFragment.lastIndexOf(' ')) { fulltextFragment = fulltextFragment.substring(0, fulltextFragment.lastIndexOf(' ')); } indexOfTerm = fulltextFragment.toLowerCase().indexOf(searchTerm.toLowerCase()); if (indexOfTerm >= 0) { fulltextFragment = applyHighlightingToPhrase(fulltextFragment, searchTerm); fulltextFragment = replaceHighlightingPlaceholders(fulltextFragment); } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } ret.add(fulltextFragment); } if (firstMatchOnly) { break; } } } if (addFragmentIfNoMatches && StringUtils.isEmpty(fulltextFragment)) { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } else { if (fulltext.length() > 200) { fulltextFragment = fulltext.substring(0, 200); } else { fulltextFragment = fulltext; } if (StringUtils.isNotBlank(fulltextFragment)) { int lastIndexOfLT = fulltextFragment.lastIndexOf('<'); int lastIndexOfGT = fulltextFragment.lastIndexOf('>'); if (lastIndexOfLT != -1 && lastIndexOfLT > lastIndexOfGT) { fulltextFragment = fulltextFragment.substring(0, lastIndexOfLT).trim(); } fulltextFragment = fulltextFragment.replace("<br>", " "); ret.add(fulltextFragment); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void extractSearchTermsFromQuery_shouldExtractAllValuesFromQueryExceptFromNOTBlocks() throws Exception { Map<String, Set<String>> result = SearchHelper.extractSearchTermsFromQuery( "(MD_X:value1 OR MD_X:value2 OR (SUPERDEFAULT:value3 AND :value4:)) AND SUPERFULLTEXT:\"hello-world\" AND SUPERUGCTERMS:\"comment\" AND NOT(MD_Y:value_not)", null); Assert.assertEquals(4, result.size()); { Set<String> terms = result.get("MD_X"); Assert.assertNotNull(terms); Assert.assertEquals(2, terms.size()); Assert.assertTrue(terms.contains("value1")); Assert.assertTrue(terms.contains("value2")); } { Set<String> terms = result.get(SolrConstants.DEFAULT); Assert.assertNotNull(terms); Assert.assertEquals(2, terms.size()); Assert.assertTrue(terms.contains("value3")); Assert.assertTrue(terms.contains(":value4:")); } { Set<String> terms = result.get(SolrConstants.FULLTEXT); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("hello-world")); } { Set<String> terms = result.get(SolrConstants.UGCTERMS); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("comment")); } Assert.assertNull(result.get("MD_Y")); }
|
public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void extractSearchTermsFromQuery_shouldHandleMultiplePhrasesInQueryCorrectly() throws Exception { Map<String, Set<String>> result = SearchHelper.extractSearchTermsFromQuery("(MD_A:\"value1\" OR MD_B:\"value1\" OR MD_C:\"value2\" OR MD_D:\"value2\")", null); Assert.assertEquals(4, result.size()); { Set<String> terms = result.get("MD_A"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("value1")); } { Set<String> terms = result.get("MD_B"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("value1")); } { Set<String> terms = result.get("MD_C"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("value2")); } { Set<String> terms = result.get("MD_D"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("value2")); } }
|
public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void extractSearchTermsFromQuery_shouldSkipDiscriminatorValue() throws Exception { Map<String, Set<String>> result = SearchHelper.extractSearchTermsFromQuery("(MD_A:\"value1\" OR MD_B:\"value1\" OR MD_C:\"value2\" OR MD_D:\"value3\")", "value1"); Assert.assertEquals(2, result.size()); { Set<String> terms = result.get("MD_C"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("value2")); } { Set<String> terms = result.get("MD_D"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("value3")); } }
|
public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test(expected = IllegalArgumentException.class) public void extractSearchTermsFromQuery_shouldThrowIllegalArgumentExceptionIfQueryIsNull() throws Exception { SearchHelper.extractSearchTermsFromQuery(null, null); }
|
public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void anonymizeUserPublicContributions_shouldAnonymizeAllUserPublicContentCorrectly() throws Exception { User user = DataManager.getInstance().getDao().getUser(2); Assert.assertNotNull(user); Assert.assertTrue(UserTools.anonymizeUserPublicContributions(user)); Comment comment = DataManager.getInstance().getDao().getComment(2); Assert.assertNotNull(comment); Assert.assertNotEquals(user, comment.getOwner()); List<CampaignRecordStatistic> statistics = DataManager.getInstance().getDao().getCampaignStatisticsForRecord("PI_1", null); Assert.assertEquals(1, statistics.size()); Assert.assertEquals(1, statistics.get(0).getReviewers().size()); Assert.assertFalse(statistics.get(0).getReviewers().contains(user)); }
|
public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOwner(user, anon); logger.debug("{} comment(s) of user {} anonymized.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().changeCampaignStatisticContributors(user, anon); logger.debug("Anonymized user in {} campaign statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.moveUserContributions(user, anon); if (count > 0) { logger.debug("Anonymized {} user contribution(s) via the '{}' module.", count, module.getName()); } } return true; }
|
UserTools { public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOwner(user, anon); logger.debug("{} comment(s) of user {} anonymized.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().changeCampaignStatisticContributors(user, anon); logger.debug("Anonymized user in {} campaign statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.moveUserContributions(user, anon); if (count > 0) { logger.debug("Anonymized {} user contribution(s) via the '{}' module.", count, module.getName()); } } return true; } }
|
UserTools { public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOwner(user, anon); logger.debug("{} comment(s) of user {} anonymized.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().changeCampaignStatisticContributors(user, anon); logger.debug("Anonymized user in {} campaign statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.moveUserContributions(user, anon); if (count > 0) { logger.debug("Anonymized {} user contribution(s) via the '{}' module.", count, module.getName()); } } return true; } }
|
UserTools { public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOwner(user, anon); logger.debug("{} comment(s) of user {} anonymized.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().changeCampaignStatisticContributors(user, anon); logger.debug("Anonymized user in {} campaign statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.moveUserContributions(user, anon); if (count > 0) { logger.debug("Anonymized {} user contribution(s) via the '{}' module.", count, module.getName()); } } return true; } static boolean deleteUser(User user); static int deleteUserGroupOwnedByUser(User owner); static int deleteBookmarkListsForUser(User owner); static int deleteSearchesForUser(User owner); static void deleteUserPublicContributions(User user); static boolean anonymizeUserPublicContributions(User user); static User checkAndCreateAnonymousUser(); }
|
UserTools { public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOwner(user, anon); logger.debug("{} comment(s) of user {} anonymized.", comments, user.getId()); int statistics = DataManager.getInstance().getDao().changeCampaignStatisticContributors(user, anon); logger.debug("Anonymized user in {} campaign statistic(s).", statistics); for (IModule module : DataManager.getInstance().getModules()) { int count = module.moveUserContributions(user, anon); if (count > 0) { logger.debug("Anonymized {} user contribution(s) via the '{}' module.", count, module.getName()); } } return true; } static boolean deleteUser(User user); static int deleteUserGroupOwnedByUser(User owner); static int deleteBookmarkListsForUser(User owner); static int deleteSearchesForUser(User owner); static void deleteUserPublicContributions(User user); static boolean anonymizeUserPublicContributions(User user); static User checkAndCreateAnonymousUser(); }
|
@Test public void extractSearchTermsFromQuery_shouldNotRemoveTruncation() throws Exception { Map<String, Set<String>> result = SearchHelper.extractSearchTermsFromQuery("MD_A:*foo*", null); Assert.assertEquals(1, result.size()); { Set<String> terms = result.get("MD_A"); Assert.assertNotNull(terms); Assert.assertEquals(1, terms.size()); Assert.assertTrue(terms.contains("*foo*")); } }
|
public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue) { if (query == null) { throw new IllegalArgumentException("query may not be null"); } Map<String, Set<String>> ret = new HashMap<>(); Set<String> stopwords = DataManager.getInstance().getConfiguration().getStopwords(); if (StringUtils.isNotEmpty(discriminatorValue)) { stopwords.add(discriminatorValue); } Matcher mNot = patternNotBrackets.matcher(query); while (mNot.find()) { query = query.replace(query.substring(mNot.start(), mNot.end()), ""); } query = query.replace("(", "").replace(")", "").replace(" AND ", " ").replace(" OR ", " "); { String queryCopy = query; Matcher mPhrases = patternPhrase.matcher(queryCopy); while (mPhrases.find()) { String phrase = queryCopy.substring(mPhrases.start(), mPhrases.end()); String[] phraseSplit = phrase.split(":"); String field = phraseSplit[0]; if (SolrConstants.SUPERDEFAULT.equals(field)) { field = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(field)) { field = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(field)) { field = SolrConstants.UGCTERMS; } else if (field.endsWith(SolrConstants._UNTOKENIZED)) { field = field.substring(0, field.length() - SolrConstants._UNTOKENIZED.length()); } String phraseWoQuot = phraseSplit[1].replace("\"", ""); if (phraseWoQuot.length() > 0 && !stopwords.contains(phraseWoQuot)) { if (ret.get(field) == null) { ret.put(field, new HashSet<String>()); } logger.trace("phraseWoQuot: {}", phraseWoQuot); ret.get(field).add(phraseWoQuot); } query = query.replace(phrase, ""); } } String[] querySplit = query.split(SEARCH_TERM_SPLIT_REGEX); String currentField = null; for (String s : querySplit) { s = s.trim(); if (s.contains(":") && !s.startsWith(":")) { int split = s.indexOf(':'); String field = s.substring(0, split); String value = s.length() > split ? s.substring(split + 1) : null; if (StringUtils.isNotBlank(value)) { currentField = field; if (SolrConstants.SUPERDEFAULT.equals(currentField)) { currentField = SolrConstants.DEFAULT; } else if (SolrConstants.SUPERFULLTEXT.equals(currentField)) { currentField = SolrConstants.FULLTEXT; } else if (SolrConstants.SUPERUGCTERMS.equals(currentField)) { currentField = SolrConstants.UGCTERMS; } if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.replace("\"", ""); } if (value.length() > 0 && !stopwords.contains(value)) { if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(value); } } } else if (s.length() > 0 && !stopwords.contains(s)) { if (currentField == null) { currentField = SolrConstants.DEFAULT; } else if (currentField.endsWith(SolrConstants._UNTOKENIZED)) { currentField = currentField.substring(0, currentField.length() - SolrConstants._UNTOKENIZED.length()); } if (ret.get(currentField) == null) { ret.put(currentField, new HashSet<String>()); } ret.get(currentField).add(s); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateCollectionBlacklistFilterSuffix_shouldConstructSuffixCorrectly() throws Exception { String suffix = SearchHelper.generateCollectionBlacklistFilterSuffix(SolrConstants.DC); Assert.assertEquals(" -" + SolrConstants.DC + ":collection1 -" + SolrConstants.DC + ":collection2", suffix); }
|
protected static String generateCollectionBlacklistFilterSuffix(String field) { logger.debug("Generating blacklist suffix for field '{}'...", field); StringBuilder sbQuery = new StringBuilder(); List<String> list = DataManager.getInstance().getConfiguration().getCollectionBlacklist(field); if (list != null && !list.isEmpty()) { for (String s : list) { if (StringUtils.isNotBlank(s)) { sbQuery.append(" -").append(field).append(':').append(s.trim()); } } } return sbQuery.toString(); }
|
SearchHelper { protected static String generateCollectionBlacklistFilterSuffix(String field) { logger.debug("Generating blacklist suffix for field '{}'...", field); StringBuilder sbQuery = new StringBuilder(); List<String> list = DataManager.getInstance().getConfiguration().getCollectionBlacklist(field); if (list != null && !list.isEmpty()) { for (String s : list) { if (StringUtils.isNotBlank(s)) { sbQuery.append(" -").append(field).append(':').append(s.trim()); } } } return sbQuery.toString(); } }
|
SearchHelper { protected static String generateCollectionBlacklistFilterSuffix(String field) { logger.debug("Generating blacklist suffix for field '{}'...", field); StringBuilder sbQuery = new StringBuilder(); List<String> list = DataManager.getInstance().getConfiguration().getCollectionBlacklist(field); if (list != null && !list.isEmpty()) { for (String s : list) { if (StringUtils.isNotBlank(s)) { sbQuery.append(" -").append(field).append(':').append(s.trim()); } } } return sbQuery.toString(); } }
|
SearchHelper { protected static String generateCollectionBlacklistFilterSuffix(String field) { logger.debug("Generating blacklist suffix for field '{}'...", field); StringBuilder sbQuery = new StringBuilder(); List<String> list = DataManager.getInstance().getConfiguration().getCollectionBlacklist(field); if (list != null && !list.isEmpty()) { for (String s : list) { if (StringUtils.isNotBlank(s)) { sbQuery.append(" -").append(field).append(':').append(s.trim()); } } } return sbQuery.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { protected static String generateCollectionBlacklistFilterSuffix(String field) { logger.debug("Generating blacklist suffix for field '{}'...", field); StringBuilder sbQuery = new StringBuilder(); List<String> list = DataManager.getInstance().getConfiguration().getCollectionBlacklist(field); if (list != null && !list.isEmpty()) { for (String s : list) { if (StringUtils.isNotBlank(s)) { sbQuery.append(" -").append(field).append(':').append(s.trim()); } } } return sbQuery.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void checkCollectionInBlacklist_shouldMatchSimpleCollectionsCorrectly() throws Exception { { Set<String> blacklist = new HashSet<>(Collections.singletonList("a")); Assert.assertTrue(SearchHelper.checkCollectionInBlacklist("a", blacklist, ".")); Assert.assertFalse(SearchHelper.checkCollectionInBlacklist("z", blacklist, ".")); } { Set<String> blacklist = new HashSet<>(Collections.singletonList("a.b.c.d")); Assert.assertTrue(SearchHelper.checkCollectionInBlacklist("a.b.c.d", blacklist, ".")); Assert.assertFalse(SearchHelper.checkCollectionInBlacklist("a.b.c.z", blacklist, ".")); } }
|
protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void checkCollectionInBlacklist_shouldMatchSubcollectionsCorrectly() throws Exception { Set<String> blacklist = new HashSet<>(Collections.singletonList("a.b")); Assert.assertTrue(SearchHelper.checkCollectionInBlacklist("a.b.c.d", blacklist, ".")); Assert.assertFalse(SearchHelper.checkCollectionInBlacklist("a.z", blacklist, ".")); }
|
protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test(expected = IllegalArgumentException.class) public void checkCollectionInBlacklist_shouldThrowIllegalArgumentExceptionIfDcIsNull() throws Exception { SearchHelper.checkCollectionInBlacklist(null, new HashSet<>(Collections.singletonList("a*")), "."); }
|
protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test(expected = IllegalArgumentException.class) public void checkCollectionInBlacklist_shouldThrowIllegalArgumentExceptionIfBlacklistIsNull() throws Exception { SearchHelper.checkCollectionInBlacklist("a", null, "."); }
|
protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { protected static boolean checkCollectionInBlacklist(String dc, Set<String> blacklist, String splittingChar) { if (dc == null) { throw new IllegalArgumentException("dc may not be null"); } if (blacklist == null) { throw new IllegalArgumentException("blacklist may not be null"); } if (splittingChar == null) { throw new IllegalArgumentException("splittingChar may not be null"); } String collectionSplitRegex = new StringBuilder("[").append(splittingChar).append(']').toString(); String dcSplit[] = dc.split(collectionSplitRegex); StringBuilder sbDc = new StringBuilder(); for (String element : dcSplit) { if (sbDc.length() > 0) { sbDc.append(splittingChar); } sbDc.append(element); String current = sbDc.toString(); if (blacklist.contains(current)) { return true; } } return false; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getDiscriminatorFieldFilterSuffix_shouldConstructSubqueryCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setSubThemeDiscriminatorValue("val"); Assert.assertEquals(" +fie:val", SearchHelper.getDiscriminatorFieldFilterSuffix(nh, "fie")); }
|
public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getDiscriminatorFieldFilterSuffix_shouldReturnEmptyStringIfDiscriminatorValueIsEmptyOrHyphen() throws Exception { NavigationHelper nh = new NavigationHelper(); Assert.assertEquals("", SearchHelper.getDiscriminatorFieldFilterSuffix(nh, "fie")); nh.setSubThemeDiscriminatorValue("-"); Assert.assertEquals("", SearchHelper.getDiscriminatorFieldFilterSuffix(nh, "fie")); }
|
public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField) throws IndexUnreachableException { logger.trace("discriminatorField: {}", discriminatorField); if (StringUtils.isNotEmpty(discriminatorField) && nh != null) { String discriminatorValue = nh.getSubThemeDiscriminatorValue(); logger.trace("discriminatorValue: {}", discriminatorValue); if (StringUtils.isNotEmpty(discriminatorValue) && !"-".equals(discriminatorValue)) { StringBuilder sbSuffix = new StringBuilder(); sbSuffix.append(" +").append(discriminatorField).append(':').append(discriminatorValue); logger.trace("Discriminator field suffix: {}", sbSuffix.toString()); return sbSuffix.toString(); } } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void defacetifyField_shouldDefacetifyCorrectly() throws Exception { Assert.assertEquals(SolrConstants.DC, SearchHelper.defacetifyField(SolrConstants.FACET_DC)); Assert.assertEquals(SolrConstants.DOCSTRCT, SearchHelper.defacetifyField("FACET_DOCSTRCT")); Assert.assertEquals("MD_TITLE", SearchHelper.defacetifyField("FACET_TITLE")); }
|
public static String defacetifyField(String fieldName) { if (fieldName == null) { return null; } switch (fieldName) { case SolrConstants.FACET_DC: case "FACET_" + SolrConstants.DOCSTRCT: case "FACET_" + SolrConstants.DOCSTRCT_SUB: case "FACET_" + SolrConstants.DOCSTRCT_TOP: return fieldName.substring(6); default: if (fieldName.startsWith("FACET_")) { return fieldName.replace("FACET_", "MD_"); } return fieldName; } }
|
SearchHelper { public static String defacetifyField(String fieldName) { if (fieldName == null) { return null; } switch (fieldName) { case SolrConstants.FACET_DC: case "FACET_" + SolrConstants.DOCSTRCT: case "FACET_" + SolrConstants.DOCSTRCT_SUB: case "FACET_" + SolrConstants.DOCSTRCT_TOP: return fieldName.substring(6); default: if (fieldName.startsWith("FACET_")) { return fieldName.replace("FACET_", "MD_"); } return fieldName; } } }
|
SearchHelper { public static String defacetifyField(String fieldName) { if (fieldName == null) { return null; } switch (fieldName) { case SolrConstants.FACET_DC: case "FACET_" + SolrConstants.DOCSTRCT: case "FACET_" + SolrConstants.DOCSTRCT_SUB: case "FACET_" + SolrConstants.DOCSTRCT_TOP: return fieldName.substring(6); default: if (fieldName.startsWith("FACET_")) { return fieldName.replace("FACET_", "MD_"); } return fieldName; } } }
|
SearchHelper { public static String defacetifyField(String fieldName) { if (fieldName == null) { return null; } switch (fieldName) { case SolrConstants.FACET_DC: case "FACET_" + SolrConstants.DOCSTRCT: case "FACET_" + SolrConstants.DOCSTRCT_SUB: case "FACET_" + SolrConstants.DOCSTRCT_TOP: return fieldName.substring(6); default: if (fieldName.startsWith("FACET_")) { return fieldName.replace("FACET_", "MD_"); } return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String defacetifyField(String fieldName) { if (fieldName == null) { return null; } switch (fieldName) { case SolrConstants.FACET_DC: case "FACET_" + SolrConstants.DOCSTRCT: case "FACET_" + SolrConstants.DOCSTRCT_SUB: case "FACET_" + SolrConstants.DOCSTRCT_TOP: return fieldName.substring(6); default: if (fieldName.startsWith("FACET_")) { return fieldName.replace("FACET_", "MD_"); } return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void facetifyField_shouldFacetifyCorrectly() throws Exception { Assert.assertEquals(SolrConstants.FACET_DC, SearchHelper.facetifyField(SolrConstants.DC)); Assert.assertEquals("FACET_DOCSTRCT", SearchHelper.facetifyField(SolrConstants.DOCSTRCT)); Assert.assertEquals("FACET_TITLE", SearchHelper.facetifyField("MD_TITLE_UNTOKENIZED")); }
|
public static String facetifyField(String fieldName) { return adaptField(fieldName, "FACET_"); }
|
SearchHelper { public static String facetifyField(String fieldName) { return adaptField(fieldName, "FACET_"); } }
|
SearchHelper { public static String facetifyField(String fieldName) { return adaptField(fieldName, "FACET_"); } }
|
SearchHelper { public static String facetifyField(String fieldName) { return adaptField(fieldName, "FACET_"); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String facetifyField(String fieldName) { return adaptField(fieldName, "FACET_"); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getMemberCount_shouldCountCorrectly() throws Exception { UserGroup ug = DataManager.getInstance().getDao().getUserGroup(1); Assert.assertNotNull(ug); Assert.assertEquals(1, ug.getMemberCount()); }
|
public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); }
|
UserGroup implements ILicensee, Serializable { public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); } }
|
UserGroup implements ILicensee, Serializable { public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); } }
|
UserGroup implements ILicensee, Serializable { public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean changeMemberRole(User user, Role role); boolean removeMember(User user); @Override boolean hasLicense(String licenseName, String privilegeName, String pi); boolean hasUserPrivilege(String privilegeName); @Override boolean addLicense(License license); @Override boolean removeLicense(License license); Long getId(); void setId(Long id); @Override String getName(); void setName(String name); String getDescription(); void setDescription(String description); User getOwner(); void setOwner(User owner); boolean isActive(); void setActive(boolean active); @Override List<License> getLicenses(); void setLicenses(List<License> licenses); List<License> getLicenses(boolean core); boolean isHasMembers(); long getMemberCount(); List<UserRole> getMemberships(); Set<User> getMembers(); Set<User> getMembersAndOwner(); @Override String toString(); }
|
UserGroup implements ILicensee, Serializable { public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean changeMemberRole(User user, Role role); boolean removeMember(User user); @Override boolean hasLicense(String licenseName, String privilegeName, String pi); boolean hasUserPrivilege(String privilegeName); @Override boolean addLicense(License license); @Override boolean removeLicense(License license); Long getId(); void setId(Long id); @Override String getName(); void setName(String name); String getDescription(); void setDescription(String description); User getOwner(); void setOwner(User owner); boolean isActive(); void setActive(boolean active); @Override List<License> getLicenses(); void setLicenses(List<License> licenses); List<License> getLicenses(boolean core); boolean isHasMembers(); long getMemberCount(); List<UserRole> getMemberships(); Set<User> getMembers(); Set<User> getMembersAndOwner(); @Override String toString(); }
|
@Test public void replaceParameters_shouldReplaceParametersCorrectly() throws Exception { Assert.assertEquals("one two three", ViewerResourceBundle.replaceParameters("{0} {1} {2}", "one", "two", "three")); }
|
static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } return ret; }
|
ViewerResourceBundle extends ResourceBundle { static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } return ret; } }
|
ViewerResourceBundle extends ResourceBundle { static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } return ret; } ViewerResourceBundle(); }
|
ViewerResourceBundle extends ResourceBundle { static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } return ret; } ViewerResourceBundle(); static Locale getDefaultLocale(); static String getTranslation(final String key, Locale locale); static String getTranslationWithParameters(final String key, final Locale locale, final String... params); static String getTranslation(final String key, Locale locale, boolean useFallback); static String cleanUpTranslation(String value); static List<String> getMessagesValues(Locale locale, String keyPrefix); @Override Enumeration<String> getKeys(); static List<Locale> getAllLocales(); static List<Locale> getFacesLocales(); static IMetadataValue getTranslations(String key); static IMetadataValue getTranslations(String key, boolean allowKeyAsTranslation); static List<Locale> getLocalesFromFacesConfig(); static List<Locale> getLocalesFromFile(Path facesConfigPath); }
|
ViewerResourceBundle extends ResourceBundle { static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } return ret; } ViewerResourceBundle(); static Locale getDefaultLocale(); static String getTranslation(final String key, Locale locale); static String getTranslationWithParameters(final String key, final Locale locale, final String... params); static String getTranslation(final String key, Locale locale, boolean useFallback); static String cleanUpTranslation(String value); static List<String> getMessagesValues(Locale locale, String keyPrefix); @Override Enumeration<String> getKeys(); static List<Locale> getAllLocales(); static List<Locale> getFacesLocales(); static IMetadataValue getTranslations(String key); static IMetadataValue getTranslations(String key, boolean allowKeyAsTranslation); static List<Locale> getLocalesFromFacesConfig(); static List<Locale> getLocalesFromFile(Path facesConfigPath); static Thread backgroundThread; }
|
@Test public void facetifyList_shouldFacetifyCorrectly() throws Exception { List<String> result = SearchHelper.facetifyList(Arrays.asList(new String[] { SolrConstants.DC, "MD_TITLE_UNTOKENIZED" })); Assert.assertEquals(2, result.size()); Assert.assertEquals(SolrConstants.FACET_DC, result.get(0)); Assert.assertEquals("FACET_TITLE", result.get(1)); }
|
public static List<String> facetifyList(List<String> sourceList) { if (sourceList == null) { return null; } List<String> ret = new ArrayList<>(sourceList.size()); for (String s : sourceList) { String fieldName = facetifyField(s); if (fieldName != null) { ret.add(fieldName); } } return ret; }
|
SearchHelper { public static List<String> facetifyList(List<String> sourceList) { if (sourceList == null) { return null; } List<String> ret = new ArrayList<>(sourceList.size()); for (String s : sourceList) { String fieldName = facetifyField(s); if (fieldName != null) { ret.add(fieldName); } } return ret; } }
|
SearchHelper { public static List<String> facetifyList(List<String> sourceList) { if (sourceList == null) { return null; } List<String> ret = new ArrayList<>(sourceList.size()); for (String s : sourceList) { String fieldName = facetifyField(s); if (fieldName != null) { ret.add(fieldName); } } return ret; } }
|
SearchHelper { public static List<String> facetifyList(List<String> sourceList) { if (sourceList == null) { return null; } List<String> ret = new ArrayList<>(sourceList.size()); for (String s : sourceList) { String fieldName = facetifyField(s); if (fieldName != null) { ret.add(fieldName); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<String> facetifyList(List<String> sourceList) { if (sourceList == null) { return null; } List<String> ret = new ArrayList<>(sourceList.size()); for (String s : sourceList) { String fieldName = facetifyField(s); if (fieldName != null) { ret.add(fieldName); } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void sortifyField_shouldSortifyCorrectly() throws Exception { Assert.assertEquals("SORT_DC", SearchHelper.sortifyField(SolrConstants.DC)); Assert.assertEquals("SORT_DOCSTRCT", SearchHelper.sortifyField(SolrConstants.DOCSTRCT)); Assert.assertEquals("SORT_TITLE", SearchHelper.sortifyField("MD_TITLE_UNTOKENIZED")); }
|
public static String sortifyField(String fieldName) { return adaptField(fieldName, "SORT_"); }
|
SearchHelper { public static String sortifyField(String fieldName) { return adaptField(fieldName, "SORT_"); } }
|
SearchHelper { public static String sortifyField(String fieldName) { return adaptField(fieldName, "SORT_"); } }
|
SearchHelper { public static String sortifyField(String fieldName) { return adaptField(fieldName, "SORT_"); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String sortifyField(String fieldName) { return adaptField(fieldName, "SORT_"); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void normalizeField_shouldNormalizeCorrectly() throws Exception { Assert.assertEquals("MD_FOO", SearchHelper.normalizeField("MD_FOO_UNTOKENIZED")); }
|
public static String normalizeField(String fieldName) { return adaptField(fieldName, null); }
|
SearchHelper { public static String normalizeField(String fieldName) { return adaptField(fieldName, null); } }
|
SearchHelper { public static String normalizeField(String fieldName) { return adaptField(fieldName, null); } }
|
SearchHelper { public static String normalizeField(String fieldName) { return adaptField(fieldName, null); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String normalizeField(String fieldName) { return adaptField(fieldName, null); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void adaptField_shouldApplyPrefixCorrectly() throws Exception { Assert.assertEquals("SORT_DC", SearchHelper.adaptField(SolrConstants.DC, "SORT_")); Assert.assertEquals("SORT_FOO", SearchHelper.adaptField("MD_FOO", "SORT_")); }
|
static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void adaptField_shouldNotApplyPrefixToRegularFieldsIfEmpty() throws Exception { Assert.assertEquals("MD_FOO", SearchHelper.adaptField("MD_FOO", "")); }
|
static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void adaptField_shouldRemoveUntokenizedCorrectly() throws Exception { Assert.assertEquals("SORT_FOO", SearchHelper.adaptField("MD_FOO_UNTOKENIZED", "SORT_")); }
|
static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { static String adaptField(String fieldName, String prefix) { if (fieldName == null) { return null; } if (prefix == null) { prefix = ""; } switch (fieldName) { case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.DOCSTRCT_SUB: case SolrConstants.DOCSTRCT_TOP: return prefix + fieldName; default: if (StringUtils.isNotEmpty(prefix)) { if (fieldName.startsWith("MD_")) { fieldName = fieldName.replace("MD_", prefix); } else if (fieldName.startsWith("MD2_")) { fieldName = fieldName.replace("MD2_", prefix); } else if (fieldName.startsWith("BOOL_")) { fieldName = fieldName.replace("BOOL_", prefix); } else if (fieldName.startsWith("SORT_")) { fieldName = fieldName.replace("SORT_", prefix); } } fieldName = fieldName.replace(SolrConstants._UNTOKENIZED, ""); return fieldName; } } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getAllSuffixes_shouldAddStaticSuffix() throws Exception { String suffix = SearchHelper.getAllSuffixes(null, true, false); Assert.assertNotNull(suffix); Assert.assertTrue(suffix.contains(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())); }
|
public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getAllSuffixes_shouldNotAddStaticSuffixIfNotRequested() throws Exception { String suffix = SearchHelper.getAllSuffixes(null, false, false); Assert.assertNotNull(suffix); Assert.assertFalse(suffix.contains(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())); }
|
public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getAllSuffixes_shouldAddCollectionBlacklistSuffix() throws Exception { String suffix = SearchHelper.getAllSuffixes(); Assert.assertNotNull(suffix); Assert.assertTrue(suffix.contains(" -" + SolrConstants.DC + ":collection1 -" + SolrConstants.DC + ":collection2")); }
|
public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix, boolean addCollectionBlacklistSuffix) throws IndexUnreachableException { StringBuilder sbSuffix = new StringBuilder(""); if (addStaticQuerySuffix && StringUtils.isNotBlank(DataManager.getInstance().getConfiguration().getStaticQuerySuffix())) { String staticSuffix = DataManager.getInstance().getConfiguration().getStaticQuerySuffix(); if (staticSuffix.charAt(0) != ' ') { sbSuffix.append(' '); } sbSuffix.append(staticSuffix); } if (addCollectionBlacklistSuffix) { sbSuffix.append(getCollectionBlacklistFilterSuffix(SolrConstants.DC)); } String filterQuerySuffix = getFilterQuerySuffix(request); if (filterQuerySuffix != null) { sbSuffix.append(filterQuerySuffix); } return sbSuffix.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateExpandQuery_shouldGenerateQueryCorrectly() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants.DEFAULT, SolrConstants.FULLTEXT, SolrConstants.NORMDATATERMS, SolrConstants.UGCTERMS, SolrConstants.CMS_TEXT_ALL }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put(SolrConstants.DEFAULT, new HashSet<>(Arrays.asList(new String[] { "one", "two" }))); searchTerms.put(SolrConstants.FULLTEXT, new HashSet<>(Arrays.asList(new String[] { "two", "three" }))); searchTerms.put(SolrConstants.NORMDATATERMS, new HashSet<>(Arrays.asList(new String[] { "four", "five" }))); searchTerms.put(SolrConstants.UGCTERMS, new HashSet<>(Arrays.asList(new String[] { "six" }))); searchTerms.put(SolrConstants.CMS_TEXT_ALL, new HashSet<>(Arrays.asList(new String[] { "seven" }))); Assert.assertEquals( " +(" + SolrConstants.DEFAULT + ":(one OR two) OR " + SolrConstants.FULLTEXT + ":(two OR three) OR " + SolrConstants.NORMDATATERMS + ":(four OR five) OR " + SolrConstants.UGCTERMS + ":six OR " + SolrConstants.CMS_TEXT_ALL + ":seven)", SearchHelper.generateExpandQuery(fields, searchTerms, false)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getMembersAndOwner_shouldReturnAllMembersAndOwner() throws Exception { UserGroup ug = DataManager.getInstance().getDao().getUserGroup(1); Assert.assertNotNull(ug); Assert.assertEquals(2, ug.getMembersAndOwner().size()); }
|
public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; }
|
UserGroup implements ILicensee, Serializable { public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; } }
|
UserGroup implements ILicensee, Serializable { public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; } }
|
UserGroup implements ILicensee, Serializable { public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean changeMemberRole(User user, Role role); boolean removeMember(User user); @Override boolean hasLicense(String licenseName, String privilegeName, String pi); boolean hasUserPrivilege(String privilegeName); @Override boolean addLicense(License license); @Override boolean removeLicense(License license); Long getId(); void setId(Long id); @Override String getName(); void setName(String name); String getDescription(); void setDescription(String description); User getOwner(); void setOwner(User owner); boolean isActive(); void setActive(boolean active); @Override List<License> getLicenses(); void setLicenses(List<License> licenses); List<License> getLicenses(boolean core); boolean isHasMembers(); long getMemberCount(); List<UserRole> getMemberships(); Set<User> getMembers(); Set<User> getMembersAndOwner(); @Override String toString(); }
|
UserGroup implements ILicensee, Serializable { public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean changeMemberRole(User user, Role role); boolean removeMember(User user); @Override boolean hasLicense(String licenseName, String privilegeName, String pi); boolean hasUserPrivilege(String privilegeName); @Override boolean addLicense(License license); @Override boolean removeLicense(License license); Long getId(); void setId(Long id); @Override String getName(); void setName(String name); String getDescription(); void setDescription(String description); User getOwner(); void setOwner(User owner); boolean isActive(); void setActive(boolean active); @Override List<License> getLicenses(); void setLicenses(List<License> licenses); List<License> getLicenses(boolean core); boolean isHasMembers(); long getMemberCount(); List<UserRole> getMemberships(); Set<User> getMembers(); Set<User> getMembersAndOwner(); @Override String toString(); }
|
@Test public void generateExpandQuery_shouldReturnEmptyStringIfNoFieldsMatch() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants.DEFAULT, SolrConstants.FULLTEXT, SolrConstants.NORMDATATERMS, SolrConstants.UGCTERMS, SolrConstants.CMS_TEXT_ALL }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put("MD_TITLE", new HashSet<>(Arrays.asList(new String[] { "one", "two" }))); Assert.assertEquals("", SearchHelper.generateExpandQuery(fields, searchTerms, false)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateExpandQuery_shouldSkipReservedFields() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants.DEFAULT, SolrConstants.FULLTEXT, SolrConstants.NORMDATATERMS, SolrConstants.UGCTERMS, SolrConstants.CMS_TEXT_ALL, SolrConstants.PI_TOPSTRUCT, SolrConstants.PI_ANCHOR, SolrConstants.DC, SolrConstants.DOCSTRCT }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put(SolrConstants.DEFAULT, new HashSet<>(Arrays.asList(new String[] { "one", "two" }))); searchTerms.put(SolrConstants.FULLTEXT, new HashSet<>(Arrays.asList(new String[] { "two", "three" }))); searchTerms.put(SolrConstants.NORMDATATERMS, new HashSet<>(Arrays.asList(new String[] { "four", "five" }))); searchTerms.put(SolrConstants.UGCTERMS, new HashSet<>(Arrays.asList(new String[] { "six" }))); searchTerms.put(SolrConstants.CMS_TEXT_ALL, new HashSet<>(Arrays.asList(new String[] { "seven" }))); searchTerms.put(SolrConstants.PI_ANCHOR, new HashSet<>(Arrays.asList(new String[] { "eight" }))); searchTerms.put(SolrConstants.PI_TOPSTRUCT, new HashSet<>(Arrays.asList(new String[] { "nine" }))); Assert.assertEquals( " +(" + SolrConstants.DEFAULT + ":(one OR two) OR " + SolrConstants.FULLTEXT + ":(two OR three) OR " + SolrConstants.NORMDATATERMS + ":(four OR five) OR " + SolrConstants.UGCTERMS + ":six OR " + SolrConstants.CMS_TEXT_ALL + ":seven)", SearchHelper.generateExpandQuery(fields, searchTerms, false)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateExpandQuery_shouldNotEscapeAsterisks() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants._CALENDAR_DAY }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put(SolrConstants._CALENDAR_DAY, new HashSet<>(Arrays.asList(new String[] { "*", }))); Assert.assertEquals(" +(YEARMONTHDAY:*)", SearchHelper.generateExpandQuery(fields, searchTerms, false)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateExpandQuery_shouldNotEscapeTruncation() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants.DEFAULT }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put(SolrConstants.DEFAULT, new HashSet<>(Arrays.asList(new String[] { "foo*", }))); Assert.assertEquals(" +(DEFAULT:foo*)", SearchHelper.generateExpandQuery(fields, searchTerms, false)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateExpandQuery_shouldEscapeReservedCharacters() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants.DEFAULT }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put(SolrConstants.DEFAULT, new HashSet<>(Arrays.asList(new String[] { "[one]", ":two:" }))); Assert.assertEquals(" +(DEFAULT:(\\[one\\] OR \\:two\\:))", SearchHelper.generateExpandQuery(fields, searchTerms, false)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateExpandQuery_shouldAddQuotationMarksIfPhraseSearchIsTrue() throws Exception { List<String> fields = Arrays.asList(new String[] { SolrConstants.DEFAULT }); Map<String, Set<String>> searchTerms = new HashMap<>(); searchTerms.put(SolrConstants.DEFAULT, new HashSet<>(Arrays.asList(new String[] { "one two three" }))); Assert.assertEquals(" +(DEFAULT:\"one\\ two\\ three\")", SearchHelper.generateExpandQuery(fields, searchTerms, true)); }
|
public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch) { logger.trace("generateExpandQuery"); StringBuilder sbOuter = new StringBuilder(); if (!searchTerms.isEmpty()) { logger.trace("fields: {}", fields.toString()); logger.trace("searchTerms: {}", searchTerms.toString()); boolean moreThanOne = false; for (String field : fields) { switch (field) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: continue; default: if (field.startsWith(SolrConstants.GROUPID_)) { continue; } } Set<String> terms = searchTerms.get(field); if (terms == null || terms.isEmpty()) { continue; } if (sbOuter.length() == 0) { sbOuter.append(" +("); } if (moreThanOne) { sbOuter.append(" OR "); } StringBuilder sbInner = new StringBuilder(); boolean multipleTerms = false; for (String term : terms) { if (sbInner.length() > 0) { sbInner.append(" OR "); multipleTerms = true; } if (!"*".equals(term)) { term = ClientUtils.escapeQueryChars(term); term = term.replace("\\*", "*"); if (phraseSearch) { term = "\"" + term + "\""; } } sbInner.append(term); } sbOuter.append(field).append(":"); if (multipleTerms) { sbOuter.append('('); } sbOuter.append(sbInner.toString()); if (multipleTerms) { sbOuter.append(')'); } moreThanOne = true; } if (sbOuter.length() > 0) { sbOuter.append(')'); } } return sbOuter.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateAdvancedExpandQuery_shouldGenerateQueryCorrectly() throws Exception { List<SearchQueryGroup> groups = new ArrayList<>(2); { SearchQueryGroup group = new SearchQueryGroup(null, 2); group.setOperator(SearchQueryGroupOperator.AND); group.getQueryItems().get(0).setOperator(SearchItemOperator.AND); group.getQueryItems().get(0).setField("MD_FIELD"); group.getQueryItems().get(0).setValue("val1"); group.getQueryItems().get(1).setOperator(SearchItemOperator.AND); group.getQueryItems().get(1).setField(SolrConstants.TITLE); group.getQueryItems().get(1).setValue("foo bar"); groups.add(group); } { SearchQueryGroup group = new SearchQueryGroup(null, 2); group.setOperator(SearchQueryGroupOperator.OR); group.getQueryItems().get(0).setField("MD_FIELD"); group.getQueryItems().get(0).setValue("val2"); group.getQueryItems().get(1).setOperator(SearchItemOperator.OR); group.getQueryItems().get(1).setField("MD_SHELFMARK"); group.getQueryItems().get(1).setValue("bla blup"); groups.add(group); } String result = SearchHelper.generateAdvancedExpandQuery(groups, 0); Assert.assertEquals(" +((MD_FIELD:val1 AND MD_TITLE:(foo AND bar)) AND (MD_FIELD:val2 OR MD_SHELFMARK:(bla OR blup)))", result); }
|
public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateAdvancedExpandQuery_shouldSkipReservedFields() throws Exception { List<SearchQueryGroup> groups = new ArrayList<>(1); SearchQueryGroup group = new SearchQueryGroup(null, 6); group.setOperator(SearchQueryGroupOperator.AND); group.getQueryItems().get(0).setOperator(SearchItemOperator.AND); group.getQueryItems().get(0).setField(SolrConstants.DOCSTRCT); group.getQueryItems().get(0).setValue("Monograph"); group.getQueryItems().get(1).setOperator(SearchItemOperator.AND); group.getQueryItems().get(1).setField(SolrConstants.PI_TOPSTRUCT); group.getQueryItems().get(1).setValue("PPN123"); group.getQueryItems().get(2).setOperator(SearchItemOperator.AND); group.getQueryItems().get(2).setField(SolrConstants.DC); group.getQueryItems().get(2).setValue("co1"); group.getQueryItems().get(3).setOperator(SearchItemOperator.AND); group.getQueryItems().get(3).setField("MD_FIELD"); group.getQueryItems().get(3).setValue("val"); group.getQueryItems().get(4).setOperator(SearchItemOperator.AND); group.getQueryItems().get(4).setField(SolrConstants.BOOKMARKS); group.getQueryItems().get(4).setValue("bookmarklist"); group.getQueryItems().get(5).setOperator(SearchItemOperator.AND); group.getQueryItems().get(5).setField(SolrConstants.PI_ANCHOR); group.getQueryItems().get(5).setValue("PPN000"); groups.add(group); String result = SearchHelper.generateAdvancedExpandQuery(groups, 0); Assert.assertEquals(" +((MD_FIELD:val))", result); }
|
public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator) { logger.trace("generateAdvancedExpandQuery"); if (groups == null || groups.isEmpty()) { return ""; } StringBuilder sbOuter = new StringBuilder(); for (SearchQueryGroup group : groups) { StringBuilder sbGroup = new StringBuilder(); boolean orMode = false; for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } switch (item.getField()) { case SolrConstants.FULLTEXT: case SolrConstants.UGCTERMS: case SearchQueryItem.ADVANCED_SEARCH_ALL_FIELDS: orMode = true; break; } } for (SearchQueryItem item : group.getQueryItems()) { if (item.getField() == null) { continue; } logger.trace("item field: " + item.getField()); switch (item.getField()) { case SolrConstants.PI_TOPSTRUCT: case SolrConstants.PI_ANCHOR: case SolrConstants.DC: case SolrConstants.DOCSTRCT: case SolrConstants.BOOKMARKS: continue; default: if (item.getField().startsWith(SolrConstants.GROUPID_)) { continue; } } String itemQuery = item.generateQuery(new HashSet<String>(), false); if (StringUtils.isNotEmpty(itemQuery)) { if (sbGroup.length() > 0) { if (orMode) { sbGroup.append(" OR "); } else { sbGroup.append(' ').append(group.getOperator().name()).append(' '); } } sbGroup.append(itemQuery); } } if (sbGroup.length() > 0) { if (sbOuter.length() > 0) { switch (advancedSearchGroupOperator) { case 0: sbOuter.append(" AND "); break; case 1: sbOuter.append(" OR "); break; default: sbOuter.append(" OR "); break; } } sbOuter.append('(').append(sbGroup).append(')'); } } if (sbOuter.length() > 0) { return " +(" + sbOuter.toString() + ')'; } return ""; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void exportSearchAsExcel_shouldCreateExcelWorkbookCorrectly() throws Exception { String query = "DOCSTRCT:monograph AND MD_YEARPUBLISH:18*"; SXSSFWorkbook wb = SearchHelper.exportSearchAsExcel(query, query, Collections.singletonList(new StringPair("SORT_YEARPUBLISH", "asc")), null, null, new HashMap<String, Set<String>>(), Locale.ENGLISH, false, null); String[] cellValues0 = new String[] { "Persistent identifier", "13473260X", "AC08311001", "AC03343066", "PPN193910888" }; String[] cellValues1 = new String[] { "Label", "Gedichte", "Linz und seine Umgebungen", "Das Bücherwesen im Mittelalter", "Das Stilisieren der Thier- und Menschen-Formen" }; Assert.assertNotNull(wb); Assert.assertEquals(1, wb.getNumberOfSheets()); SXSSFSheet sheet = wb.getSheetAt(0); Assert.assertEquals(6, sheet.getPhysicalNumberOfRows()); { SXSSFRow row = sheet.getRow(0); Assert.assertEquals(2, row.getPhysicalNumberOfCells()); Assert.assertEquals("Query:", row.getCell(0).getRichStringCellValue().toString()); Assert.assertEquals(query, row.getCell(1).getRichStringCellValue().toString()); } for (int i = 1; i < 4; ++i) { SXSSFRow row = sheet.getRow(i); Assert.assertEquals(2, row.getPhysicalNumberOfCells()); Assert.assertEquals(cellValues0[i - 1], row.getCell(0).getRichStringCellValue().toString()); Assert.assertEquals(cellValues1[i - 1], row.getCell(1).getRichStringCellValue().toString()); } }
|
public static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request) throws IndexUnreachableException, DAOException, PresentationException, ViewerConfigurationException { SXSSFWorkbook wb = new SXSSFWorkbook(25); List<SXSSFSheet> sheets = new ArrayList<>(); int currentSheetIndex = 0; SXSSFSheet currentSheet = wb.createSheet("intranda_viewer_search"); CellStyle styleBold = wb.createCellStyle(); Font font2 = wb.createFont(); font2.setFontHeightInPoints((short) 10); font2.setBold(true); styleBold.setFont(font2); int currentRowIndex = 0; int currentCellIndex = 0; { SXSSFRow row = currentSheet.createRow(currentRowIndex++); SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString("Query:")); cell = row.createCell(currentCellIndex++); cell.setCellValue(new XSSFRichTextString(exportQuery)); currentCellIndex = 0; } SXSSFRow row = currentSheet.createRow(currentRowIndex++); for (String field : DataManager.getInstance().getConfiguration().getSearchExcelExportFields()) { SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString(ViewerResourceBundle.getTranslation(field, locale))); } List<String> exportFields = DataManager.getInstance().getConfiguration().getSearchExcelExportFields(); long totalHits = DataManager.getInstance().getSearchIndex().getHitCount(finalQuery, filterQueries); int batchSize = 100; int totalBatches = (int) Math.ceil((double) totalHits / batchSize); for (int i = 0; i < totalBatches; ++i) { int first = i * batchSize; int max = first + batchSize - 1; if (max > totalHits) { max = (int) (totalHits - 1); batchSize = (int) (totalHits - first); } logger.trace("Fetching search hits {}-{} out of {}", first, max, totalHits); List<SearchHit> batch; if (aggregateHits) { batch = searchWithAggregation(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale); } else { batch = searchWithFulltext(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale, request); } for (SearchHit hit : batch) { currentCellIndex = 0; row = currentSheet.createRow(currentRowIndex++); for (String field : exportFields) { SXSSFCell cell = row.createCell(currentCellIndex++); String value = hit.getExportMetadata().get(field); cell.setCellValue(new XSSFRichTextString(value != null ? value : "")); } } } return wb; }
|
SearchHelper { public static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request) throws IndexUnreachableException, DAOException, PresentationException, ViewerConfigurationException { SXSSFWorkbook wb = new SXSSFWorkbook(25); List<SXSSFSheet> sheets = new ArrayList<>(); int currentSheetIndex = 0; SXSSFSheet currentSheet = wb.createSheet("intranda_viewer_search"); CellStyle styleBold = wb.createCellStyle(); Font font2 = wb.createFont(); font2.setFontHeightInPoints((short) 10); font2.setBold(true); styleBold.setFont(font2); int currentRowIndex = 0; int currentCellIndex = 0; { SXSSFRow row = currentSheet.createRow(currentRowIndex++); SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString("Query:")); cell = row.createCell(currentCellIndex++); cell.setCellValue(new XSSFRichTextString(exportQuery)); currentCellIndex = 0; } SXSSFRow row = currentSheet.createRow(currentRowIndex++); for (String field : DataManager.getInstance().getConfiguration().getSearchExcelExportFields()) { SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString(ViewerResourceBundle.getTranslation(field, locale))); } List<String> exportFields = DataManager.getInstance().getConfiguration().getSearchExcelExportFields(); long totalHits = DataManager.getInstance().getSearchIndex().getHitCount(finalQuery, filterQueries); int batchSize = 100; int totalBatches = (int) Math.ceil((double) totalHits / batchSize); for (int i = 0; i < totalBatches; ++i) { int first = i * batchSize; int max = first + batchSize - 1; if (max > totalHits) { max = (int) (totalHits - 1); batchSize = (int) (totalHits - first); } logger.trace("Fetching search hits {}-{} out of {}", first, max, totalHits); List<SearchHit> batch; if (aggregateHits) { batch = searchWithAggregation(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale); } else { batch = searchWithFulltext(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale, request); } for (SearchHit hit : batch) { currentCellIndex = 0; row = currentSheet.createRow(currentRowIndex++); for (String field : exportFields) { SXSSFCell cell = row.createCell(currentCellIndex++); String value = hit.getExportMetadata().get(field); cell.setCellValue(new XSSFRichTextString(value != null ? value : "")); } } } return wb; } }
|
SearchHelper { public static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request) throws IndexUnreachableException, DAOException, PresentationException, ViewerConfigurationException { SXSSFWorkbook wb = new SXSSFWorkbook(25); List<SXSSFSheet> sheets = new ArrayList<>(); int currentSheetIndex = 0; SXSSFSheet currentSheet = wb.createSheet("intranda_viewer_search"); CellStyle styleBold = wb.createCellStyle(); Font font2 = wb.createFont(); font2.setFontHeightInPoints((short) 10); font2.setBold(true); styleBold.setFont(font2); int currentRowIndex = 0; int currentCellIndex = 0; { SXSSFRow row = currentSheet.createRow(currentRowIndex++); SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString("Query:")); cell = row.createCell(currentCellIndex++); cell.setCellValue(new XSSFRichTextString(exportQuery)); currentCellIndex = 0; } SXSSFRow row = currentSheet.createRow(currentRowIndex++); for (String field : DataManager.getInstance().getConfiguration().getSearchExcelExportFields()) { SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString(ViewerResourceBundle.getTranslation(field, locale))); } List<String> exportFields = DataManager.getInstance().getConfiguration().getSearchExcelExportFields(); long totalHits = DataManager.getInstance().getSearchIndex().getHitCount(finalQuery, filterQueries); int batchSize = 100; int totalBatches = (int) Math.ceil((double) totalHits / batchSize); for (int i = 0; i < totalBatches; ++i) { int first = i * batchSize; int max = first + batchSize - 1; if (max > totalHits) { max = (int) (totalHits - 1); batchSize = (int) (totalHits - first); } logger.trace("Fetching search hits {}-{} out of {}", first, max, totalHits); List<SearchHit> batch; if (aggregateHits) { batch = searchWithAggregation(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale); } else { batch = searchWithFulltext(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale, request); } for (SearchHit hit : batch) { currentCellIndex = 0; row = currentSheet.createRow(currentRowIndex++); for (String field : exportFields) { SXSSFCell cell = row.createCell(currentCellIndex++); String value = hit.getExportMetadata().get(field); cell.setCellValue(new XSSFRichTextString(value != null ? value : "")); } } } return wb; } }
|
SearchHelper { public static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request) throws IndexUnreachableException, DAOException, PresentationException, ViewerConfigurationException { SXSSFWorkbook wb = new SXSSFWorkbook(25); List<SXSSFSheet> sheets = new ArrayList<>(); int currentSheetIndex = 0; SXSSFSheet currentSheet = wb.createSheet("intranda_viewer_search"); CellStyle styleBold = wb.createCellStyle(); Font font2 = wb.createFont(); font2.setFontHeightInPoints((short) 10); font2.setBold(true); styleBold.setFont(font2); int currentRowIndex = 0; int currentCellIndex = 0; { SXSSFRow row = currentSheet.createRow(currentRowIndex++); SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString("Query:")); cell = row.createCell(currentCellIndex++); cell.setCellValue(new XSSFRichTextString(exportQuery)); currentCellIndex = 0; } SXSSFRow row = currentSheet.createRow(currentRowIndex++); for (String field : DataManager.getInstance().getConfiguration().getSearchExcelExportFields()) { SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString(ViewerResourceBundle.getTranslation(field, locale))); } List<String> exportFields = DataManager.getInstance().getConfiguration().getSearchExcelExportFields(); long totalHits = DataManager.getInstance().getSearchIndex().getHitCount(finalQuery, filterQueries); int batchSize = 100; int totalBatches = (int) Math.ceil((double) totalHits / batchSize); for (int i = 0; i < totalBatches; ++i) { int first = i * batchSize; int max = first + batchSize - 1; if (max > totalHits) { max = (int) (totalHits - 1); batchSize = (int) (totalHits - first); } logger.trace("Fetching search hits {}-{} out of {}", first, max, totalHits); List<SearchHit> batch; if (aggregateHits) { batch = searchWithAggregation(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale); } else { batch = searchWithFulltext(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale, request); } for (SearchHit hit : batch) { currentCellIndex = 0; row = currentSheet.createRow(currentRowIndex++); for (String field : exportFields) { SXSSFCell cell = row.createCell(currentCellIndex++); String value = hit.getExportMetadata().get(field); cell.setCellValue(new XSSFRichTextString(value != null ? value : "")); } } } return wb; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request) throws IndexUnreachableException, DAOException, PresentationException, ViewerConfigurationException { SXSSFWorkbook wb = new SXSSFWorkbook(25); List<SXSSFSheet> sheets = new ArrayList<>(); int currentSheetIndex = 0; SXSSFSheet currentSheet = wb.createSheet("intranda_viewer_search"); CellStyle styleBold = wb.createCellStyle(); Font font2 = wb.createFont(); font2.setFontHeightInPoints((short) 10); font2.setBold(true); styleBold.setFont(font2); int currentRowIndex = 0; int currentCellIndex = 0; { SXSSFRow row = currentSheet.createRow(currentRowIndex++); SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString("Query:")); cell = row.createCell(currentCellIndex++); cell.setCellValue(new XSSFRichTextString(exportQuery)); currentCellIndex = 0; } SXSSFRow row = currentSheet.createRow(currentRowIndex++); for (String field : DataManager.getInstance().getConfiguration().getSearchExcelExportFields()) { SXSSFCell cell = row.createCell(currentCellIndex++); cell.setCellStyle(styleBold); cell.setCellValue(new XSSFRichTextString(ViewerResourceBundle.getTranslation(field, locale))); } List<String> exportFields = DataManager.getInstance().getConfiguration().getSearchExcelExportFields(); long totalHits = DataManager.getInstance().getSearchIndex().getHitCount(finalQuery, filterQueries); int batchSize = 100; int totalBatches = (int) Math.ceil((double) totalHits / batchSize); for (int i = 0; i < totalBatches; ++i) { int first = i * batchSize; int max = first + batchSize - 1; if (max > totalHits) { max = (int) (totalHits - 1); batchSize = (int) (totalHits - first); } logger.trace("Fetching search hits {}-{} out of {}", first, max, totalHits); List<SearchHit> batch; if (aggregateHits) { batch = searchWithAggregation(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale); } else { batch = searchWithFulltext(finalQuery, first, batchSize, sortFields, null, filterQueries, params, searchTerms, exportFields, locale, request); } for (SearchHit hit : batch) { currentCellIndex = 0; row = currentSheet.createRow(currentRowIndex++); for (String field : exportFields) { SXSSFCell cell = row.createCell(currentCellIndex++); String value = hit.getExportMetadata().get(field); cell.setCellValue(new XSSFRichTextString(value != null ? value : "")); } } } return wb; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void applyHighlightingToPhrase_shouldApplyHighlightingForAllTerms() throws Exception { { String phrase = "FOO BAR Foo Bar foo bar"; Set<String> terms = new HashSet<>(); terms.add("foo"); terms.add("bar"); String highlightedPhrase = SearchHelper.applyHighlightingToPhrase(phrase, terms); Assert.assertEquals(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "FOO" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "BAR" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Bar" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "bar" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END, highlightedPhrase); } { String phrase = "Γ qu 4"; Set<String> terms = new HashSet<>(); terms.add("Γ qu 4"); String highlightedPhrase = SearchHelper.applyHighlightingToPhrase(phrase, terms); Assert.assertEquals(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Γ qu 4" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END, highlightedPhrase); } }
|
public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void testGetProcessedConditions() { LicenseType type = new LicenseType(); type.setConditions("FILENAME:{" + CONDITION_FILENAME_1 + "}"); Assert.assertTrue("processed conditions are " + type.getProcessedConditions(), StringUtils.isBlank(type.getProcessedConditions())); type.setConditions("FILENAME:{" + CONDITION_FILENAME_1 + "} " + CONDITION_QUERY_1); Assert.assertTrue("processed conditions are " + type.getProcessedConditions(), type.getProcessedConditions().equals(CONDITION_QUERY_1)); ; type.setConditions(CONDITION_QUERY_1 + "FILENAME:{" + CONDITION_FILENAME_1 + "}"); Assert.assertTrue("processed conditions are " + type.getProcessedConditions(), type.getProcessedConditions().equals(CONDITION_QUERY_1)); type.setConditions(CONDITION_QUERY_1); Assert.assertTrue("processed conditions are " + type.getProcessedConditions(), type.getProcessedConditions().equals(CONDITION_QUERY_1)); }
|
public String getProcessedConditions() { String conditions = this.conditions; conditions = getQueryConditions(conditions); conditions = SolrSearchIndex.getProcessedConditions(conditions); return conditions.trim(); }
|
LicenseType implements IPrivilegeHolder { public String getProcessedConditions() { String conditions = this.conditions; conditions = getQueryConditions(conditions); conditions = SolrSearchIndex.getProcessedConditions(conditions); return conditions.trim(); } }
|
LicenseType implements IPrivilegeHolder { public String getProcessedConditions() { String conditions = this.conditions; conditions = getQueryConditions(conditions); conditions = SolrSearchIndex.getProcessedConditions(conditions); return conditions.trim(); } LicenseType(); LicenseType(String name); }
|
LicenseType implements IPrivilegeHolder { public String getProcessedConditions() { String conditions = this.conditions; conditions = getQueryConditions(conditions); conditions = SolrSearchIndex.getProcessedConditions(conditions); return conditions.trim(); } LicenseType(); LicenseType(String name); @Override int hashCode(); @Override boolean equals(Object obj); Long getId(); void setId(Long id); String getName(); void setName(String name); String getDescription(); void setDescription(String description); String getProcessedConditions(); String getFilenameConditions(); String getMatch(String conditions, String pattern); boolean isCmsType(); boolean isCrowdsourcingType(); String getConditions(); void setConditions(String conditions); boolean isOpenAccess(); void setOpenAccess(boolean openAccess); boolean isCore(); void setCore(boolean core); boolean isMovingWall(); void setMovingWall(boolean movingWall); boolean isPdfDownloadQuota(); void setPdfDownloadQuota(boolean pdfDownloadQuota); boolean isConcurrentViewsLimit(); void setConcurrentViewsLimit(boolean concurrentViewsLimit); Set<String> getPrivileges(); List<String> getAvailablePrivileges(); List<String> getAvailablePrivileges(Set<String> privileges); List<String> getSortedPrivileges(Set<String> privileges); void setPrivileges(Set<String> privileges); boolean addPrivilege(String privilege); boolean removePrivilege(String privilege); @Override boolean hasPrivilege(String privilege); boolean hasPrivilegeCopy(String privilege); @Override boolean isPrivCmsPages(); @Override void setPrivCmsPages(boolean priv); @Override boolean isPrivCmsAllSubthemes(); @Override void setPrivCmsAllSubthemes(boolean priv); @Override boolean isPrivCmsAllCategories(); @Override void setPrivCmsAllCategories(boolean priv); @Override boolean isPrivCmsAllTemplates(); @Override void setPrivCmsAllTemplates(boolean priv); @Override boolean isPrivCmsMenu(); @Override void setPrivCmsMenu(boolean priv); @Override boolean isPrivCmsStaticPages(); @Override void setPrivCmsStaticPages(boolean priv); @Override boolean isPrivCmsCollections(); @Override void setPrivCmsCollections(boolean priv); @Override boolean isPrivCmsCategories(); @Override void setPrivCmsCategories(boolean priv); @Override boolean isPrivCrowdsourcingAllCampaigns(); @Override void setPrivCrowdsourcingAllCampaigns(boolean priv); @Override boolean isPrivCrowdsourcingAnnotateCampaign(); @Override void setPrivCrowdsourcingAnnotateCampaign(boolean priv); @Override boolean isPrivCrowdsourcingReviewCampaign(); @Override void setPrivCrowdsourcingReviewCampaign(boolean priv); Set<LicenseType> getOverridingLicenseTypes(); void setOverridingLicenseTypes(Set<LicenseType> overridingLicenseTypes); Set<String> getPrivilegesCopy(); void setPrivilegesCopy(Set<String> privilegesCopy); boolean isRestrictionsExpired(String query); Map<String, Boolean> getRestrictionsExpired(); void setRestrictionsExpired(Map<String, Boolean> restrictionsExpired); static void addCoreLicenseTypesToDB(); String getFilterQueryPart(boolean negateFilterQuery); @Override String toString(); }
|
LicenseType implements IPrivilegeHolder { public String getProcessedConditions() { String conditions = this.conditions; conditions = getQueryConditions(conditions); conditions = SolrSearchIndex.getProcessedConditions(conditions); return conditions.trim(); } LicenseType(); LicenseType(String name); @Override int hashCode(); @Override boolean equals(Object obj); Long getId(); void setId(Long id); String getName(); void setName(String name); String getDescription(); void setDescription(String description); String getProcessedConditions(); String getFilenameConditions(); String getMatch(String conditions, String pattern); boolean isCmsType(); boolean isCrowdsourcingType(); String getConditions(); void setConditions(String conditions); boolean isOpenAccess(); void setOpenAccess(boolean openAccess); boolean isCore(); void setCore(boolean core); boolean isMovingWall(); void setMovingWall(boolean movingWall); boolean isPdfDownloadQuota(); void setPdfDownloadQuota(boolean pdfDownloadQuota); boolean isConcurrentViewsLimit(); void setConcurrentViewsLimit(boolean concurrentViewsLimit); Set<String> getPrivileges(); List<String> getAvailablePrivileges(); List<String> getAvailablePrivileges(Set<String> privileges); List<String> getSortedPrivileges(Set<String> privileges); void setPrivileges(Set<String> privileges); boolean addPrivilege(String privilege); boolean removePrivilege(String privilege); @Override boolean hasPrivilege(String privilege); boolean hasPrivilegeCopy(String privilege); @Override boolean isPrivCmsPages(); @Override void setPrivCmsPages(boolean priv); @Override boolean isPrivCmsAllSubthemes(); @Override void setPrivCmsAllSubthemes(boolean priv); @Override boolean isPrivCmsAllCategories(); @Override void setPrivCmsAllCategories(boolean priv); @Override boolean isPrivCmsAllTemplates(); @Override void setPrivCmsAllTemplates(boolean priv); @Override boolean isPrivCmsMenu(); @Override void setPrivCmsMenu(boolean priv); @Override boolean isPrivCmsStaticPages(); @Override void setPrivCmsStaticPages(boolean priv); @Override boolean isPrivCmsCollections(); @Override void setPrivCmsCollections(boolean priv); @Override boolean isPrivCmsCategories(); @Override void setPrivCmsCategories(boolean priv); @Override boolean isPrivCrowdsourcingAllCampaigns(); @Override void setPrivCrowdsourcingAllCampaigns(boolean priv); @Override boolean isPrivCrowdsourcingAnnotateCampaign(); @Override void setPrivCrowdsourcingAnnotateCampaign(boolean priv); @Override boolean isPrivCrowdsourcingReviewCampaign(); @Override void setPrivCrowdsourcingReviewCampaign(boolean priv); Set<LicenseType> getOverridingLicenseTypes(); void setOverridingLicenseTypes(Set<LicenseType> overridingLicenseTypes); Set<String> getPrivilegesCopy(); void setPrivilegesCopy(Set<String> privilegesCopy); boolean isRestrictionsExpired(String query); Map<String, Boolean> getRestrictionsExpired(); void setRestrictionsExpired(Map<String, Boolean> restrictionsExpired); static void addCoreLicenseTypesToDB(); String getFilterQueryPart(boolean negateFilterQuery); @Override String toString(); static final String LICENSE_TYPE_SET_REPRESENTATIVE_IMAGE; static final String LICENSE_TYPE_DELETE_OCR_PAGE; static final String LICENSE_TYPE_CMS; static final String LICENSE_TYPE_CROWDSOURCING_CAMPAIGNS; }
|
@Test public void applyHighlightingToPhrase_shouldIgnoreDiacriticsForHightlighting() throws Exception { String phrase = "Širvintos"; Set<String> terms = new HashSet<>(); terms.add("sirvintos"); String highlightedPhrase = SearchHelper.applyHighlightingToPhrase(phrase, terms); Assert.assertEquals(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + phrase + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END, highlightedPhrase); }
|
public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void applyHighlightingToPhrase_shouldSkipSingleCharacterTerms() throws Exception { String phrase = "FOO BAR Foo Bar foo bar"; Set<String> terms = new HashSet<>(); terms.add("o"); String highlightedPhrase = SearchHelper.applyHighlightingToPhrase(phrase, terms); Assert.assertEquals(phrase, highlightedPhrase); }
|
public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void applyHighlightingToPhrase_shouldApplyHighlightingToAllOccurrencesOfTerm() throws Exception { String phrase = "FOO BAR Foo Bar foo bar"; String highlightedPhrase1 = SearchHelper.applyHighlightingToPhrase(phrase, "foo"); Assert.assertEquals( SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "FOO" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " BAR " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " Bar " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " bar", highlightedPhrase1); String highlightedPhrase2 = SearchHelper.applyHighlightingToPhrase(highlightedPhrase1, "bar"); Assert.assertEquals(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "FOO" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "BAR" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Bar" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "bar" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END, highlightedPhrase2); }
|
public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void applyHighlightingToPhrase_shouldIgnoreSpecialCharacters() throws Exception { String phrase = "FOO BAR Foo Bar foo bar"; String highlightedPhrase1 = SearchHelper.applyHighlightingToPhrase(phrase, "foo-bar"); Assert.assertEquals(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "FOO BAR" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "Foo Bar" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END + " " + SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "foo bar" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END, highlightedPhrase1); }
|
public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String applyHighlightingToPhrase(String phrase, Set<String> terms) { if (phrase == null) { throw new IllegalArgumentException("phrase may not be null"); } if (terms == null) { throw new IllegalArgumentException("terms may not be null"); } String highlightedValue = phrase; for (String term : terms) { if (term.length() < 2) { continue; } term = SearchHelper.removeTruncation(term); String normalizedPhrase = normalizeString(phrase); String normalizedTerm = normalizeString(term); if (StringUtils.contains(normalizedPhrase, normalizedTerm)) { highlightedValue = SearchHelper.applyHighlightingToPhrase(highlightedValue, term); } } return highlightedValue; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void applyHighlightingToTerm_shouldAddSpanCorrectly() throws Exception { Assert.assertEquals(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END, SearchHelper.applyHighlightingToTerm("foo")); }
|
static String applyHighlightingToTerm(String term) { return new StringBuilder(PLACEHOLDER_HIGHLIGHTING_START).append(term).append(PLACEHOLDER_HIGHLIGHTING_END).toString(); }
|
SearchHelper { static String applyHighlightingToTerm(String term) { return new StringBuilder(PLACEHOLDER_HIGHLIGHTING_START).append(term).append(PLACEHOLDER_HIGHLIGHTING_END).toString(); } }
|
SearchHelper { static String applyHighlightingToTerm(String term) { return new StringBuilder(PLACEHOLDER_HIGHLIGHTING_START).append(term).append(PLACEHOLDER_HIGHLIGHTING_END).toString(); } }
|
SearchHelper { static String applyHighlightingToTerm(String term) { return new StringBuilder(PLACEHOLDER_HIGHLIGHTING_START).append(term).append(PLACEHOLDER_HIGHLIGHTING_END).toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { static String applyHighlightingToTerm(String term) { return new StringBuilder(PLACEHOLDER_HIGHLIGHTING_START).append(term).append(PLACEHOLDER_HIGHLIGHTING_END).toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void replaceHighlightingPlaceholders_shouldReplacePlaceholdersWithHtmlTags() throws Exception { Assert.assertEquals("<span class=\"search-list--highlight\">foo</span>", SearchHelper .replaceHighlightingPlaceholders(SearchHelper.PLACEHOLDER_HIGHLIGHTING_START + "foo" + SearchHelper.PLACEHOLDER_HIGHLIGHTING_END)); }
|
public static String replaceHighlightingPlaceholders(String phrase) { return phrase.replace(PLACEHOLDER_HIGHLIGHTING_START, "<span class=\"search-list--highlight\">") .replace(PLACEHOLDER_HIGHLIGHTING_END, "</span>"); }
|
SearchHelper { public static String replaceHighlightingPlaceholders(String phrase) { return phrase.replace(PLACEHOLDER_HIGHLIGHTING_START, "<span class=\"search-list--highlight\">") .replace(PLACEHOLDER_HIGHLIGHTING_END, "</span>"); } }
|
SearchHelper { public static String replaceHighlightingPlaceholders(String phrase) { return phrase.replace(PLACEHOLDER_HIGHLIGHTING_START, "<span class=\"search-list--highlight\">") .replace(PLACEHOLDER_HIGHLIGHTING_END, "</span>"); } }
|
SearchHelper { public static String replaceHighlightingPlaceholders(String phrase) { return phrase.replace(PLACEHOLDER_HIGHLIGHTING_START, "<span class=\"search-list--highlight\">") .replace(PLACEHOLDER_HIGHLIGHTING_END, "</span>"); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String replaceHighlightingPlaceholders(String phrase) { return phrase.replace(PLACEHOLDER_HIGHLIGHTING_START, "<span class=\"search-list--highlight\">") .replace(PLACEHOLDER_HIGHLIGHTING_END, "</span>"); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void prepareQuery_shouldPrepareNonemptyQueriesCorrectly() throws Exception { Assert.assertEquals("(FOO:bar)", SearchHelper.prepareQuery("FOO:bar", null)); }
|
public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void prepareQuery_shouldPrepareEmptyQueriesCorrectly() throws Exception { Assert.assertEquals("(ISWORK:true OR ISANCHOR:true) AND BLA:blup", SearchHelper.prepareQuery(null, "(ISWORK:true OR ISANCHOR:true) AND BLA:blup")); Assert.assertEquals("+(ISWORK:true ISANCHOR:true)", SearchHelper.prepareQuery(null, "")); }
|
public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String prepareQuery(String query) { StringBuilder sbQuery = new StringBuilder(); if (StringUtils.isNotEmpty(query)) { sbQuery.append('(').append(query).append(')'); } else { String docstructWhitelistFilterQuery = getDocstrctWhitelistFilterQuery(); if (StringUtils.isNotEmpty(docstructWhitelistFilterQuery)) { sbQuery.append(docstructWhitelistFilterQuery); } else { sbQuery.append(ALL_RECORDS_QUERY); } } return sbQuery.toString(); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void parseSortString_shouldParseStringCorrectly() throws Exception { String sortString = "!SORT_1;SORT_2;SORT_3"; Assert.assertEquals(3, SearchHelper.parseSortString(sortString, null).size()); }
|
public static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper) { List<StringPair> ret = new ArrayList<>(); if (StringUtils.isNotEmpty(sortString)) { String[] sortStringSplit = sortString.split(";"); if (sortStringSplit.length > 0) { for (String field : sortStringSplit) { ret.add(new StringPair(field.replace("!", ""), field.charAt(0) == '!' ? "desc" : "asc")); logger.trace("Added sort field: {}", field); if (navigationHelper != null && field.startsWith("SORT_")) { Iterable<Locale> locales = () -> navigationHelper.getSupportedLocales(); StreamSupport.stream(locales.spliterator(), false) .sorted(new LocaleComparator(BeanUtils.getLocale())) .map(locale -> field + SolrConstants._LANG_ + locale.getLanguage().toUpperCase()) .peek(language -> logger.trace("Adding sort field: {}", language)) .forEach(language -> ret.add(new StringPair(language.replace("!", ""), language.charAt(0) == '!' ? "desc" : "asc"))); } } } } return ret; }
|
SearchHelper { public static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper) { List<StringPair> ret = new ArrayList<>(); if (StringUtils.isNotEmpty(sortString)) { String[] sortStringSplit = sortString.split(";"); if (sortStringSplit.length > 0) { for (String field : sortStringSplit) { ret.add(new StringPair(field.replace("!", ""), field.charAt(0) == '!' ? "desc" : "asc")); logger.trace("Added sort field: {}", field); if (navigationHelper != null && field.startsWith("SORT_")) { Iterable<Locale> locales = () -> navigationHelper.getSupportedLocales(); StreamSupport.stream(locales.spliterator(), false) .sorted(new LocaleComparator(BeanUtils.getLocale())) .map(locale -> field + SolrConstants._LANG_ + locale.getLanguage().toUpperCase()) .peek(language -> logger.trace("Adding sort field: {}", language)) .forEach(language -> ret.add(new StringPair(language.replace("!", ""), language.charAt(0) == '!' ? "desc" : "asc"))); } } } } return ret; } }
|
SearchHelper { public static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper) { List<StringPair> ret = new ArrayList<>(); if (StringUtils.isNotEmpty(sortString)) { String[] sortStringSplit = sortString.split(";"); if (sortStringSplit.length > 0) { for (String field : sortStringSplit) { ret.add(new StringPair(field.replace("!", ""), field.charAt(0) == '!' ? "desc" : "asc")); logger.trace("Added sort field: {}", field); if (navigationHelper != null && field.startsWith("SORT_")) { Iterable<Locale> locales = () -> navigationHelper.getSupportedLocales(); StreamSupport.stream(locales.spliterator(), false) .sorted(new LocaleComparator(BeanUtils.getLocale())) .map(locale -> field + SolrConstants._LANG_ + locale.getLanguage().toUpperCase()) .peek(language -> logger.trace("Adding sort field: {}", language)) .forEach(language -> ret.add(new StringPair(language.replace("!", ""), language.charAt(0) == '!' ? "desc" : "asc"))); } } } } return ret; } }
|
SearchHelper { public static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper) { List<StringPair> ret = new ArrayList<>(); if (StringUtils.isNotEmpty(sortString)) { String[] sortStringSplit = sortString.split(";"); if (sortStringSplit.length > 0) { for (String field : sortStringSplit) { ret.add(new StringPair(field.replace("!", ""), field.charAt(0) == '!' ? "desc" : "asc")); logger.trace("Added sort field: {}", field); if (navigationHelper != null && field.startsWith("SORT_")) { Iterable<Locale> locales = () -> navigationHelper.getSupportedLocales(); StreamSupport.stream(locales.spliterator(), false) .sorted(new LocaleComparator(BeanUtils.getLocale())) .map(locale -> field + SolrConstants._LANG_ + locale.getLanguage().toUpperCase()) .peek(language -> logger.trace("Adding sort field: {}", language)) .forEach(language -> ret.add(new StringPair(language.replace("!", ""), language.charAt(0) == '!' ? "desc" : "asc"))); } } } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper) { List<StringPair> ret = new ArrayList<>(); if (StringUtils.isNotEmpty(sortString)) { String[] sortStringSplit = sortString.split(";"); if (sortStringSplit.length > 0) { for (String field : sortStringSplit) { ret.add(new StringPair(field.replace("!", ""), field.charAt(0) == '!' ? "desc" : "asc")); logger.trace("Added sort field: {}", field); if (navigationHelper != null && field.startsWith("SORT_")) { Iterable<Locale> locales = () -> navigationHelper.getSupportedLocales(); StreamSupport.stream(locales.spliterator(), false) .sorted(new LocaleComparator(BeanUtils.getLocale())) .map(locale -> field + SolrConstants._LANG_ + locale.getLanguage().toUpperCase()) .peek(language -> logger.trace("Adding sort field: {}", language)) .forEach(language -> ret.add(new StringPair(language.replace("!", ""), language.charAt(0) == '!' ? "desc" : "asc"))); } } } } return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void removeHighlightingTags_shouldRemoveHtmlTags() throws Exception { Assert.assertEquals("foo bar", SearchHelper .removeHighlightingTags("f<span class=\"search-list--highlight\">oo</span> <span class=\"search-list--highlight\">bar</span>")); }
|
public static String removeHighlightingTags(String phrase) { return phrase.replace("<span class=\"search-list--highlight\">", "").replace("</span>", ""); }
|
SearchHelper { public static String removeHighlightingTags(String phrase) { return phrase.replace("<span class=\"search-list--highlight\">", "").replace("</span>", ""); } }
|
SearchHelper { public static String removeHighlightingTags(String phrase) { return phrase.replace("<span class=\"search-list--highlight\">", "").replace("</span>", ""); } }
|
SearchHelper { public static String removeHighlightingTags(String phrase) { return phrase.replace("<span class=\"search-list--highlight\">", "").replace("</span>", ""); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String removeHighlightingTags(String phrase) { return phrase.replace("<span class=\"search-list--highlight\">", "").replace("</span>", ""); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void testGetFilenameConditions() { LicenseType type = new LicenseType(); type.setConditions("FILENAME:{" + CONDITION_FILENAME_1 + "}"); Assert.assertTrue("filename conditions are " + type.getFilenameConditions(), type.getFilenameConditions().equals(CONDITION_FILENAME_1)); type.setConditions("FILENAME:{" + CONDITION_FILENAME_1 + "} " + CONDITION_QUERY_1); Assert.assertTrue("filename conditions are " + type.getFilenameConditions(), type.getFilenameConditions().equals(CONDITION_FILENAME_1)); ; type.setConditions(CONDITION_QUERY_1 + "FILENAME:{" + CONDITION_FILENAME_1 + "}"); Assert.assertTrue("filename conditions are " + type.getFilenameConditions(), type.getFilenameConditions().equals(CONDITION_FILENAME_1)); type.setConditions(CONDITION_QUERY_1); Assert.assertTrue("filename conditions are " + type.getFilenameConditions(), StringUtils.isBlank(type.getFilenameConditions())); }
|
public String getFilenameConditions() { return getFilenameConditions(this.conditions); }
|
LicenseType implements IPrivilegeHolder { public String getFilenameConditions() { return getFilenameConditions(this.conditions); } }
|
LicenseType implements IPrivilegeHolder { public String getFilenameConditions() { return getFilenameConditions(this.conditions); } LicenseType(); LicenseType(String name); }
|
LicenseType implements IPrivilegeHolder { public String getFilenameConditions() { return getFilenameConditions(this.conditions); } LicenseType(); LicenseType(String name); @Override int hashCode(); @Override boolean equals(Object obj); Long getId(); void setId(Long id); String getName(); void setName(String name); String getDescription(); void setDescription(String description); String getProcessedConditions(); String getFilenameConditions(); String getMatch(String conditions, String pattern); boolean isCmsType(); boolean isCrowdsourcingType(); String getConditions(); void setConditions(String conditions); boolean isOpenAccess(); void setOpenAccess(boolean openAccess); boolean isCore(); void setCore(boolean core); boolean isMovingWall(); void setMovingWall(boolean movingWall); boolean isPdfDownloadQuota(); void setPdfDownloadQuota(boolean pdfDownloadQuota); boolean isConcurrentViewsLimit(); void setConcurrentViewsLimit(boolean concurrentViewsLimit); Set<String> getPrivileges(); List<String> getAvailablePrivileges(); List<String> getAvailablePrivileges(Set<String> privileges); List<String> getSortedPrivileges(Set<String> privileges); void setPrivileges(Set<String> privileges); boolean addPrivilege(String privilege); boolean removePrivilege(String privilege); @Override boolean hasPrivilege(String privilege); boolean hasPrivilegeCopy(String privilege); @Override boolean isPrivCmsPages(); @Override void setPrivCmsPages(boolean priv); @Override boolean isPrivCmsAllSubthemes(); @Override void setPrivCmsAllSubthemes(boolean priv); @Override boolean isPrivCmsAllCategories(); @Override void setPrivCmsAllCategories(boolean priv); @Override boolean isPrivCmsAllTemplates(); @Override void setPrivCmsAllTemplates(boolean priv); @Override boolean isPrivCmsMenu(); @Override void setPrivCmsMenu(boolean priv); @Override boolean isPrivCmsStaticPages(); @Override void setPrivCmsStaticPages(boolean priv); @Override boolean isPrivCmsCollections(); @Override void setPrivCmsCollections(boolean priv); @Override boolean isPrivCmsCategories(); @Override void setPrivCmsCategories(boolean priv); @Override boolean isPrivCrowdsourcingAllCampaigns(); @Override void setPrivCrowdsourcingAllCampaigns(boolean priv); @Override boolean isPrivCrowdsourcingAnnotateCampaign(); @Override void setPrivCrowdsourcingAnnotateCampaign(boolean priv); @Override boolean isPrivCrowdsourcingReviewCampaign(); @Override void setPrivCrowdsourcingReviewCampaign(boolean priv); Set<LicenseType> getOverridingLicenseTypes(); void setOverridingLicenseTypes(Set<LicenseType> overridingLicenseTypes); Set<String> getPrivilegesCopy(); void setPrivilegesCopy(Set<String> privilegesCopy); boolean isRestrictionsExpired(String query); Map<String, Boolean> getRestrictionsExpired(); void setRestrictionsExpired(Map<String, Boolean> restrictionsExpired); static void addCoreLicenseTypesToDB(); String getFilterQueryPart(boolean negateFilterQuery); @Override String toString(); }
|
LicenseType implements IPrivilegeHolder { public String getFilenameConditions() { return getFilenameConditions(this.conditions); } LicenseType(); LicenseType(String name); @Override int hashCode(); @Override boolean equals(Object obj); Long getId(); void setId(Long id); String getName(); void setName(String name); String getDescription(); void setDescription(String description); String getProcessedConditions(); String getFilenameConditions(); String getMatch(String conditions, String pattern); boolean isCmsType(); boolean isCrowdsourcingType(); String getConditions(); void setConditions(String conditions); boolean isOpenAccess(); void setOpenAccess(boolean openAccess); boolean isCore(); void setCore(boolean core); boolean isMovingWall(); void setMovingWall(boolean movingWall); boolean isPdfDownloadQuota(); void setPdfDownloadQuota(boolean pdfDownloadQuota); boolean isConcurrentViewsLimit(); void setConcurrentViewsLimit(boolean concurrentViewsLimit); Set<String> getPrivileges(); List<String> getAvailablePrivileges(); List<String> getAvailablePrivileges(Set<String> privileges); List<String> getSortedPrivileges(Set<String> privileges); void setPrivileges(Set<String> privileges); boolean addPrivilege(String privilege); boolean removePrivilege(String privilege); @Override boolean hasPrivilege(String privilege); boolean hasPrivilegeCopy(String privilege); @Override boolean isPrivCmsPages(); @Override void setPrivCmsPages(boolean priv); @Override boolean isPrivCmsAllSubthemes(); @Override void setPrivCmsAllSubthemes(boolean priv); @Override boolean isPrivCmsAllCategories(); @Override void setPrivCmsAllCategories(boolean priv); @Override boolean isPrivCmsAllTemplates(); @Override void setPrivCmsAllTemplates(boolean priv); @Override boolean isPrivCmsMenu(); @Override void setPrivCmsMenu(boolean priv); @Override boolean isPrivCmsStaticPages(); @Override void setPrivCmsStaticPages(boolean priv); @Override boolean isPrivCmsCollections(); @Override void setPrivCmsCollections(boolean priv); @Override boolean isPrivCmsCategories(); @Override void setPrivCmsCategories(boolean priv); @Override boolean isPrivCrowdsourcingAllCampaigns(); @Override void setPrivCrowdsourcingAllCampaigns(boolean priv); @Override boolean isPrivCrowdsourcingAnnotateCampaign(); @Override void setPrivCrowdsourcingAnnotateCampaign(boolean priv); @Override boolean isPrivCrowdsourcingReviewCampaign(); @Override void setPrivCrowdsourcingReviewCampaign(boolean priv); Set<LicenseType> getOverridingLicenseTypes(); void setOverridingLicenseTypes(Set<LicenseType> overridingLicenseTypes); Set<String> getPrivilegesCopy(); void setPrivilegesCopy(Set<String> privilegesCopy); boolean isRestrictionsExpired(String query); Map<String, Boolean> getRestrictionsExpired(); void setRestrictionsExpired(Map<String, Boolean> restrictionsExpired); static void addCoreLicenseTypesToDB(); String getFilterQueryPart(boolean negateFilterQuery); @Override String toString(); static final String LICENSE_TYPE_SET_REPRESENTATIVE_IMAGE; static final String LICENSE_TYPE_DELETE_OCR_PAGE; static final String LICENSE_TYPE_CMS; static final String LICENSE_TYPE_CROWDSOURCING_CAMPAIGNS; }
|
@Test public void cleanUpSearchTerm_shouldRemoveIllegalCharsCorrectly() throws Exception { Assert.assertEquals("a", SearchHelper.cleanUpSearchTerm("(a)")); }
|
public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void cleanUpSearchTerm_shouldPreserveTruncation() throws Exception { Assert.assertEquals("*a*", SearchHelper.cleanUpSearchTerm("*a*")); }
|
public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void cleanUpSearchTerm_shouldPreserveNegation() throws Exception { Assert.assertEquals("-a", SearchHelper.cleanUpSearchTerm("-a")); }
|
public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String cleanUpSearchTerm(String s) { if (StringUtils.isNotEmpty(s)) { boolean addNegation = false; boolean addLeftTruncation = false; boolean addRightTruncation = false; if (s.charAt(0) == '-') { addNegation = true; s = s.substring(1); } else if (s.charAt(0) == '*') { addLeftTruncation = true; } if (s.endsWith("*")) { addRightTruncation = true; } s = s.replace("*", ""); s = s.replace("(", ""); s = s.replace(")", ""); if (addNegation) { s = '-' + s; } else if (addLeftTruncation) { s = '*' + s; } if (addRightTruncation) { s += '*'; } } return s; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void normalizeString_shouldPreserveDigits() throws Exception { Assert.assertEquals("1 2 3", SearchHelper.normalizeString("1*2*3")); }
|
static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void normalizeString_shouldPreserveLatinChars() throws Exception { Assert.assertEquals("f o obar", SearchHelper.normalizeString("F*O*Obar")); }
|
static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { static String normalizeString(String string) { if (string == null) { return null; } string = Normalizer.normalize(string, Normalizer.Form.NFD); string = string.toLowerCase().replaceAll("\\p{M}", "").replaceAll("[^\\p{L}0-9#]", " "); string = Normalizer.normalize(string, Normalizer.Form.NFC); return string; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void testBuildFinalQuery() throws IndexUnreachableException, PresentationException { String query = "DC:dctei"; String finalQuery = SearchHelper.buildFinalQuery(query, false, null); SolrDocumentList docs = DataManager.getInstance().getSearchIndex().search(finalQuery); Assert.assertEquals(65, docs.size()); finalQuery = SearchHelper.buildFinalQuery(query, false, null); docs = DataManager.getInstance().getSearchIndex().search(finalQuery); Assert.assertEquals(65, docs.size()); }
|
public static String buildFinalQuery(String rawQuery, boolean aggregateHits) throws IndexUnreachableException { return buildFinalQuery(rawQuery, aggregateHits, null); }
|
SearchHelper { public static String buildFinalQuery(String rawQuery, boolean aggregateHits) throws IndexUnreachableException { return buildFinalQuery(rawQuery, aggregateHits, null); } }
|
SearchHelper { public static String buildFinalQuery(String rawQuery, boolean aggregateHits) throws IndexUnreachableException { return buildFinalQuery(rawQuery, aggregateHits, null); } }
|
SearchHelper { public static String buildFinalQuery(String rawQuery, boolean aggregateHits) throws IndexUnreachableException { return buildFinalQuery(rawQuery, aggregateHits, null); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static String buildFinalQuery(String rawQuery, boolean aggregateHits) throws IndexUnreachableException { return buildFinalQuery(rawQuery, aggregateHits, null); } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void getFilteredTerms_shouldBeThreadSafeWhenCountingTerms() throws Exception { int previousSize = -1; Map<String, Long> previousCounts = new HashMap<>(); BrowsingMenuFieldConfig bmfc = new BrowsingMenuFieldConfig("MD_LANGUAGE_UNTOKENIZED", null, null, false, false, false); for (int i = 0; i < 100; ++i) { List<BrowseTerm> terms = SearchHelper.getFilteredTerms(bmfc, null, null, 0, SolrSearchIndex.MAX_HITS, new BrowseTermComparator(Locale.ENGLISH), true); Assert.assertFalse(terms.isEmpty()); Assert.assertTrue(previousSize == -1 || terms.size() == previousSize); previousSize = terms.size(); for (BrowseTerm term : terms) { if (previousCounts.containsKey(term.getTerm())) { Assert.assertEquals("Token '" + term.getTerm() + "' - ", Long.valueOf(previousCounts.get(term.getTerm())), Long.valueOf(term.getHitCount())); } previousCounts.put(term.getTerm(), term.getHitCount()); } } }
|
public static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows, Comparator<BrowseTerm> comparator, boolean aggregateHits) throws PresentationException, IndexUnreachableException { if (bmfc == null) { throw new IllegalArgumentException("bmfc may not be null"); } logger.trace("getFilteredTerms: {}", bmfc.getField()); List<BrowseTerm> ret = new ArrayList<>(); ConcurrentMap<String, BrowseTerm> terms = new ConcurrentHashMap<>(); if (bmfc.isRecordsAndAnchorsOnly()) { rows = 0; } try { List<StringPair> sortFields = StringUtils.isEmpty(bmfc.getSortField()) ? null : Collections.singletonList(new StringPair(bmfc.getSortField(), "asc")); QueryResponse resp = getFilteredTermsFromIndex(bmfc, startsWith, filterQuery, sortFields, start, rows); if ("0-9".equals(startsWith)) { Pattern p = Pattern.compile("[\\d]"); for (SolrDocument doc : resp.getResults()) { Collection<Object> termList = doc.getFieldValues(bmfc.getField()); String sortTerm = (String) doc.getFieldValue(bmfc.getSortField()); Set<String> usedTermsInCurrentDoc = new HashSet<>(); for (Object o : termList) { String term = String.valueOf(o); if (usedTermsInCurrentDoc.contains(term)) { continue; } String termStart = term; if (termStart.length() > 1) { termStart = term.substring(0, 1); } String compareTerm = termStart; if (StringUtils.isNotEmpty(sortTerm)) { compareTerm = sortTerm; } Matcher m = p.matcher(compareTerm); if (m.find()) { BrowseTerm browseTerm = terms.get(term); if (browseTerm == null) { browseTerm = new BrowseTerm(term, sortTerm, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(term) : null); terms.put(term, browseTerm); } sortTerm = null; browseTerm.addToHitCount(1); usedTermsInCurrentDoc.add(term); } } } } else { String facetField = SearchHelper.facetifyField(bmfc.getField()); if (resp.getResults().isEmpty() && resp.getFacetField(facetField) != null) { logger.trace("using faceting: {}", facetField); for (Count count : resp.getFacetField(facetField).getValues()) { terms.put(count.getName(), new BrowseTerm(count.getName(), null, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(count.getName()) : null) .setHitCount(count.getCount())); } } else { for (SolrDocument doc : resp.getResults()) { processSolrResult(doc, bmfc, startsWith, terms, aggregateHits); } } } } catch (PresentationException e) { logger.debug("PresentationException thrown here: {}", e.getMessage()); throw new PresentationException(e.getMessage()); } if (!terms.isEmpty()) { ret = new ArrayList<>(terms.values()); if (comparator != null) { Collections.sort(ret, comparator); } } logger.debug("getFilteredTerms end: {} terms found.", ret.size()); return ret; }
|
SearchHelper { public static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows, Comparator<BrowseTerm> comparator, boolean aggregateHits) throws PresentationException, IndexUnreachableException { if (bmfc == null) { throw new IllegalArgumentException("bmfc may not be null"); } logger.trace("getFilteredTerms: {}", bmfc.getField()); List<BrowseTerm> ret = new ArrayList<>(); ConcurrentMap<String, BrowseTerm> terms = new ConcurrentHashMap<>(); if (bmfc.isRecordsAndAnchorsOnly()) { rows = 0; } try { List<StringPair> sortFields = StringUtils.isEmpty(bmfc.getSortField()) ? null : Collections.singletonList(new StringPair(bmfc.getSortField(), "asc")); QueryResponse resp = getFilteredTermsFromIndex(bmfc, startsWith, filterQuery, sortFields, start, rows); if ("0-9".equals(startsWith)) { Pattern p = Pattern.compile("[\\d]"); for (SolrDocument doc : resp.getResults()) { Collection<Object> termList = doc.getFieldValues(bmfc.getField()); String sortTerm = (String) doc.getFieldValue(bmfc.getSortField()); Set<String> usedTermsInCurrentDoc = new HashSet<>(); for (Object o : termList) { String term = String.valueOf(o); if (usedTermsInCurrentDoc.contains(term)) { continue; } String termStart = term; if (termStart.length() > 1) { termStart = term.substring(0, 1); } String compareTerm = termStart; if (StringUtils.isNotEmpty(sortTerm)) { compareTerm = sortTerm; } Matcher m = p.matcher(compareTerm); if (m.find()) { BrowseTerm browseTerm = terms.get(term); if (browseTerm == null) { browseTerm = new BrowseTerm(term, sortTerm, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(term) : null); terms.put(term, browseTerm); } sortTerm = null; browseTerm.addToHitCount(1); usedTermsInCurrentDoc.add(term); } } } } else { String facetField = SearchHelper.facetifyField(bmfc.getField()); if (resp.getResults().isEmpty() && resp.getFacetField(facetField) != null) { logger.trace("using faceting: {}", facetField); for (Count count : resp.getFacetField(facetField).getValues()) { terms.put(count.getName(), new BrowseTerm(count.getName(), null, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(count.getName()) : null) .setHitCount(count.getCount())); } } else { for (SolrDocument doc : resp.getResults()) { processSolrResult(doc, bmfc, startsWith, terms, aggregateHits); } } } } catch (PresentationException e) { logger.debug("PresentationException thrown here: {}", e.getMessage()); throw new PresentationException(e.getMessage()); } if (!terms.isEmpty()) { ret = new ArrayList<>(terms.values()); if (comparator != null) { Collections.sort(ret, comparator); } } logger.debug("getFilteredTerms end: {} terms found.", ret.size()); return ret; } }
|
SearchHelper { public static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows, Comparator<BrowseTerm> comparator, boolean aggregateHits) throws PresentationException, IndexUnreachableException { if (bmfc == null) { throw new IllegalArgumentException("bmfc may not be null"); } logger.trace("getFilteredTerms: {}", bmfc.getField()); List<BrowseTerm> ret = new ArrayList<>(); ConcurrentMap<String, BrowseTerm> terms = new ConcurrentHashMap<>(); if (bmfc.isRecordsAndAnchorsOnly()) { rows = 0; } try { List<StringPair> sortFields = StringUtils.isEmpty(bmfc.getSortField()) ? null : Collections.singletonList(new StringPair(bmfc.getSortField(), "asc")); QueryResponse resp = getFilteredTermsFromIndex(bmfc, startsWith, filterQuery, sortFields, start, rows); if ("0-9".equals(startsWith)) { Pattern p = Pattern.compile("[\\d]"); for (SolrDocument doc : resp.getResults()) { Collection<Object> termList = doc.getFieldValues(bmfc.getField()); String sortTerm = (String) doc.getFieldValue(bmfc.getSortField()); Set<String> usedTermsInCurrentDoc = new HashSet<>(); for (Object o : termList) { String term = String.valueOf(o); if (usedTermsInCurrentDoc.contains(term)) { continue; } String termStart = term; if (termStart.length() > 1) { termStart = term.substring(0, 1); } String compareTerm = termStart; if (StringUtils.isNotEmpty(sortTerm)) { compareTerm = sortTerm; } Matcher m = p.matcher(compareTerm); if (m.find()) { BrowseTerm browseTerm = terms.get(term); if (browseTerm == null) { browseTerm = new BrowseTerm(term, sortTerm, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(term) : null); terms.put(term, browseTerm); } sortTerm = null; browseTerm.addToHitCount(1); usedTermsInCurrentDoc.add(term); } } } } else { String facetField = SearchHelper.facetifyField(bmfc.getField()); if (resp.getResults().isEmpty() && resp.getFacetField(facetField) != null) { logger.trace("using faceting: {}", facetField); for (Count count : resp.getFacetField(facetField).getValues()) { terms.put(count.getName(), new BrowseTerm(count.getName(), null, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(count.getName()) : null) .setHitCount(count.getCount())); } } else { for (SolrDocument doc : resp.getResults()) { processSolrResult(doc, bmfc, startsWith, terms, aggregateHits); } } } } catch (PresentationException e) { logger.debug("PresentationException thrown here: {}", e.getMessage()); throw new PresentationException(e.getMessage()); } if (!terms.isEmpty()) { ret = new ArrayList<>(terms.values()); if (comparator != null) { Collections.sort(ret, comparator); } } logger.debug("getFilteredTerms end: {} terms found.", ret.size()); return ret; } }
|
SearchHelper { public static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows, Comparator<BrowseTerm> comparator, boolean aggregateHits) throws PresentationException, IndexUnreachableException { if (bmfc == null) { throw new IllegalArgumentException("bmfc may not be null"); } logger.trace("getFilteredTerms: {}", bmfc.getField()); List<BrowseTerm> ret = new ArrayList<>(); ConcurrentMap<String, BrowseTerm> terms = new ConcurrentHashMap<>(); if (bmfc.isRecordsAndAnchorsOnly()) { rows = 0; } try { List<StringPair> sortFields = StringUtils.isEmpty(bmfc.getSortField()) ? null : Collections.singletonList(new StringPair(bmfc.getSortField(), "asc")); QueryResponse resp = getFilteredTermsFromIndex(bmfc, startsWith, filterQuery, sortFields, start, rows); if ("0-9".equals(startsWith)) { Pattern p = Pattern.compile("[\\d]"); for (SolrDocument doc : resp.getResults()) { Collection<Object> termList = doc.getFieldValues(bmfc.getField()); String sortTerm = (String) doc.getFieldValue(bmfc.getSortField()); Set<String> usedTermsInCurrentDoc = new HashSet<>(); for (Object o : termList) { String term = String.valueOf(o); if (usedTermsInCurrentDoc.contains(term)) { continue; } String termStart = term; if (termStart.length() > 1) { termStart = term.substring(0, 1); } String compareTerm = termStart; if (StringUtils.isNotEmpty(sortTerm)) { compareTerm = sortTerm; } Matcher m = p.matcher(compareTerm); if (m.find()) { BrowseTerm browseTerm = terms.get(term); if (browseTerm == null) { browseTerm = new BrowseTerm(term, sortTerm, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(term) : null); terms.put(term, browseTerm); } sortTerm = null; browseTerm.addToHitCount(1); usedTermsInCurrentDoc.add(term); } } } } else { String facetField = SearchHelper.facetifyField(bmfc.getField()); if (resp.getResults().isEmpty() && resp.getFacetField(facetField) != null) { logger.trace("using faceting: {}", facetField); for (Count count : resp.getFacetField(facetField).getValues()) { terms.put(count.getName(), new BrowseTerm(count.getName(), null, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(count.getName()) : null) .setHitCount(count.getCount())); } } else { for (SolrDocument doc : resp.getResults()) { processSolrResult(doc, bmfc, startsWith, terms, aggregateHits); } } } } catch (PresentationException e) { logger.debug("PresentationException thrown here: {}", e.getMessage()); throw new PresentationException(e.getMessage()); } if (!terms.isEmpty()) { ret = new ArrayList<>(terms.values()); if (comparator != null) { Collections.sort(ret, comparator); } } logger.debug("getFilteredTerms end: {} terms found.", ret.size()); return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows, Comparator<BrowseTerm> comparator, boolean aggregateHits) throws PresentationException, IndexUnreachableException { if (bmfc == null) { throw new IllegalArgumentException("bmfc may not be null"); } logger.trace("getFilteredTerms: {}", bmfc.getField()); List<BrowseTerm> ret = new ArrayList<>(); ConcurrentMap<String, BrowseTerm> terms = new ConcurrentHashMap<>(); if (bmfc.isRecordsAndAnchorsOnly()) { rows = 0; } try { List<StringPair> sortFields = StringUtils.isEmpty(bmfc.getSortField()) ? null : Collections.singletonList(new StringPair(bmfc.getSortField(), "asc")); QueryResponse resp = getFilteredTermsFromIndex(bmfc, startsWith, filterQuery, sortFields, start, rows); if ("0-9".equals(startsWith)) { Pattern p = Pattern.compile("[\\d]"); for (SolrDocument doc : resp.getResults()) { Collection<Object> termList = doc.getFieldValues(bmfc.getField()); String sortTerm = (String) doc.getFieldValue(bmfc.getSortField()); Set<String> usedTermsInCurrentDoc = new HashSet<>(); for (Object o : termList) { String term = String.valueOf(o); if (usedTermsInCurrentDoc.contains(term)) { continue; } String termStart = term; if (termStart.length() > 1) { termStart = term.substring(0, 1); } String compareTerm = termStart; if (StringUtils.isNotEmpty(sortTerm)) { compareTerm = sortTerm; } Matcher m = p.matcher(compareTerm); if (m.find()) { BrowseTerm browseTerm = terms.get(term); if (browseTerm == null) { browseTerm = new BrowseTerm(term, sortTerm, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(term) : null); terms.put(term, browseTerm); } sortTerm = null; browseTerm.addToHitCount(1); usedTermsInCurrentDoc.add(term); } } } } else { String facetField = SearchHelper.facetifyField(bmfc.getField()); if (resp.getResults().isEmpty() && resp.getFacetField(facetField) != null) { logger.trace("using faceting: {}", facetField); for (Count count : resp.getFacetField(facetField).getValues()) { terms.put(count.getName(), new BrowseTerm(count.getName(), null, bmfc.isTranslate() ? ViewerResourceBundle.getTranslations(count.getName()) : null) .setHitCount(count.getCount())); } } else { for (SolrDocument doc : resp.getResults()) { processSolrResult(doc, bmfc, startsWith, terms, aggregateHits); } } } } catch (PresentationException e) { logger.debug("PresentationException thrown here: {}", e.getMessage()); throw new PresentationException(e.getMessage()); } if (!terms.isEmpty()) { ret = new ArrayList<>(terms.values()); if (comparator != null) { Collections.sort(ret, comparator); } } logger.debug("getFilteredTerms end: {} terms found.", ret.size()); return ret; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void generateQueryParams_shouldReturnEmptyMapIfSearchHitAggregationOn() throws Exception { DataManager.getInstance().getConfiguration().overrideValue("search.aggregateHits", true); Map<String, String> params = SearchHelper.generateQueryParams(); }
|
public static Map<String, String> generateQueryParams() { Map<String, String> params = new HashMap<>(); if (DataManager.getInstance().getConfiguration().isAggregateHits()) { return params; } if (DataManager.getInstance().getConfiguration().isGroupDuplicateHits()) { params.put(GroupParams.GROUP, "true"); params.put(GroupParams.GROUP_MAIN, "true"); params.put(GroupParams.GROUP_FIELD, SolrConstants.GROUPFIELD); } if (DataManager.getInstance().getConfiguration().isBoostTopLevelDocstructs()) { params.put("defType", "edismax"); params.put("bq", "ISANCHOR:true^10 OR ISWORK:true^5"); } return params; }
|
SearchHelper { public static Map<String, String> generateQueryParams() { Map<String, String> params = new HashMap<>(); if (DataManager.getInstance().getConfiguration().isAggregateHits()) { return params; } if (DataManager.getInstance().getConfiguration().isGroupDuplicateHits()) { params.put(GroupParams.GROUP, "true"); params.put(GroupParams.GROUP_MAIN, "true"); params.put(GroupParams.GROUP_FIELD, SolrConstants.GROUPFIELD); } if (DataManager.getInstance().getConfiguration().isBoostTopLevelDocstructs()) { params.put("defType", "edismax"); params.put("bq", "ISANCHOR:true^10 OR ISWORK:true^5"); } return params; } }
|
SearchHelper { public static Map<String, String> generateQueryParams() { Map<String, String> params = new HashMap<>(); if (DataManager.getInstance().getConfiguration().isAggregateHits()) { return params; } if (DataManager.getInstance().getConfiguration().isGroupDuplicateHits()) { params.put(GroupParams.GROUP, "true"); params.put(GroupParams.GROUP_MAIN, "true"); params.put(GroupParams.GROUP_FIELD, SolrConstants.GROUPFIELD); } if (DataManager.getInstance().getConfiguration().isBoostTopLevelDocstructs()) { params.put("defType", "edismax"); params.put("bq", "ISANCHOR:true^10 OR ISWORK:true^5"); } return params; } }
|
SearchHelper { public static Map<String, String> generateQueryParams() { Map<String, String> params = new HashMap<>(); if (DataManager.getInstance().getConfiguration().isAggregateHits()) { return params; } if (DataManager.getInstance().getConfiguration().isGroupDuplicateHits()) { params.put(GroupParams.GROUP, "true"); params.put(GroupParams.GROUP_MAIN, "true"); params.put(GroupParams.GROUP_FIELD, SolrConstants.GROUPFIELD); } if (DataManager.getInstance().getConfiguration().isBoostTopLevelDocstructs()) { params.put("defType", "edismax"); params.put("bq", "ISANCHOR:true^10 OR ISWORK:true^5"); } return params; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); }
|
SearchHelper { public static Map<String, String> generateQueryParams() { Map<String, String> params = new HashMap<>(); if (DataManager.getInstance().getConfiguration().isAggregateHits()) { return params; } if (DataManager.getInstance().getConfiguration().isGroupDuplicateHits()) { params.put(GroupParams.GROUP, "true"); params.put(GroupParams.GROUP_MAIN, "true"); params.put(GroupParams.GROUP_FIELD, SolrConstants.GROUPFIELD); } if (DataManager.getInstance().getConfiguration().isBoostTopLevelDocstructs()) { params.put("defType", "edismax"); params.put("bq", "ISANCHOR:true^10 OR ISWORK:true^5"); } return params; } static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request); static List<SearchHit> searchWithFulltext(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
HttpServletRequest request, boolean keepSolrDoc); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale); static List<SearchHit> searchWithAggregation(String query, int first, int rows, List<StringPair> sortFields, List<String> resultFields,
List<String> filterQueries, Map<String, String> params, Map<String, Set<String>> searchTerms, List<String> exportFields, Locale locale,
boolean keepSolrDoc); static String getAllSuffixes(HttpServletRequest request, boolean addStaticQuerySuffix,
boolean addCollectionBlacklistSuffix); static String getAllSuffixes(); static String getAllSuffixesExceptCollectionBlacklist(); static BrowseElement getBrowseElement(String query, int index, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static StringPair getFirstRecordURL(String luceneField, String value, boolean filterForWhitelist,
boolean filterForBlacklist, String separatorString, Locale locale); static Map<String, CollectionResult> findAllCollectionsFromField(String luceneField, String facetField, String filterQuery,
boolean filterForWhitelist, boolean filterForBlacklist, String splittingChar); static QueryResponse searchCalendar(String query, List<String> facetFields, int facetMinCount, boolean getFieldStatistics); static int[] getMinMaxYears(String subQuery); static List<String> searchAutosuggestion(String suggest, List<FacetItem> currentFacets); static String getCollectionBlacklistFilterSuffix(String field); static String getDiscriminatorFieldFilterSuffix(NavigationHelper nh, String discriminatorField); static void updateFilterQuerySuffix(HttpServletRequest request); static String getPersonalFilterQuerySuffix(User user, String ipAddress); static List<String> truncateFulltext(Set<String> searchTerms, String fulltext, int targetFragmentLength, boolean firstMatchOnly,
boolean addFragmentIfNoMatches); static String applyHighlightingToPhrase(String phrase, Set<String> terms); static String replaceHighlightingPlaceholdersForHyperlinks(String phrase); static String replaceHighlightingPlaceholders(String phrase); static String removeHighlightingTags(String phrase); static List<String> getFacetValues(String query, String facetFieldName, int facetMinCount); static List<String> getFacetValues(String query, String facetFieldName, String facetPrefix, int facetMinCount); static int getFilteredTermsCount(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery); static List<BrowseTerm> getFilteredTerms(BrowsingMenuFieldConfig bmfc, String startsWith, String filterQuery, int start, int rows,
Comparator<BrowseTerm> comparator, boolean aggregateHits); static Map<String, Set<String>> extractSearchTermsFromQuery(String query, String discriminatorValue); static String removeTruncation(String value); static Map<String, String> generateQueryParams(); static List<String> facetifyList(List<String> sourceList); static String facetifyField(String fieldName); static String sortifyField(String fieldName); static String normalizeField(String fieldName); static String defacetifyField(String fieldName); static String generateExpandQuery(List<String> fields, Map<String, Set<String>> searchTerms, boolean phraseSearch); static String generateAdvancedExpandQuery(List<SearchQueryGroup> groups, int advancedSearchGroupOperator); static List<String> getExpandQueryFieldList(int searchType, SearchFilter searchFilter, List<SearchQueryGroup> queryGroups); static String prepareQuery(String query); static String prepareQuery(String query, String docstructWhitelistFilterQuery); static String buildFinalQuery(String rawQuery, boolean aggregateHits); static String buildFinalQuery(String rawQuery, boolean aggregateHits, HttpServletRequest request); static SXSSFWorkbook exportSearchAsExcel(String finalQuery, String exportQuery, List<StringPair> sortFields, List<String> filterQueries,
Map<String, String> params, Map<String, Set<String>> searchTerms, Locale locale, boolean aggregateHits, HttpServletRequest request); static List<String> getAllFacetFields(List<String> hierarchicalFacetFields); static List<StringPair> parseSortString(String sortString, NavigationHelper navigationHelper); static Map<String, String> getExpandQueryParams(String expandQuery); static String cleanUpSearchTerm(String s); static final String PARAM_NAME_FILTER_QUERY_SUFFIX; static final String SEARCH_TERM_SPLIT_REGEX; static final String PLACEHOLDER_HIGHLIGHTING_START; static final String PLACEHOLDER_HIGHLIGHTING_END; static final int SEARCH_TYPE_REGULAR; static final int SEARCH_TYPE_ADVANCED; static final int SEARCH_TYPE_TIMELINE; static final int SEARCH_TYPE_CALENDAR; static final SearchFilter SEARCH_FILTER_ALL; static final String ALL_RECORDS_QUERY; static final String DEFAULT_DOCSTRCT_WHITELIST_FILTER_QUERY; static Pattern patternNotBrackets; static Pattern patternPhrase; }
|
@Test public void compare_shouldCompareCorrectly() throws Exception { BrowseTermComparator comparator = new BrowseTermComparator(null); Assert.assertEquals(1, comparator.compare(new BrowseTerm("foo", null, null), new BrowseTerm("bar", null, null))); Assert.assertEquals(-1, comparator.compare(new BrowseTerm("A", null, null), new BrowseTerm("Á", null, null))); Assert.assertEquals(-1, comparator.compare(new BrowseTerm("Azcárate", null, null), new BrowseTerm("Ávila", null, null))); Assert.assertEquals(0, comparator.compare(new BrowseTerm("foo123", null, null), new BrowseTerm("foo123", null, null))); Assert.assertEquals(-1, comparator.compare(new BrowseTerm("foo12", null, null), new BrowseTerm("foo123", null, null))); Assert.assertEquals(-1, comparator.compare(new BrowseTerm("12foo", null, null), new BrowseTerm("123foo", null, null))); }
|
@Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
@Test public void compare_shouldUseSortTermIfProvided() throws Exception { Assert.assertEquals(-1, new BrowseTermComparator(null).compare(new BrowseTerm("foo", "1", null), new BrowseTerm("bar", "2", null))); }
|
@Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
@Test public void normalizeUsername_shouldNormalizeValueCorrectly() throws Exception { Assert.assertEquals("00001234567", BibliothecaAuthenticationRequest.normalizeUsername("1234567")); }
|
static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < 11; ++i) { sb.append('0'); } sb.append(username); return sb.toString(); } return username; }
|
BibliothecaAuthenticationRequest extends UserPasswordAuthenticationRequest { static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < 11; ++i) { sb.append('0'); } sb.append(username); return sb.toString(); } return username; } }
|
BibliothecaAuthenticationRequest extends UserPasswordAuthenticationRequest { static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < 11; ++i) { sb.append('0'); } sb.append(username); return sb.toString(); } return username; } BibliothecaAuthenticationRequest(String username, String password); }
|
BibliothecaAuthenticationRequest extends UserPasswordAuthenticationRequest { static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < 11; ++i) { sb.append('0'); } sb.append(username); return sb.toString(); } return username; } BibliothecaAuthenticationRequest(String username, String password); @Override String toString(); }
|
BibliothecaAuthenticationRequest extends UserPasswordAuthenticationRequest { static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < 11; ++i) { sb.append('0'); } sb.append(username); return sb.toString(); } return username; } BibliothecaAuthenticationRequest(String username, String password); @Override String toString(); }
|
@Test public void compare_shouldUseTranslatedTermIfProvided() throws Exception { Map<String, String> translations1 = new HashMap<>(); translations1.put("de", "Deutsch"); translations1.put("en", "German"); Map<String, String> translations2 = new HashMap<>(); translations2.put("de", "Englisch"); translations2.put("en", "English"); Assert.assertEquals(-1, new BrowseTermComparator(Locale.GERMAN).compare(new BrowseTerm("ger", null, new MultiLanguageMetadataValue(translations1)), new BrowseTerm("eng", null, new MultiLanguageMetadataValue(translations2)))); Assert.assertEquals(1, new BrowseTermComparator(Locale.ENGLISH).compare(new BrowseTerm("ger", null, new MultiLanguageMetadataValue(translations1)), new BrowseTerm("eng", null, new MultiLanguageMetadataValue(translations2)))); }
|
@Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
@Test public void compare_shouldSortAccentedVowelsAfterPlainVowels() throws Exception { Assert.assertEquals(-1, new BrowseTermComparator(null).compare(new BrowseTerm("arm", null, null), new BrowseTerm("árm", null, null))); }
|
@Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { @Override public int compare(BrowseTerm o1, BrowseTerm o2) { BrowseTerm o1a = o1; BrowseTerm o2a = o2; String relevantString1 = o1a.getTerm(); if (StringUtils.isNotEmpty(relevantString1)) { if (o1a.getSortTerm() != null) { relevantString1 = o1a.getSortTerm().toLowerCase(); } else if (o1a.getTranslations() != null && o1a.getTranslations().getValue(locale) != null && o1a.getTranslations().getValue(locale).isPresent()) { relevantString1 = o1a.getTranslations().getValue(locale).get(); } else { relevantString1 = relevantString1.toLowerCase(); } } relevantString1 = normalizeString(relevantString1, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); String relevantString2 = o2a.getTerm(); if (StringUtils.isNotEmpty(relevantString2)) { if (o2a.getSortTerm() != null) { relevantString2 = o2a.getSortTerm().toLowerCase(); } else if (o2a.getTranslations() != null && o2a.getTranslations().getValue(locale) != null && o2a.getTranslations().getValue(locale).isPresent()) { relevantString2 = o2a.getTranslations().getValue(locale).get(); } else { relevantString2 = relevantString2.toLowerCase(); } } relevantString2 = normalizeString(relevantString2, DataManager.getInstance().getConfiguration().getBrowsingMenuSortingIgnoreLeadingChars()); return comparator.compare(relevantString1, relevantString2); } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
@Test public void normalizeString_shouldUseIgnoreCharsIfProvided() throws Exception { Assert.assertEquals("#.foo", BrowseTermComparator.normalizeString("[.]#.foo", ".[]")); }
|
public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } BrowseTermComparator(Locale locale); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
@Test public void normalizeString_shouldRemoveFirstCharIfNonAlphanumIfIgnoreCharsNotProvided() throws Exception { Assert.assertEquals(".]#.foo", BrowseTermComparator.normalizeString("[.]#.foo", null)); }
|
public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } BrowseTermComparator(Locale locale); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } } else { if (s.length() > 1 && !StringUtils.isAlphanumeric(s.substring(0, 1))) { s = s.substring(1); } } return s; } BrowseTermComparator(Locale locale); @Override int compare(BrowseTerm o1, BrowseTerm o2); static String normalizeString(String s, String ignoreChars); }
|
@Test public void generateDownloadJobId_shouldGenerateSameIdFromSameCriteria() throws Exception { String hash = "78acb5991aaf0fee0329b673e985ce82"; String crit1 = "PPN123456789"; String crit2 = "LOG_0000"; Assert.assertEquals(hash, DownloadJob.generateDownloadJobId(crit1, crit2)); Assert.assertEquals(hash, DownloadJob.generateDownloadJobId(crit1, crit2)); Assert.assertEquals(hash, DownloadJob.generateDownloadJobId(crit1, crit2)); }
|
public static String generateDownloadJobId(String... criteria) { StringBuilder sbCriteria = new StringBuilder(criteria.length * 10); for (String criterion : criteria) { if (criterion != null) { sbCriteria.append(criterion); } } return StringTools.generateMD5(sbCriteria.toString()); }
|
DownloadJob implements Serializable { public static String generateDownloadJobId(String... criteria) { StringBuilder sbCriteria = new StringBuilder(criteria.length * 10); for (String criterion : criteria) { if (criterion != null) { sbCriteria.append(criterion); } } return StringTools.generateMD5(sbCriteria.toString()); } }
|
DownloadJob implements Serializable { public static String generateDownloadJobId(String... criteria) { StringBuilder sbCriteria = new StringBuilder(criteria.length * 10); for (String criterion : criteria) { if (criterion != null) { sbCriteria.append(criterion); } } return StringTools.generateMD5(sbCriteria.toString()); } }
|
DownloadJob implements Serializable { public static String generateDownloadJobId(String... criteria) { StringBuilder sbCriteria = new StringBuilder(criteria.length * 10); for (String criterion : criteria) { if (criterion != null) { sbCriteria.append(criterion); } } return StringTools.generateMD5(sbCriteria.toString()); } abstract void generateDownloadIdentifier(); static String generateDownloadJobId(String... criteria); static DownloadJob checkDownload(String type, final String email, String pi, String logId, String downloadIdentifier, long ttl); static boolean ocrFolderExists(String pi); static int cleanupExpiredDownloads(); boolean isExpired(); @JsonIgnore abstract String getMimeType(); @JsonIgnore abstract String getFileExtension(); @JsonIgnore abstract String getDisplayName(); abstract long getSize(); abstract int getQueuePosition(); @JsonIgnore Path getFile(); boolean notifyObservers(JobStatus status, String message); File getDownloadFile(String pi, final String logId, String type); Long getId(); void setId(Long id); String getType(); String getPi(); void setPi(String pi); String getLogId(); void setLogId(String logId); String getIdentifier(); void setIdentifier(String identifier); @JsonFormat(pattern = DATETIME_FORMAT) Date getLastRequested(); void setLastRequested(Date lastRequested); @JsonIgnore long getTtl(); String getTimeToLive(); void setTtl(long ttl); JobStatus getStatus(); void setStatus(JobStatus status); String getDescription(); void setDescription(String description); @JsonIgnore List<String> getObservers(); void setObservers(List<String> observers); void resetObservers(); String getMessage(); void setMessage(String message); static Response postJobRequest(String url, AbstractTaskManagerRequest body); String getJobStatus(String identifier); void updateStatus(); @Override String toString(); }
|
DownloadJob implements Serializable { public static String generateDownloadJobId(String... criteria) { StringBuilder sbCriteria = new StringBuilder(criteria.length * 10); for (String criterion : criteria) { if (criterion != null) { sbCriteria.append(criterion); } } return StringTools.generateMD5(sbCriteria.toString()); } abstract void generateDownloadIdentifier(); static String generateDownloadJobId(String... criteria); static DownloadJob checkDownload(String type, final String email, String pi, String logId, String downloadIdentifier, long ttl); static boolean ocrFolderExists(String pi); static int cleanupExpiredDownloads(); boolean isExpired(); @JsonIgnore abstract String getMimeType(); @JsonIgnore abstract String getFileExtension(); @JsonIgnore abstract String getDisplayName(); abstract long getSize(); abstract int getQueuePosition(); @JsonIgnore Path getFile(); boolean notifyObservers(JobStatus status, String message); File getDownloadFile(String pi, final String logId, String type); Long getId(); void setId(Long id); String getType(); String getPi(); void setPi(String pi); String getLogId(); void setLogId(String logId); String getIdentifier(); void setIdentifier(String identifier); @JsonFormat(pattern = DATETIME_FORMAT) Date getLastRequested(); void setLastRequested(Date lastRequested); @JsonIgnore long getTtl(); String getTimeToLive(); void setTtl(long ttl); JobStatus getStatus(); void setStatus(JobStatus status); String getDescription(); void setDescription(String description); @JsonIgnore List<String> getObservers(); void setObservers(List<String> observers); void resetObservers(); String getMessage(); void setMessage(String message); static Response postJobRequest(String url, AbstractTaskManagerRequest body); String getJobStatus(String identifier); void updateStatus(); @Override String toString(); }
|
@Test public void getCurrentPartnerPage_shouldReturnValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.statusMap.put(NavigationHelper.KEY_CURRENT_PARTNER_PAGE, NavigationHelper.KEY_CURRENT_PARTNER_PAGE + "_value"); Assert.assertEquals(NavigationHelper.KEY_CURRENT_PARTNER_PAGE + "_value", nh.getCurrentPartnerPage()); }
|
public String getCurrentPartnerPage() { return statusMap.get(KEY_CURRENT_PARTNER_PAGE); }
|
NavigationHelper implements Serializable { public String getCurrentPartnerPage() { return statusMap.get(KEY_CURRENT_PARTNER_PAGE); } }
|
NavigationHelper implements Serializable { public String getCurrentPartnerPage() { return statusMap.get(KEY_CURRENT_PARTNER_PAGE); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public String getCurrentPartnerPage() { return statusMap.get(KEY_CURRENT_PARTNER_PAGE); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public String getCurrentPartnerPage() { return statusMap.get(KEY_CURRENT_PARTNER_PAGE); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void getCurrentView_shouldReturnValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.statusMap.put(NavigationHelper.KEY_CURRENT_VIEW, NavigationHelper.KEY_CURRENT_VIEW + "_value"); Assert.assertEquals(NavigationHelper.KEY_CURRENT_VIEW + "_value", nh.getCurrentView()); }
|
public String getCurrentView() { return statusMap.get(KEY_CURRENT_VIEW); }
|
NavigationHelper implements Serializable { public String getCurrentView() { return statusMap.get(KEY_CURRENT_VIEW); } }
|
NavigationHelper implements Serializable { public String getCurrentView() { return statusMap.get(KEY_CURRENT_VIEW); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public String getCurrentView() { return statusMap.get(KEY_CURRENT_VIEW); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public String getCurrentView() { return statusMap.get(KEY_CURRENT_VIEW); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void getMenuPage_shouldReturnValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.statusMap.put(NavigationHelper.KEY_MENU_PAGE, NavigationHelper.KEY_MENU_PAGE + "_value"); Assert.assertEquals(NavigationHelper.KEY_MENU_PAGE + "_value", nh.getMenuPage()); }
|
public String getMenuPage() { return statusMap.get(KEY_MENU_PAGE); }
|
NavigationHelper implements Serializable { public String getMenuPage() { return statusMap.get(KEY_MENU_PAGE); } }
|
NavigationHelper implements Serializable { public String getMenuPage() { return statusMap.get(KEY_MENU_PAGE); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public String getMenuPage() { return statusMap.get(KEY_MENU_PAGE); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public String getMenuPage() { return statusMap.get(KEY_MENU_PAGE); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void getPreferredView_shouldReturnValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.statusMap.put(NavigationHelper.KEY_PREFERRED_VIEW, NavigationHelper.KEY_PREFERRED_VIEW + "_value"); Assert.assertEquals(NavigationHelper.KEY_PREFERRED_VIEW + "_value", nh.getPreferredView()); }
|
public String getPreferredView() { return statusMap.get(KEY_PREFERRED_VIEW); }
|
NavigationHelper implements Serializable { public String getPreferredView() { return statusMap.get(KEY_PREFERRED_VIEW); } }
|
NavigationHelper implements Serializable { public String getPreferredView() { return statusMap.get(KEY_PREFERRED_VIEW); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public String getPreferredView() { return statusMap.get(KEY_PREFERRED_VIEW); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public String getPreferredView() { return statusMap.get(KEY_PREFERRED_VIEW); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void getSelectedNewsArticle_shouldReturnValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.statusMap.put(NavigationHelper.KEY_SELECTED_NEWS_ARTICLE, NavigationHelper.KEY_SELECTED_NEWS_ARTICLE + "_value"); Assert.assertEquals(NavigationHelper.KEY_SELECTED_NEWS_ARTICLE + "_value", nh.getSelectedNewsArticle()); }
|
public String getSelectedNewsArticle() { return statusMap.get(KEY_SELECTED_NEWS_ARTICLE); }
|
NavigationHelper implements Serializable { public String getSelectedNewsArticle() { return statusMap.get(KEY_SELECTED_NEWS_ARTICLE); } }
|
NavigationHelper implements Serializable { public String getSelectedNewsArticle() { return statusMap.get(KEY_SELECTED_NEWS_ARTICLE); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public String getSelectedNewsArticle() { return statusMap.get(KEY_SELECTED_NEWS_ARTICLE); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public String getSelectedNewsArticle() { return statusMap.get(KEY_SELECTED_NEWS_ARTICLE); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void testLogin() throws AuthenticationProviderException, InterruptedException, ExecutionException { Assert.assertFalse(provider.login(user_id, user_pw).get().isRefused()); Assert.assertTrue(provider.login(user_id_invalid, user_pw).get().isRefused()); Assert.assertTrue(provider.login(user_id, user_pw_invalid).get().isRefused()); }
|
@Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(loginName, response); LoginResult result = new LoginResult(BeanUtils.getRequest(), BeanUtils.getResponse(), user, !response.isAuthenticationSuccessful()); return CompletableFuture.completedFuture(result); } catch (URISyntaxException e) { throw new AuthenticationProviderException("Cannot resolve authentication api url " + getUrl(), e); } catch (IOException e) { throw new AuthenticationProviderException("Error requesting authorisation for user " + loginName, e); } }
|
LitteraProvider extends HttpAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(loginName, response); LoginResult result = new LoginResult(BeanUtils.getRequest(), BeanUtils.getResponse(), user, !response.isAuthenticationSuccessful()); return CompletableFuture.completedFuture(result); } catch (URISyntaxException e) { throw new AuthenticationProviderException("Cannot resolve authentication api url " + getUrl(), e); } catch (IOException e) { throw new AuthenticationProviderException("Error requesting authorisation for user " + loginName, e); } } }
|
LitteraProvider extends HttpAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(loginName, response); LoginResult result = new LoginResult(BeanUtils.getRequest(), BeanUtils.getResponse(), user, !response.isAuthenticationSuccessful()); return CompletableFuture.completedFuture(result); } catch (URISyntaxException e) { throw new AuthenticationProviderException("Cannot resolve authentication api url " + getUrl(), e); } catch (IOException e) { throw new AuthenticationProviderException("Error requesting authorisation for user " + loginName, e); } } LitteraProvider(String name, String label, String url, String image, long timeoutMillis); }
|
LitteraProvider extends HttpAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(loginName, response); LoginResult result = new LoginResult(BeanUtils.getRequest(), BeanUtils.getResponse(), user, !response.isAuthenticationSuccessful()); return CompletableFuture.completedFuture(result); } catch (URISyntaxException e) { throw new AuthenticationProviderException("Cannot resolve authentication api url " + getUrl(), e); } catch (IOException e) { throw new AuthenticationProviderException("Error requesting authorisation for user " + loginName, e); } } LitteraProvider(String name, String label, String url, String image, long timeoutMillis); @Override void logout(); @Override CompletableFuture<LoginResult> login(String loginName, String password); @Override boolean allowsPasswordChange(); @Override boolean allowsNicknameChange(); @Override boolean allowsEmailChange(); }
|
LitteraProvider extends HttpAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(loginName, response); LoginResult result = new LoginResult(BeanUtils.getRequest(), BeanUtils.getResponse(), user, !response.isAuthenticationSuccessful()); return CompletableFuture.completedFuture(result); } catch (URISyntaxException e) { throw new AuthenticationProviderException("Cannot resolve authentication api url " + getUrl(), e); } catch (IOException e) { throw new AuthenticationProviderException("Error requesting authorisation for user " + loginName, e); } } LitteraProvider(String name, String label, String url, String image, long timeoutMillis); @Override void logout(); @Override CompletableFuture<LoginResult> login(String loginName, String password); @Override boolean allowsPasswordChange(); @Override boolean allowsNicknameChange(); @Override boolean allowsEmailChange(); }
|
@Test public void getStatusMapValue_shouldReturnValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.statusMap.put("new_key", "new_value"); Assert.assertEquals("new_value", nh.getStatusMapValue("new_key")); }
|
public String getStatusMapValue(String key) { return statusMap.get(key); }
|
NavigationHelper implements Serializable { public String getStatusMapValue(String key) { return statusMap.get(key); } }
|
NavigationHelper implements Serializable { public String getStatusMapValue(String key) { return statusMap.get(key); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public String getStatusMapValue(String key) { return statusMap.get(key); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public String getStatusMapValue(String key) { return statusMap.get(key); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void setCurrentPartnerPage_shouldSetValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setCurrentPartnerPage(NavigationHelper.KEY_CURRENT_PARTNER_PAGE + "_value"); Assert.assertEquals(NavigationHelper.KEY_CURRENT_PARTNER_PAGE + "_value", nh.statusMap.get(NavigationHelper.KEY_CURRENT_PARTNER_PAGE)); }
|
public void setCurrentPartnerPage(String currentPartnerPage) { statusMap.put(KEY_CURRENT_PARTNER_PAGE, currentPartnerPage); logger.trace("current Partner Page: {}", currentPartnerPage); }
|
NavigationHelper implements Serializable { public void setCurrentPartnerPage(String currentPartnerPage) { statusMap.put(KEY_CURRENT_PARTNER_PAGE, currentPartnerPage); logger.trace("current Partner Page: {}", currentPartnerPage); } }
|
NavigationHelper implements Serializable { public void setCurrentPartnerPage(String currentPartnerPage) { statusMap.put(KEY_CURRENT_PARTNER_PAGE, currentPartnerPage); logger.trace("current Partner Page: {}", currentPartnerPage); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public void setCurrentPartnerPage(String currentPartnerPage) { statusMap.put(KEY_CURRENT_PARTNER_PAGE, currentPartnerPage); logger.trace("current Partner Page: {}", currentPartnerPage); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public void setCurrentPartnerPage(String currentPartnerPage) { statusMap.put(KEY_CURRENT_PARTNER_PAGE, currentPartnerPage); logger.trace("current Partner Page: {}", currentPartnerPage); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void setCurrentView_shouldSetValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setCurrentView(NavigationHelper.KEY_CURRENT_VIEW + "_value"); Assert.assertEquals(NavigationHelper.KEY_CURRENT_VIEW + "_value", nh.statusMap.get(NavigationHelper.KEY_CURRENT_VIEW)); }
|
public void setCurrentView(String currentView) { logger.trace("{}: {}", KEY_CURRENT_VIEW, currentView); statusMap.put(KEY_CURRENT_VIEW, currentView); setCurrentPage(currentView); }
|
NavigationHelper implements Serializable { public void setCurrentView(String currentView) { logger.trace("{}: {}", KEY_CURRENT_VIEW, currentView); statusMap.put(KEY_CURRENT_VIEW, currentView); setCurrentPage(currentView); } }
|
NavigationHelper implements Serializable { public void setCurrentView(String currentView) { logger.trace("{}: {}", KEY_CURRENT_VIEW, currentView); statusMap.put(KEY_CURRENT_VIEW, currentView); setCurrentPage(currentView); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public void setCurrentView(String currentView) { logger.trace("{}: {}", KEY_CURRENT_VIEW, currentView); statusMap.put(KEY_CURRENT_VIEW, currentView); setCurrentPage(currentView); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public void setCurrentView(String currentView) { logger.trace("{}: {}", KEY_CURRENT_VIEW, currentView); statusMap.put(KEY_CURRENT_VIEW, currentView); setCurrentPage(currentView); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void setMenuPage_shouldSetValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setMenuPage(NavigationHelper.KEY_MENU_PAGE + "_value"); Assert.assertEquals(NavigationHelper.KEY_MENU_PAGE + "_value", nh.statusMap.get(NavigationHelper.KEY_MENU_PAGE)); }
|
public void setMenuPage(String page) { logger.debug("Menu Page ist: " + page); statusMap.put(KEY_MENU_PAGE, page); }
|
NavigationHelper implements Serializable { public void setMenuPage(String page) { logger.debug("Menu Page ist: " + page); statusMap.put(KEY_MENU_PAGE, page); } }
|
NavigationHelper implements Serializable { public void setMenuPage(String page) { logger.debug("Menu Page ist: " + page); statusMap.put(KEY_MENU_PAGE, page); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public void setMenuPage(String page) { logger.debug("Menu Page ist: " + page); statusMap.put(KEY_MENU_PAGE, page); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public void setMenuPage(String page) { logger.debug("Menu Page ist: " + page); statusMap.put(KEY_MENU_PAGE, page); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void setPreferredView_shouldSetValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setPreferredView(NavigationHelper.KEY_PREFERRED_VIEW + "_value"); Assert.assertEquals(NavigationHelper.KEY_PREFERRED_VIEW + "_value", nh.statusMap.get(NavigationHelper.KEY_PREFERRED_VIEW)); }
|
public void setPreferredView(String preferredView) { statusMap.put(KEY_PREFERRED_VIEW, preferredView); }
|
NavigationHelper implements Serializable { public void setPreferredView(String preferredView) { statusMap.put(KEY_PREFERRED_VIEW, preferredView); } }
|
NavigationHelper implements Serializable { public void setPreferredView(String preferredView) { statusMap.put(KEY_PREFERRED_VIEW, preferredView); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public void setPreferredView(String preferredView) { statusMap.put(KEY_PREFERRED_VIEW, preferredView); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public void setPreferredView(String preferredView) { statusMap.put(KEY_PREFERRED_VIEW, preferredView); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void setSelectedNewsArticle_shouldSetValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setSelectedNewsArticle(NavigationHelper.KEY_SELECTED_NEWS_ARTICLE + "_value"); Assert.assertEquals(NavigationHelper.KEY_SELECTED_NEWS_ARTICLE + "_value", nh.statusMap.get(NavigationHelper.KEY_SELECTED_NEWS_ARTICLE)); }
|
public void setSelectedNewsArticle(String art) { statusMap.put(KEY_SELECTED_NEWS_ARTICLE, art); }
|
NavigationHelper implements Serializable { public void setSelectedNewsArticle(String art) { statusMap.put(KEY_SELECTED_NEWS_ARTICLE, art); } }
|
NavigationHelper implements Serializable { public void setSelectedNewsArticle(String art) { statusMap.put(KEY_SELECTED_NEWS_ARTICLE, art); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public void setSelectedNewsArticle(String art) { statusMap.put(KEY_SELECTED_NEWS_ARTICLE, art); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public void setSelectedNewsArticle(String art) { statusMap.put(KEY_SELECTED_NEWS_ARTICLE, art); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void setStatusMapValue_shouldSetValueCorrectly() throws Exception { NavigationHelper nh = new NavigationHelper(); nh.setStatusMapValue("new_key", "new_value"); Assert.assertEquals("new_value", nh.statusMap.get("new_key")); }
|
public void setStatusMapValue(String key, String value) { statusMap.put(key, value); }
|
NavigationHelper implements Serializable { public void setStatusMapValue(String key, String value) { statusMap.put(key, value); } }
|
NavigationHelper implements Serializable { public void setStatusMapValue(String key, String value) { statusMap.put(key, value); } NavigationHelper(); }
|
NavigationHelper implements Serializable { public void setStatusMapValue(String key, String value) { statusMap.put(key, value); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
NavigationHelper implements Serializable { public void setStatusMapValue(String key, String value) { statusMap.put(key, value); } NavigationHelper(); @PostConstruct void init(); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); String searchPage(); String homePage(); String browsePage(); String getCurrentPage(); boolean isCmsPage(); void setCmsPage(boolean isCmsPage); void setCurrentPage(String currentPage); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument); void setCurrentPage(String currentPage, boolean resetBreadcrubs, boolean resetCurrentDocument, boolean setCmsPage); void setCurrentBreadcrumbPage(String pageName, String pageWeight, String pageURL); void setCurrentPartnerPage(String currentPartnerPage); String getCurrentPartnerPage(); String getPreferredView(); void setPreferredView(String preferredView); void setCurrentPageIndex(); void setCurrentPageSearch(); void setCurrentPageBrowse(); void setCurrentPageBrowse(CollectionView collection); void setCurrentPageTags(); void setCurrentPageStatistics(); void setCrowdsourcingAnnotationPage(Campaign campaign, String pi, CampaignRecordStatus status); void setCurrentPageUser(); void setCurrentPageAdmin(String pageName); void setCurrentPageAdmin(); void setCurrentPageSitelinks(); void setCurrentPageTimeMatrix(); void setCurrentPageSearchTermList(); void resetCurrentPage(); String getViewAction(String view); String getCurrentView(); void setCurrentView(String currentView); Locale getDefaultLocale(); Locale getLocale(); String getLocaleString(); Iterator<Locale> getSupportedLocales(); List<String> getSupportedLanguages(); String getSupportedLanguagesAsJson(); void setLocaleString(String inLocale); String getDatePattern(); void reload(); String getApplicationUrl(); String getEncodedUrl(); String getCurrentUrl(); String getRssUrl(); String getRequestPath(ExternalContext externalContext); static String getRequestPath(HttpServletRequest request, String prettyFacesURI); static String getFullRequestUrl(HttpServletRequest request, String prettyFacesURI); String getCurrentPrettyUrl(); TimeZone getTimeZone(); void setMenuPage(String page); String getMenuPage(); @Deprecated String getActivePartnerId(); @Deprecated void setActivePartnerId(String activePartnerId); String getTheme(); String getSubThemeDiscriminatorValue(); String determineCurrentSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(); void setSubThemeDiscriminatorValue(String subThemeDiscriminatorValue); void resetTheme(); void setTheme(String theme); @Deprecated boolean isHtmlHeadDCMetadata(); String getObjectUrl(); String getImageUrl(); String getImageActiveUrl(); String getReadingModeUrl(); String getViewImagePathFullscreen(); String getCalendarUrl(); String getCalendarActiveUrl(); String getTocUrl(); String getTocActiveUrl(); String getThumbsUrl(); String getThumbsActiveUrl(); String getMetadataUrl(); String getMetadataActiveUrl(); String getFulltextUrl(); String getFulltextActiveUrl(); String getSearchUrl(); String getAdvancedSearchUrl(); String getPageUrl(String pageType); String getPageUrl(PageType page); String getSearchUrl(int activeSearchType); String getTermUrl(); String getBrowseUrl(); String getSortUrl(); void addStaticLinkToBreadcrumb(String linkName, int linkWeight); void addStaticLinkToBreadcrumb(String linkName, String url, int linkWeight); @Deprecated String getCurrentPartnerUrl(); String getLocalDate(Date date); List<String> getMessageValueList(String keyPrefix); void setSelectedNewsArticle(String art); String getSelectedNewsArticle(); String getLastRequestTimestamp(); String getStatusMapValue(String key); void setStatusMapValue(String key, String value); Map<String, String> getStatusMap(); void setStatusMap(Map<String, String> statusMap); String getTranslationWithParams(String msgKey, String... params); String getTranslation(String msgKey, String language); boolean isDisplayNoIndexMetaTag(); boolean isDocumentPage(); String getSubThemeDiscriminatorQuerySuffix(); PageType getCurrentPageType(); String getPreviousViewUrl(); void redirectToPreviousView(); String getCurrentViewUrl(); String getExitUrl(); String getExitUrl(PageType pageType); String resolvePrettyUrl(String prettyId, Object... parameters); void redirectToCurrentView(); String urlEncode(String s); String urlEncodeUnicode(String s); String getThemeOrSubtheme(); boolean isSubthemeSelected(); String getVersion(); String getPublicVersion(); String getBuildDate(); String getBuildVersion(); String getApplicationName(); @Deprecated String getBuildDate(String pattern); }
|
@Test public void testGetCampaignCount() throws DAOException { long numPublic = bean.getCampaignCount(CampaignVisibility.PUBLIC); long numPrivate = bean.getCampaignCount(CampaignVisibility.PRIVATE); long numRestricted = bean.getCampaignCount(CampaignVisibility.RESTRICTED); Assert.assertEquals(1, numPublic); Assert.assertEquals(1, numPrivate); Assert.assertEquals(0, numRestricted); }
|
public long getCampaignCount(CampaignVisibility visibility) throws DAOException { Map<String, String> filters = visibility != null ? Collections.singletonMap("visibility", visibility.name()) : null; return DataManager.getInstance().getDao().getCampaignCount(filters); }
|
CrowdsourcingBean implements Serializable { public long getCampaignCount(CampaignVisibility visibility) throws DAOException { Map<String, String> filters = visibility != null ? Collections.singletonMap("visibility", visibility.name()) : null; return DataManager.getInstance().getDao().getCampaignCount(filters); } }
|
CrowdsourcingBean implements Serializable { public long getCampaignCount(CampaignVisibility visibility) throws DAOException { Map<String, String> filters = visibility != null ? Collections.singletonMap("visibility", visibility.name()) : null; return DataManager.getInstance().getDao().getCampaignCount(filters); } }
|
CrowdsourcingBean implements Serializable { public long getCampaignCount(CampaignVisibility visibility) throws DAOException { Map<String, String> filters = visibility != null ? Collections.singletonMap("visibility", visibility.name()) : null; return DataManager.getInstance().getDao().getCampaignCount(filters); } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAction(CampaignVisibility visibility); static List<Locale> getAllLocales(); String createNewCampaignAction(); String editCampaignAction(Campaign campaign); String deleteCampaignAction(Campaign campaign); String addNewQuestionAction(); String removeQuestionAction(Question question); String resetDurationAction(); List<Campaign> getAllCampaigns(); List<Campaign> getAllCampaigns(CampaignVisibility visibility); List<Campaign> getAllowedCampaigns(User user); boolean isAllowed(User user, Campaign campaign); void saveSelectedCampaign(); String getCampaignsRootUrl(); TableDataProvider<Campaign> getLazyModelCampaigns(); TableDataProvider<PersistentAnnotation> getLazyModelAnnotations(); String deleteAnnotationAction(PersistentAnnotation annotation); Campaign getSelectedCampaign(); void setSelectedCampaign(Campaign selectedCampaign); boolean isEditMode(); void setEditMode(boolean editMode); String getSelectedCampaignId(); void setSelectedCampaignId(String id); Campaign getTargetCampaign(); void setTargetCampaign(Campaign targetCampaign); String getTargetCampaignId(); void setTargetCampaignId(String id); void setRandomIdentifierForAnnotation(); void setRandomIdentifierForReview(); void resetTarget(); String forwardToAnnotationTarget(); String forwardToReviewTarget(); String getTargetIdentifier(); String getTargetIdentifierForUrl(); void setTargetIdentifierForUrl(String pi); void setTargetIdentifier(String targetIdentifier); String forwardToCrowdsourcingAnnotation(Campaign campaign); String forwardToCrowdsourcingReview(Campaign campaign); String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi); String forwardToCrowdsourcingReview(Campaign campaign, String pi); String getRandomItemUrl(Campaign campaign, CampaignRecordStatus status); CampaignRecordStatus getTargetRecordStatus(); String handleInvalidTarget(); List<Campaign> getActiveCampaignsForRecord(String pi); void updateActiveCampaigns(); }
|
CrowdsourcingBean implements Serializable { public long getCampaignCount(CampaignVisibility visibility) throws DAOException { Map<String, String> filters = visibility != null ? Collections.singletonMap("visibility", visibility.name()) : null; return DataManager.getInstance().getDao().getCampaignCount(filters); } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAction(CampaignVisibility visibility); static List<Locale> getAllLocales(); String createNewCampaignAction(); String editCampaignAction(Campaign campaign); String deleteCampaignAction(Campaign campaign); String addNewQuestionAction(); String removeQuestionAction(Question question); String resetDurationAction(); List<Campaign> getAllCampaigns(); List<Campaign> getAllCampaigns(CampaignVisibility visibility); List<Campaign> getAllowedCampaigns(User user); boolean isAllowed(User user, Campaign campaign); void saveSelectedCampaign(); String getCampaignsRootUrl(); TableDataProvider<Campaign> getLazyModelCampaigns(); TableDataProvider<PersistentAnnotation> getLazyModelAnnotations(); String deleteAnnotationAction(PersistentAnnotation annotation); Campaign getSelectedCampaign(); void setSelectedCampaign(Campaign selectedCampaign); boolean isEditMode(); void setEditMode(boolean editMode); String getSelectedCampaignId(); void setSelectedCampaignId(String id); Campaign getTargetCampaign(); void setTargetCampaign(Campaign targetCampaign); String getTargetCampaignId(); void setTargetCampaignId(String id); void setRandomIdentifierForAnnotation(); void setRandomIdentifierForReview(); void resetTarget(); String forwardToAnnotationTarget(); String forwardToReviewTarget(); String getTargetIdentifier(); String getTargetIdentifierForUrl(); void setTargetIdentifierForUrl(String pi); void setTargetIdentifier(String targetIdentifier); String forwardToCrowdsourcingAnnotation(Campaign campaign); String forwardToCrowdsourcingReview(Campaign campaign); String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi); String forwardToCrowdsourcingReview(Campaign campaign, String pi); String getRandomItemUrl(Campaign campaign, CampaignRecordStatus status); CampaignRecordStatus getTargetRecordStatus(); String handleInvalidTarget(); List<Campaign> getActiveCampaignsForRecord(String pi); void updateActiveCampaigns(); }
|
@Test public void testGetAllCampaigns() throws DAOException { List<Campaign> campaigns = bean.getAllCampaigns(); Assert.assertEquals(2, campaigns.size()); }
|
public List<Campaign> getAllCampaigns() throws DAOException { List<Campaign> pages = DataManager.getInstance().getDao().getAllCampaigns(); return pages; }
|
CrowdsourcingBean implements Serializable { public List<Campaign> getAllCampaigns() throws DAOException { List<Campaign> pages = DataManager.getInstance().getDao().getAllCampaigns(); return pages; } }
|
CrowdsourcingBean implements Serializable { public List<Campaign> getAllCampaigns() throws DAOException { List<Campaign> pages = DataManager.getInstance().getDao().getAllCampaigns(); return pages; } }
|
CrowdsourcingBean implements Serializable { public List<Campaign> getAllCampaigns() throws DAOException { List<Campaign> pages = DataManager.getInstance().getDao().getAllCampaigns(); return pages; } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAction(CampaignVisibility visibility); static List<Locale> getAllLocales(); String createNewCampaignAction(); String editCampaignAction(Campaign campaign); String deleteCampaignAction(Campaign campaign); String addNewQuestionAction(); String removeQuestionAction(Question question); String resetDurationAction(); List<Campaign> getAllCampaigns(); List<Campaign> getAllCampaigns(CampaignVisibility visibility); List<Campaign> getAllowedCampaigns(User user); boolean isAllowed(User user, Campaign campaign); void saveSelectedCampaign(); String getCampaignsRootUrl(); TableDataProvider<Campaign> getLazyModelCampaigns(); TableDataProvider<PersistentAnnotation> getLazyModelAnnotations(); String deleteAnnotationAction(PersistentAnnotation annotation); Campaign getSelectedCampaign(); void setSelectedCampaign(Campaign selectedCampaign); boolean isEditMode(); void setEditMode(boolean editMode); String getSelectedCampaignId(); void setSelectedCampaignId(String id); Campaign getTargetCampaign(); void setTargetCampaign(Campaign targetCampaign); String getTargetCampaignId(); void setTargetCampaignId(String id); void setRandomIdentifierForAnnotation(); void setRandomIdentifierForReview(); void resetTarget(); String forwardToAnnotationTarget(); String forwardToReviewTarget(); String getTargetIdentifier(); String getTargetIdentifierForUrl(); void setTargetIdentifierForUrl(String pi); void setTargetIdentifier(String targetIdentifier); String forwardToCrowdsourcingAnnotation(Campaign campaign); String forwardToCrowdsourcingReview(Campaign campaign); String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi); String forwardToCrowdsourcingReview(Campaign campaign, String pi); String getRandomItemUrl(Campaign campaign, CampaignRecordStatus status); CampaignRecordStatus getTargetRecordStatus(); String handleInvalidTarget(); List<Campaign> getActiveCampaignsForRecord(String pi); void updateActiveCampaigns(); }
|
CrowdsourcingBean implements Serializable { public List<Campaign> getAllCampaigns() throws DAOException { List<Campaign> pages = DataManager.getInstance().getDao().getAllCampaigns(); return pages; } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAction(CampaignVisibility visibility); static List<Locale> getAllLocales(); String createNewCampaignAction(); String editCampaignAction(Campaign campaign); String deleteCampaignAction(Campaign campaign); String addNewQuestionAction(); String removeQuestionAction(Question question); String resetDurationAction(); List<Campaign> getAllCampaigns(); List<Campaign> getAllCampaigns(CampaignVisibility visibility); List<Campaign> getAllowedCampaigns(User user); boolean isAllowed(User user, Campaign campaign); void saveSelectedCampaign(); String getCampaignsRootUrl(); TableDataProvider<Campaign> getLazyModelCampaigns(); TableDataProvider<PersistentAnnotation> getLazyModelAnnotations(); String deleteAnnotationAction(PersistentAnnotation annotation); Campaign getSelectedCampaign(); void setSelectedCampaign(Campaign selectedCampaign); boolean isEditMode(); void setEditMode(boolean editMode); String getSelectedCampaignId(); void setSelectedCampaignId(String id); Campaign getTargetCampaign(); void setTargetCampaign(Campaign targetCampaign); String getTargetCampaignId(); void setTargetCampaignId(String id); void setRandomIdentifierForAnnotation(); void setRandomIdentifierForReview(); void resetTarget(); String forwardToAnnotationTarget(); String forwardToReviewTarget(); String getTargetIdentifier(); String getTargetIdentifierForUrl(); void setTargetIdentifierForUrl(String pi); void setTargetIdentifier(String targetIdentifier); String forwardToCrowdsourcingAnnotation(Campaign campaign); String forwardToCrowdsourcingReview(Campaign campaign); String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi); String forwardToCrowdsourcingReview(Campaign campaign, String pi); String getRandomItemUrl(Campaign campaign, CampaignRecordStatus status); CampaignRecordStatus getTargetRecordStatus(); String handleInvalidTarget(); List<Campaign> getActiveCampaignsForRecord(String pi); void updateActiveCampaigns(); }
|
@Test public void testSaveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { bean.setSelectedCampaignId("1"); Assert.assertNotNull(bean.getSelectedCampaign()); Date created = new Date(); bean.getSelectedCampaign().setDateCreated(created); Assert.assertEquals("Date created does not match after setting", created, bean.getSelectedCampaign().getDateCreated()); bean.saveSelectedCampaign(); bean.setSelectedCampaignId("1"); Assert.assertEquals("Date created does not match in database", created, bean.getSelectedCampaign().getDateCreated()); }
|
public void saveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { logger.trace("saveSelectedCampaign"); try { if (userBean == null || !userBean.getUser().isSuperuser()) { return; } if (selectedCampaign == null) { return; } boolean success = false; Date now = new Date(); if (selectedCampaign.getDateCreated() == null) { selectedCampaign.setDateCreated(now); } selectedCampaign.setDateUpdated(now); if (selectedCampaign.getId() != null) { success = DataManager.getInstance().getDao().updateCampaign(selectedCampaign); } else { success = DataManager.getInstance().getDao().addCampaign(selectedCampaign); } if (success) { selectedCampaign.setDirty(false); Messages.info("admin__crowdsourcing_campaign_save_success"); setSelectedCampaign(selectedCampaign); lazyModelCampaigns.update(); updateActiveCampaigns(); } else { Messages.error("admin__crowdsourcing_campaign_save_failure"); } } finally { } }
|
CrowdsourcingBean implements Serializable { public void saveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { logger.trace("saveSelectedCampaign"); try { if (userBean == null || !userBean.getUser().isSuperuser()) { return; } if (selectedCampaign == null) { return; } boolean success = false; Date now = new Date(); if (selectedCampaign.getDateCreated() == null) { selectedCampaign.setDateCreated(now); } selectedCampaign.setDateUpdated(now); if (selectedCampaign.getId() != null) { success = DataManager.getInstance().getDao().updateCampaign(selectedCampaign); } else { success = DataManager.getInstance().getDao().addCampaign(selectedCampaign); } if (success) { selectedCampaign.setDirty(false); Messages.info("admin__crowdsourcing_campaign_save_success"); setSelectedCampaign(selectedCampaign); lazyModelCampaigns.update(); updateActiveCampaigns(); } else { Messages.error("admin__crowdsourcing_campaign_save_failure"); } } finally { } } }
|
CrowdsourcingBean implements Serializable { public void saveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { logger.trace("saveSelectedCampaign"); try { if (userBean == null || !userBean.getUser().isSuperuser()) { return; } if (selectedCampaign == null) { return; } boolean success = false; Date now = new Date(); if (selectedCampaign.getDateCreated() == null) { selectedCampaign.setDateCreated(now); } selectedCampaign.setDateUpdated(now); if (selectedCampaign.getId() != null) { success = DataManager.getInstance().getDao().updateCampaign(selectedCampaign); } else { success = DataManager.getInstance().getDao().addCampaign(selectedCampaign); } if (success) { selectedCampaign.setDirty(false); Messages.info("admin__crowdsourcing_campaign_save_success"); setSelectedCampaign(selectedCampaign); lazyModelCampaigns.update(); updateActiveCampaigns(); } else { Messages.error("admin__crowdsourcing_campaign_save_failure"); } } finally { } } }
|
CrowdsourcingBean implements Serializable { public void saveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { logger.trace("saveSelectedCampaign"); try { if (userBean == null || !userBean.getUser().isSuperuser()) { return; } if (selectedCampaign == null) { return; } boolean success = false; Date now = new Date(); if (selectedCampaign.getDateCreated() == null) { selectedCampaign.setDateCreated(now); } selectedCampaign.setDateUpdated(now); if (selectedCampaign.getId() != null) { success = DataManager.getInstance().getDao().updateCampaign(selectedCampaign); } else { success = DataManager.getInstance().getDao().addCampaign(selectedCampaign); } if (success) { selectedCampaign.setDirty(false); Messages.info("admin__crowdsourcing_campaign_save_success"); setSelectedCampaign(selectedCampaign); lazyModelCampaigns.update(); updateActiveCampaigns(); } else { Messages.error("admin__crowdsourcing_campaign_save_failure"); } } finally { } } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAction(CampaignVisibility visibility); static List<Locale> getAllLocales(); String createNewCampaignAction(); String editCampaignAction(Campaign campaign); String deleteCampaignAction(Campaign campaign); String addNewQuestionAction(); String removeQuestionAction(Question question); String resetDurationAction(); List<Campaign> getAllCampaigns(); List<Campaign> getAllCampaigns(CampaignVisibility visibility); List<Campaign> getAllowedCampaigns(User user); boolean isAllowed(User user, Campaign campaign); void saveSelectedCampaign(); String getCampaignsRootUrl(); TableDataProvider<Campaign> getLazyModelCampaigns(); TableDataProvider<PersistentAnnotation> getLazyModelAnnotations(); String deleteAnnotationAction(PersistentAnnotation annotation); Campaign getSelectedCampaign(); void setSelectedCampaign(Campaign selectedCampaign); boolean isEditMode(); void setEditMode(boolean editMode); String getSelectedCampaignId(); void setSelectedCampaignId(String id); Campaign getTargetCampaign(); void setTargetCampaign(Campaign targetCampaign); String getTargetCampaignId(); void setTargetCampaignId(String id); void setRandomIdentifierForAnnotation(); void setRandomIdentifierForReview(); void resetTarget(); String forwardToAnnotationTarget(); String forwardToReviewTarget(); String getTargetIdentifier(); String getTargetIdentifierForUrl(); void setTargetIdentifierForUrl(String pi); void setTargetIdentifier(String targetIdentifier); String forwardToCrowdsourcingAnnotation(Campaign campaign); String forwardToCrowdsourcingReview(Campaign campaign); String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi); String forwardToCrowdsourcingReview(Campaign campaign, String pi); String getRandomItemUrl(Campaign campaign, CampaignRecordStatus status); CampaignRecordStatus getTargetRecordStatus(); String handleInvalidTarget(); List<Campaign> getActiveCampaignsForRecord(String pi); void updateActiveCampaigns(); }
|
CrowdsourcingBean implements Serializable { public void saveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { logger.trace("saveSelectedCampaign"); try { if (userBean == null || !userBean.getUser().isSuperuser()) { return; } if (selectedCampaign == null) { return; } boolean success = false; Date now = new Date(); if (selectedCampaign.getDateCreated() == null) { selectedCampaign.setDateCreated(now); } selectedCampaign.setDateUpdated(now); if (selectedCampaign.getId() != null) { success = DataManager.getInstance().getDao().updateCampaign(selectedCampaign); } else { success = DataManager.getInstance().getDao().addCampaign(selectedCampaign); } if (success) { selectedCampaign.setDirty(false); Messages.info("admin__crowdsourcing_campaign_save_success"); setSelectedCampaign(selectedCampaign); lazyModelCampaigns.update(); updateActiveCampaigns(); } else { Messages.error("admin__crowdsourcing_campaign_save_failure"); } } finally { } } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAction(CampaignVisibility visibility); static List<Locale> getAllLocales(); String createNewCampaignAction(); String editCampaignAction(Campaign campaign); String deleteCampaignAction(Campaign campaign); String addNewQuestionAction(); String removeQuestionAction(Question question); String resetDurationAction(); List<Campaign> getAllCampaigns(); List<Campaign> getAllCampaigns(CampaignVisibility visibility); List<Campaign> getAllowedCampaigns(User user); boolean isAllowed(User user, Campaign campaign); void saveSelectedCampaign(); String getCampaignsRootUrl(); TableDataProvider<Campaign> getLazyModelCampaigns(); TableDataProvider<PersistentAnnotation> getLazyModelAnnotations(); String deleteAnnotationAction(PersistentAnnotation annotation); Campaign getSelectedCampaign(); void setSelectedCampaign(Campaign selectedCampaign); boolean isEditMode(); void setEditMode(boolean editMode); String getSelectedCampaignId(); void setSelectedCampaignId(String id); Campaign getTargetCampaign(); void setTargetCampaign(Campaign targetCampaign); String getTargetCampaignId(); void setTargetCampaignId(String id); void setRandomIdentifierForAnnotation(); void setRandomIdentifierForReview(); void resetTarget(); String forwardToAnnotationTarget(); String forwardToReviewTarget(); String getTargetIdentifier(); String getTargetIdentifierForUrl(); void setTargetIdentifierForUrl(String pi); void setTargetIdentifier(String targetIdentifier); String forwardToCrowdsourcingAnnotation(Campaign campaign); String forwardToCrowdsourcingReview(Campaign campaign); String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi); String forwardToCrowdsourcingReview(Campaign campaign, String pi); String getRandomItemUrl(Campaign campaign, CampaignRecordStatus status); CampaignRecordStatus getTargetRecordStatus(); String handleInvalidTarget(); List<Campaign> getActiveCampaignsForRecord(String pi); void updateActiveCampaigns(); }
|
@Test public void testLogin_valid() throws AuthenticationProviderException, InterruptedException, ExecutionException { CompletableFuture<LoginResult> future = provider.login(userActive_email, userActive_pwHash); Assert.assertTrue(future.get().getUser().isPresent()); Assert.assertTrue(future.get().getUser().get().isActive()); Assert.assertFalse(future.get().getUser().get().isSuspended()); }
|
@Override public CompletableFuture<LoginResult> login(String email, String password) throws AuthenticationProviderException { HttpServletRequest request = BeanUtils.getRequest(); HttpServletResponse response = BeanUtils.getResponse(); if (StringUtils.isNotEmpty(email)) { try { User user = DataManager.getInstance().getDao().getUserByEmail(email); boolean refused = true; if (user != null && StringUtils.isNotBlank(password) && user.getPasswordHash() != null && bcrypt.checkpw(password, user.getPasswordHash())) { refused = false; } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.ofNullable(user), refused)); } catch (DAOException e) { throw new AuthenticationProviderException(e); } } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.empty(), true)); }
|
LocalAuthenticationProvider implements IAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String email, String password) throws AuthenticationProviderException { HttpServletRequest request = BeanUtils.getRequest(); HttpServletResponse response = BeanUtils.getResponse(); if (StringUtils.isNotEmpty(email)) { try { User user = DataManager.getInstance().getDao().getUserByEmail(email); boolean refused = true; if (user != null && StringUtils.isNotBlank(password) && user.getPasswordHash() != null && bcrypt.checkpw(password, user.getPasswordHash())) { refused = false; } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.ofNullable(user), refused)); } catch (DAOException e) { throw new AuthenticationProviderException(e); } } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.empty(), true)); } }
|
LocalAuthenticationProvider implements IAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String email, String password) throws AuthenticationProviderException { HttpServletRequest request = BeanUtils.getRequest(); HttpServletResponse response = BeanUtils.getResponse(); if (StringUtils.isNotEmpty(email)) { try { User user = DataManager.getInstance().getDao().getUserByEmail(email); boolean refused = true; if (user != null && StringUtils.isNotBlank(password) && user.getPasswordHash() != null && bcrypt.checkpw(password, user.getPasswordHash())) { refused = false; } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.ofNullable(user), refused)); } catch (DAOException e) { throw new AuthenticationProviderException(e); } } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.empty(), true)); } LocalAuthenticationProvider(String name); }
|
LocalAuthenticationProvider implements IAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String email, String password) throws AuthenticationProviderException { HttpServletRequest request = BeanUtils.getRequest(); HttpServletResponse response = BeanUtils.getResponse(); if (StringUtils.isNotEmpty(email)) { try { User user = DataManager.getInstance().getDao().getUserByEmail(email); boolean refused = true; if (user != null && StringUtils.isNotBlank(password) && user.getPasswordHash() != null && bcrypt.checkpw(password, user.getPasswordHash())) { refused = false; } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.ofNullable(user), refused)); } catch (DAOException e) { throw new AuthenticationProviderException(e); } } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.empty(), true)); } LocalAuthenticationProvider(String name); @Override CompletableFuture<LoginResult> login(String email, String password); @Override void logout(); @Override boolean allowsPasswordChange(); @Override String getName(); @Override String getType(); @Override boolean allowsNicknameChange(); @Override boolean allowsEmailChange(); @Override List<String> getAddUserToGroups(); @Override void setAddUserToGroups(List<String> addUserToGroups); }
|
LocalAuthenticationProvider implements IAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String email, String password) throws AuthenticationProviderException { HttpServletRequest request = BeanUtils.getRequest(); HttpServletResponse response = BeanUtils.getResponse(); if (StringUtils.isNotEmpty(email)) { try { User user = DataManager.getInstance().getDao().getUserByEmail(email); boolean refused = true; if (user != null && StringUtils.isNotBlank(password) && user.getPasswordHash() != null && bcrypt.checkpw(password, user.getPasswordHash())) { refused = false; } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.ofNullable(user), refused)); } catch (DAOException e) { throw new AuthenticationProviderException(e); } } return CompletableFuture.completedFuture(new LoginResult(request, response, Optional.empty(), true)); } LocalAuthenticationProvider(String name); @Override CompletableFuture<LoginResult> login(String email, String password); @Override void logout(); @Override boolean allowsPasswordChange(); @Override String getName(); @Override String getType(); @Override boolean allowsNicknameChange(); @Override boolean allowsEmailChange(); @Override List<String> getAddUserToGroups(); @Override void setAddUserToGroups(List<String> addUserToGroups); static final String TYPE_LOCAL; }
|
@Test public void setPersistentIdentifier_shouldDetermineCurrentElementIddocCorrectly() throws Exception { ActiveDocumentBean adb = new ActiveDocumentBean(); adb.setPersistentIdentifier(PI_KLEIUNIV); Assert.assertEquals(iddocKleiuniv, adb.topDocumentIddoc); }
|
public void setPersistentIdentifier(String persistentIdentifier) throws PresentationException, RecordNotFoundException, IndexUnreachableException { synchronized (this) { logger.trace("setPersistentIdentifier: {}", persistentIdentifier); lastReceivedIdentifier = persistentIdentifier; if (!PIValidator.validatePi(persistentIdentifier)) { logger.warn("Invalid identifier '{}'.", persistentIdentifier); reset(); return; } if (!"-".equals(persistentIdentifier) && (viewManager == null || !persistentIdentifier.equals(viewManager.getPi()))) { long id = DataManager.getInstance().getSearchIndex().getIddocFromIdentifier(persistentIdentifier); if (id > 0) { if (topDocumentIddoc != id) { topDocumentIddoc = id; logger.trace("IDDOC found for {}: {}", persistentIdentifier, id); } } else { logger.warn("No IDDOC for identifier '{}' found.", persistentIdentifier); reset(); return; } } } }
|
ActiveDocumentBean implements Serializable { public void setPersistentIdentifier(String persistentIdentifier) throws PresentationException, RecordNotFoundException, IndexUnreachableException { synchronized (this) { logger.trace("setPersistentIdentifier: {}", persistentIdentifier); lastReceivedIdentifier = persistentIdentifier; if (!PIValidator.validatePi(persistentIdentifier)) { logger.warn("Invalid identifier '{}'.", persistentIdentifier); reset(); return; } if (!"-".equals(persistentIdentifier) && (viewManager == null || !persistentIdentifier.equals(viewManager.getPi()))) { long id = DataManager.getInstance().getSearchIndex().getIddocFromIdentifier(persistentIdentifier); if (id > 0) { if (topDocumentIddoc != id) { topDocumentIddoc = id; logger.trace("IDDOC found for {}: {}", persistentIdentifier, id); } } else { logger.warn("No IDDOC for identifier '{}' found.", persistentIdentifier); reset(); return; } } } } }
|
ActiveDocumentBean implements Serializable { public void setPersistentIdentifier(String persistentIdentifier) throws PresentationException, RecordNotFoundException, IndexUnreachableException { synchronized (this) { logger.trace("setPersistentIdentifier: {}", persistentIdentifier); lastReceivedIdentifier = persistentIdentifier; if (!PIValidator.validatePi(persistentIdentifier)) { logger.warn("Invalid identifier '{}'.", persistentIdentifier); reset(); return; } if (!"-".equals(persistentIdentifier) && (viewManager == null || !persistentIdentifier.equals(viewManager.getPi()))) { long id = DataManager.getInstance().getSearchIndex().getIddocFromIdentifier(persistentIdentifier); if (id > 0) { if (topDocumentIddoc != id) { topDocumentIddoc = id; logger.trace("IDDOC found for {}: {}", persistentIdentifier, id); } } else { logger.warn("No IDDOC for identifier '{}' found.", persistentIdentifier); reset(); return; } } } } ActiveDocumentBean(); }
|
ActiveDocumentBean implements Serializable { public void setPersistentIdentifier(String persistentIdentifier) throws PresentationException, RecordNotFoundException, IndexUnreachableException { synchronized (this) { logger.trace("setPersistentIdentifier: {}", persistentIdentifier); lastReceivedIdentifier = persistentIdentifier; if (!PIValidator.validatePi(persistentIdentifier)) { logger.warn("Invalid identifier '{}'.", persistentIdentifier); reset(); return; } if (!"-".equals(persistentIdentifier) && (viewManager == null || !persistentIdentifier.equals(viewManager.getPi()))) { long id = DataManager.getInstance().getSearchIndex().getIddocFromIdentifier(persistentIdentifier); if (id > 0) { if (topDocumentIddoc != id) { topDocumentIddoc = id; logger.trace("IDDOC found for {}: {}", persistentIdentifier, id); } } else { logger.warn("No IDDOC for identifier '{}' found.", persistentIdentifier); reset(); return; } } } } ActiveDocumentBean(); void setNavigationHelper(NavigationHelper navigationHelper); void setCmsBean(CmsBean cmsBean); void setSearchBean(SearchBean searchBean); void setBookshelfBean(BookmarkBean bookshelfBean); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); void reset(); ViewManager getViewManager(); String reload(String pi); void update(); String open(); String openFulltext(); BrowseElement getPrevHit(); BrowseElement getNextHit(); long getActiveDocumentIddoc(); StructElement getCurrentElement(); void setImageToShow(int imageToShow); int getImageToShow(); List<Metadata> getTitleBarMetadata(); void setLogid(String logid); String getLogid(); boolean isAnchor(); void setAnchor(boolean anchor); boolean isVolume(); boolean isGroup(); String getAction(); void setAction(String action); void setPersistentIdentifier(String persistentIdentifier); String getPersistentIdentifier(); String getThumbPart(); String getLogPart(); String getPageUrl(String pageType, int page); String getPageUrl(int page); String getPageUrl(); String getPageUrl(String pageType); String getFirstPageUrl(); String getLastPageUrl(); String getPreviousPageUrl(int step); String getNextPageUrl(int step); String getPreviousPageUrl(); String getNextPageUrl(); String getImageUrl(); String getFullscreenImageUrl(); String getReadingModeUrl(); String getFulltextUrl(); String getMetadataUrl(); StructElement getTopDocument(); void setChildrenVisible(TOCElement element); void setChildrenInvisible(TOCElement element); String calculateSidebarToc(); TOC getToc(); int getTocCurrentPage(); void setTocCurrentPage(int tocCurrentPage); String getTitleBarLabel(Locale locale); String getTitleBarLabel(); String getTitleBarLabel(String language); String getLabelForJS(); int getImageContainerWidth(); int getNumberOfImages(); long getTopDocumentIddoc(); boolean isRecordLoaded(); boolean hasAnchor(); String reIndexRecordAction(); String deleteRecordAction(boolean keepTraceDocument); int getCurrentThumbnailPage(); void setCurrentThumbnailPage(int currentThumbnailPage); boolean isHasLanguages(); List<String> getRecordLanguages(); void setRecordLanguages(List<String> recordLanguages); String getSelectedRecordLanguage(); void setSelectedRecordLanguage(String selectedRecordLanguage); boolean isAccessPermissionEpub(); boolean isAccessPermissionPdf(); void downloadTOCAction(); List<SearchHit> getRelatedItems(String identifierField); String getRelatedItemsQueryString(String identifierField); String getRelativeUrlTags(); void resetAccess(); Boolean getDeleteRecordKeepTrace(); void setDeleteRecordKeepTrace(Boolean deleteRecordKeepTrace); CMSSidebarElement getMapWidget(); }
|
ActiveDocumentBean implements Serializable { public void setPersistentIdentifier(String persistentIdentifier) throws PresentationException, RecordNotFoundException, IndexUnreachableException { synchronized (this) { logger.trace("setPersistentIdentifier: {}", persistentIdentifier); lastReceivedIdentifier = persistentIdentifier; if (!PIValidator.validatePi(persistentIdentifier)) { logger.warn("Invalid identifier '{}'.", persistentIdentifier); reset(); return; } if (!"-".equals(persistentIdentifier) && (viewManager == null || !persistentIdentifier.equals(viewManager.getPi()))) { long id = DataManager.getInstance().getSearchIndex().getIddocFromIdentifier(persistentIdentifier); if (id > 0) { if (topDocumentIddoc != id) { topDocumentIddoc = id; logger.trace("IDDOC found for {}: {}", persistentIdentifier, id); } } else { logger.warn("No IDDOC for identifier '{}' found.", persistentIdentifier); reset(); return; } } } } ActiveDocumentBean(); void setNavigationHelper(NavigationHelper navigationHelper); void setCmsBean(CmsBean cmsBean); void setSearchBean(SearchBean searchBean); void setBookshelfBean(BookmarkBean bookshelfBean); void setBreadcrumbBean(BreadcrumbBean breadcrumbBean); void reset(); ViewManager getViewManager(); String reload(String pi); void update(); String open(); String openFulltext(); BrowseElement getPrevHit(); BrowseElement getNextHit(); long getActiveDocumentIddoc(); StructElement getCurrentElement(); void setImageToShow(int imageToShow); int getImageToShow(); List<Metadata> getTitleBarMetadata(); void setLogid(String logid); String getLogid(); boolean isAnchor(); void setAnchor(boolean anchor); boolean isVolume(); boolean isGroup(); String getAction(); void setAction(String action); void setPersistentIdentifier(String persistentIdentifier); String getPersistentIdentifier(); String getThumbPart(); String getLogPart(); String getPageUrl(String pageType, int page); String getPageUrl(int page); String getPageUrl(); String getPageUrl(String pageType); String getFirstPageUrl(); String getLastPageUrl(); String getPreviousPageUrl(int step); String getNextPageUrl(int step); String getPreviousPageUrl(); String getNextPageUrl(); String getImageUrl(); String getFullscreenImageUrl(); String getReadingModeUrl(); String getFulltextUrl(); String getMetadataUrl(); StructElement getTopDocument(); void setChildrenVisible(TOCElement element); void setChildrenInvisible(TOCElement element); String calculateSidebarToc(); TOC getToc(); int getTocCurrentPage(); void setTocCurrentPage(int tocCurrentPage); String getTitleBarLabel(Locale locale); String getTitleBarLabel(); String getTitleBarLabel(String language); String getLabelForJS(); int getImageContainerWidth(); int getNumberOfImages(); long getTopDocumentIddoc(); boolean isRecordLoaded(); boolean hasAnchor(); String reIndexRecordAction(); String deleteRecordAction(boolean keepTraceDocument); int getCurrentThumbnailPage(); void setCurrentThumbnailPage(int currentThumbnailPage); boolean isHasLanguages(); List<String> getRecordLanguages(); void setRecordLanguages(List<String> recordLanguages); String getSelectedRecordLanguage(); void setSelectedRecordLanguage(String selectedRecordLanguage); boolean isAccessPermissionEpub(); boolean isAccessPermissionPdf(); void downloadTOCAction(); List<SearchHit> getRelatedItems(String identifierField); String getRelatedItemsQueryString(String identifierField); String getRelativeUrlTags(); void resetAccess(); Boolean getDeleteRecordKeepTrace(); void setDeleteRecordKeepTrace(Boolean deleteRecordKeepTrace); CMSSidebarElement getMapWidget(); }
|
@Test public void getAvailableValuesForField_shouldReturnAllExistingValuesForTheGivenField() throws Exception { SitelinkBean sb = new SitelinkBean(); List<String> values = sb.getAvailableValuesForField("MD_YEARPUBLISH", SolrConstants.ISWORK + ":true"); Assert.assertFalse(values.isEmpty()); }
|
public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new IllegalArgumentException("filterQuery may not be null"); } filterQuery = SearchHelper.buildFinalQuery(filterQuery, false); QueryResponse qr = DataManager.getInstance().getSearchIndex().searchFacetsAndStatistics(filterQuery, null, Collections.singletonList(field), 1, false); if (qr != null) { FacetField facet = qr.getFacetField(field); if (facet != null) { List<String> ret = new ArrayList<>(facet.getValueCount()); for (Count count : facet.getValues()) { if (count.getName().charAt(0) != 0x01) { ret.add(count.getName()); } } return ret; } } return Collections.emptyList(); }
|
SitelinkBean implements Serializable { public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new IllegalArgumentException("filterQuery may not be null"); } filterQuery = SearchHelper.buildFinalQuery(filterQuery, false); QueryResponse qr = DataManager.getInstance().getSearchIndex().searchFacetsAndStatistics(filterQuery, null, Collections.singletonList(field), 1, false); if (qr != null) { FacetField facet = qr.getFacetField(field); if (facet != null) { List<String> ret = new ArrayList<>(facet.getValueCount()); for (Count count : facet.getValues()) { if (count.getName().charAt(0) != 0x01) { ret.add(count.getName()); } } return ret; } } return Collections.emptyList(); } }
|
SitelinkBean implements Serializable { public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new IllegalArgumentException("filterQuery may not be null"); } filterQuery = SearchHelper.buildFinalQuery(filterQuery, false); QueryResponse qr = DataManager.getInstance().getSearchIndex().searchFacetsAndStatistics(filterQuery, null, Collections.singletonList(field), 1, false); if (qr != null) { FacetField facet = qr.getFacetField(field); if (facet != null) { List<String> ret = new ArrayList<>(facet.getValueCount()); for (Count count : facet.getValues()) { if (count.getName().charAt(0) != 0x01) { ret.add(count.getName()); } } return ret; } } return Collections.emptyList(); } }
|
SitelinkBean implements Serializable { public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new IllegalArgumentException("filterQuery may not be null"); } filterQuery = SearchHelper.buildFinalQuery(filterQuery, false); QueryResponse qr = DataManager.getInstance().getSearchIndex().searchFacetsAndStatistics(filterQuery, null, Collections.singletonList(field), 1, false); if (qr != null) { FacetField facet = qr.getFacetField(field); if (facet != null) { List<String> ret = new ArrayList<>(facet.getValueCount()); for (Count count : facet.getValues()) { if (count.getName().charAt(0) != 0x01) { ret.add(count.getName()); } } return ret; } } return Collections.emptyList(); } List<String> getAvailableValues(); List<String> getAvailableValuesForField(String field, String filterQuery); String searchAction(); String resetAction(); String getValue(); void setValue(String value); List<StringPair> getHits(); }
|
SitelinkBean implements Serializable { public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new IllegalArgumentException("filterQuery may not be null"); } filterQuery = SearchHelper.buildFinalQuery(filterQuery, false); QueryResponse qr = DataManager.getInstance().getSearchIndex().searchFacetsAndStatistics(filterQuery, null, Collections.singletonList(field), 1, false); if (qr != null) { FacetField facet = qr.getFacetField(field); if (facet != null) { List<String> ret = new ArrayList<>(facet.getValueCount()); for (Count count : facet.getValues()) { if (count.getName().charAt(0) != 0x01) { ret.add(count.getName()); } } return ret; } } return Collections.emptyList(); } List<String> getAvailableValues(); List<String> getAvailableValuesForField(String field, String filterQuery); String searchAction(); String resetAction(); String getValue(); void setValue(String value); List<StringPair> getHits(); }
|
@Test public void escapeCriticalUrlChracters_shouldReplaceCharactersCorrectly() throws Exception { Assert.assertEquals("AU002FU005CU007CU003FZ", BeanUtils.escapeCriticalUrlChracters("A/\\|?Z")); Assert.assertEquals("U007C", BeanUtils.escapeCriticalUrlChracters("%7C")); }
|
public static String escapeCriticalUrlChracters(String value) { return escapeCriticalUrlChracters(value, false); }
|
BeanUtils { public static String escapeCriticalUrlChracters(String value) { return escapeCriticalUrlChracters(value, false); } }
|
BeanUtils { public static String escapeCriticalUrlChracters(String value) { return escapeCriticalUrlChracters(value, false); } }
|
BeanUtils { public static String escapeCriticalUrlChracters(String value) { return escapeCriticalUrlChracters(value, false); } static HttpServletRequest getRequest(); static HttpServletRequest getRequest(FacesContext context); static HttpSession getSession(); static String getServletPathWithHostAsUrlFromJsfContext(); static boolean hasJsfContext(); static String getServletImagesPathFromRequest(HttpServletRequest request, String theme); static ServletContext getServletContext(); static Locale getLocale(); static Locale getDefaultLocale(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object getBeanByName(String name, Class clazz); static NavigationHelper getNavigationHelper(); static ActiveDocumentBean getActiveDocumentBean(); static SearchBean getSearchBean(); static BookmarkBean getBookmarkBean(); static CreateRecordBean getCreateRecordBean(); static CmsCollectionsBean getCMSCollectionsBean(); static MetadataBean getMetadataBean(); static CmsBean getCmsBean(); static CmsMediaBean getCmsMediaBean(); static CalendarBean getCalendarBean(); static UserBean getUserBean(); static ImageDeliveryBean getImageDeliveryBean(); static BrowseBean getBrowseBean(); static UserBean getUserBeanFromRequest(HttpServletRequest request); static User getUserFromRequest(HttpServletRequest request); static String escapeCriticalUrlChracters(String value); static String escapeCriticalUrlChracters(String value, boolean escapePercentCharacters); static String unescapeCriticalUrlChracters(String value); static HttpServletResponse getResponse(); static Object getManagedBeanValue(String expr); }
|
BeanUtils { public static String escapeCriticalUrlChracters(String value) { return escapeCriticalUrlChracters(value, false); } static HttpServletRequest getRequest(); static HttpServletRequest getRequest(FacesContext context); static HttpSession getSession(); static String getServletPathWithHostAsUrlFromJsfContext(); static boolean hasJsfContext(); static String getServletImagesPathFromRequest(HttpServletRequest request, String theme); static ServletContext getServletContext(); static Locale getLocale(); static Locale getDefaultLocale(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object getBeanByName(String name, Class clazz); static NavigationHelper getNavigationHelper(); static ActiveDocumentBean getActiveDocumentBean(); static SearchBean getSearchBean(); static BookmarkBean getBookmarkBean(); static CreateRecordBean getCreateRecordBean(); static CmsCollectionsBean getCMSCollectionsBean(); static MetadataBean getMetadataBean(); static CmsBean getCmsBean(); static CmsMediaBean getCmsMediaBean(); static CalendarBean getCalendarBean(); static UserBean getUserBean(); static ImageDeliveryBean getImageDeliveryBean(); static BrowseBean getBrowseBean(); static UserBean getUserBeanFromRequest(HttpServletRequest request); static User getUserFromRequest(HttpServletRequest request); static String escapeCriticalUrlChracters(String value); static String escapeCriticalUrlChracters(String value, boolean escapePercentCharacters); static String unescapeCriticalUrlChracters(String value); static HttpServletResponse getResponse(); static Object getManagedBeanValue(String expr); static final String SLASH_REPLACEMENT; static final String BACKSLASH_REPLACEMENT; static final String PIPE_REPLACEMENT; static final String QUESTION_MARK_REPLACEMENT; static final String PERCENT_REPLACEMENT; }
|
@Test public void unescapeCriticalUrlChracters_shouldReplaceCharactersCorrectly() throws Exception { Assert.assertEquals("A/\\|?Z", BeanUtils.unescapeCriticalUrlChracters("AU002FU005CU007CU003FZ")); }
|
public static String unescapeCriticalUrlChracters(String value) { if (value == null) { throw new IllegalArgumentException("value may not be null"); } return value.replace(SLASH_REPLACEMENT, "/") .replace(BACKSLASH_REPLACEMENT, "\\") .replace(PIPE_REPLACEMENT, "|") .replace(QUESTION_MARK_REPLACEMENT, "?") .replace(PERCENT_REPLACEMENT, "%"); }
|
BeanUtils { public static String unescapeCriticalUrlChracters(String value) { if (value == null) { throw new IllegalArgumentException("value may not be null"); } return value.replace(SLASH_REPLACEMENT, "/") .replace(BACKSLASH_REPLACEMENT, "\\") .replace(PIPE_REPLACEMENT, "|") .replace(QUESTION_MARK_REPLACEMENT, "?") .replace(PERCENT_REPLACEMENT, "%"); } }
|
BeanUtils { public static String unescapeCriticalUrlChracters(String value) { if (value == null) { throw new IllegalArgumentException("value may not be null"); } return value.replace(SLASH_REPLACEMENT, "/") .replace(BACKSLASH_REPLACEMENT, "\\") .replace(PIPE_REPLACEMENT, "|") .replace(QUESTION_MARK_REPLACEMENT, "?") .replace(PERCENT_REPLACEMENT, "%"); } }
|
BeanUtils { public static String unescapeCriticalUrlChracters(String value) { if (value == null) { throw new IllegalArgumentException("value may not be null"); } return value.replace(SLASH_REPLACEMENT, "/") .replace(BACKSLASH_REPLACEMENT, "\\") .replace(PIPE_REPLACEMENT, "|") .replace(QUESTION_MARK_REPLACEMENT, "?") .replace(PERCENT_REPLACEMENT, "%"); } static HttpServletRequest getRequest(); static HttpServletRequest getRequest(FacesContext context); static HttpSession getSession(); static String getServletPathWithHostAsUrlFromJsfContext(); static boolean hasJsfContext(); static String getServletImagesPathFromRequest(HttpServletRequest request, String theme); static ServletContext getServletContext(); static Locale getLocale(); static Locale getDefaultLocale(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object getBeanByName(String name, Class clazz); static NavigationHelper getNavigationHelper(); static ActiveDocumentBean getActiveDocumentBean(); static SearchBean getSearchBean(); static BookmarkBean getBookmarkBean(); static CreateRecordBean getCreateRecordBean(); static CmsCollectionsBean getCMSCollectionsBean(); static MetadataBean getMetadataBean(); static CmsBean getCmsBean(); static CmsMediaBean getCmsMediaBean(); static CalendarBean getCalendarBean(); static UserBean getUserBean(); static ImageDeliveryBean getImageDeliveryBean(); static BrowseBean getBrowseBean(); static UserBean getUserBeanFromRequest(HttpServletRequest request); static User getUserFromRequest(HttpServletRequest request); static String escapeCriticalUrlChracters(String value); static String escapeCriticalUrlChracters(String value, boolean escapePercentCharacters); static String unescapeCriticalUrlChracters(String value); static HttpServletResponse getResponse(); static Object getManagedBeanValue(String expr); }
|
BeanUtils { public static String unescapeCriticalUrlChracters(String value) { if (value == null) { throw new IllegalArgumentException("value may not be null"); } return value.replace(SLASH_REPLACEMENT, "/") .replace(BACKSLASH_REPLACEMENT, "\\") .replace(PIPE_REPLACEMENT, "|") .replace(QUESTION_MARK_REPLACEMENT, "?") .replace(PERCENT_REPLACEMENT, "%"); } static HttpServletRequest getRequest(); static HttpServletRequest getRequest(FacesContext context); static HttpSession getSession(); static String getServletPathWithHostAsUrlFromJsfContext(); static boolean hasJsfContext(); static String getServletImagesPathFromRequest(HttpServletRequest request, String theme); static ServletContext getServletContext(); static Locale getLocale(); static Locale getDefaultLocale(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object getBeanByName(String name, Class clazz); static NavigationHelper getNavigationHelper(); static ActiveDocumentBean getActiveDocumentBean(); static SearchBean getSearchBean(); static BookmarkBean getBookmarkBean(); static CreateRecordBean getCreateRecordBean(); static CmsCollectionsBean getCMSCollectionsBean(); static MetadataBean getMetadataBean(); static CmsBean getCmsBean(); static CmsMediaBean getCmsMediaBean(); static CalendarBean getCalendarBean(); static UserBean getUserBean(); static ImageDeliveryBean getImageDeliveryBean(); static BrowseBean getBrowseBean(); static UserBean getUserBeanFromRequest(HttpServletRequest request); static User getUserFromRequest(HttpServletRequest request); static String escapeCriticalUrlChracters(String value); static String escapeCriticalUrlChracters(String value, boolean escapePercentCharacters); static String unescapeCriticalUrlChracters(String value); static HttpServletResponse getResponse(); static Object getManagedBeanValue(String expr); static final String SLASH_REPLACEMENT; static final String BACKSLASH_REPLACEMENT; static final String PIPE_REPLACEMENT; static final String QUESTION_MARK_REPLACEMENT; static final String PERCENT_REPLACEMENT; }
|
@Test public void getSearchUrl_shouldReturnNullIfNavigationHelperIsNull() throws Exception { SearchBean sb = new SearchBean(); Assert.assertNull(sb.getSearchUrl()); }
|
public String getSearchUrl() { if (navigationHelper == null) { return null; } switch (activeSearchType) { case SearchHelper.SEARCH_TYPE_ADVANCED: return navigationHelper.getAdvancedSearchUrl(); default: return navigationHelper.getSearchUrl(); } }
|
SearchBean implements SearchInterface, Serializable { public String getSearchUrl() { if (navigationHelper == null) { return null; } switch (activeSearchType) { case SearchHelper.SEARCH_TYPE_ADVANCED: return navigationHelper.getAdvancedSearchUrl(); default: return navigationHelper.getSearchUrl(); } } }
|
SearchBean implements SearchInterface, Serializable { public String getSearchUrl() { if (navigationHelper == null) { return null; } switch (activeSearchType) { case SearchHelper.SEARCH_TYPE_ADVANCED: return navigationHelper.getAdvancedSearchUrl(); default: return navigationHelper.getSearchUrl(); } } SearchBean(); }
|
SearchBean implements SearchInterface, Serializable { public String getSearchUrl() { if (navigationHelper == null) { return null; } switch (activeSearchType) { case SearchHelper.SEARCH_TYPE_ADVANCED: return navigationHelper.getAdvancedSearchUrl(); default: return navigationHelper.getSearchUrl(); } } SearchBean(); @PostConstruct void init(); void setNavigationHelper(NavigationHelper navigationHelper); void clearSearchItemLists(); String search(); @Override String searchSimple(); String searchSimple(boolean resetParameters); String searchSimple(boolean resetParameters, boolean resetFacets); String searchSimpleResetCollections(); String searchSimpleSetFacets(String facetString); @Override String searchAdvanced(); String searchAdvanced(boolean resetParameters); String searchDirect(); String resetSearchAction(); @Override String resetSearch(); void resetSearchResults(); void resetSearchParameters(); void resetSearchParameters(boolean resetAll); void setAdvancedQueryItemsReset(boolean reset); void hitsPerPageListener(); void executeSearch(); @Override int getActiveSearchType(); @Override void setActiveSearchType(int activeSearchType); void resetActiveSearchType(); @Override List<String> autocomplete(String suggest); @Override boolean isSearchInDcFlag(); String getInvisibleSearchString(); void setInvisibleSearchString(String invisibleSearchString); @Override String getSearchString(); String getSearchStringForUrl(); void setSearchStringForUrl(String searchString); @Override void setSearchString(String searchString); @Override String getExactSearchString(); void setExactSearchString(String inSearchString); String getExactSearchStringResetGui(); void setExactSearchStringResetGui(String inSearchString); @Override void setSortString(String sortString); @Override String getSortString(); void mirrorAdvancedSearchCurrentHierarchicalFacets(); String removeFacetAction(String facetQuery); @Override int getCurrentPage(); void setCurrentPage(int currentPage); @Override long getHitsCount(); void setHitsCount(long hitsCount); Map<String, Set<String>> getSearchTerms(); int getCurrentHitIndex(); int getCurrentHitIndexDisplay(); void increaseCurrentHitIndex(); int getHitIndexOperand(); void setHitIndexOperand(int hitIndexOperand); void findCurrentHitIndex(String pi, int page, boolean aggregateHits); BrowseElement getNextElement(); BrowseElement getPreviousElement(); @Override List<SearchFilter> getSearchFilters(); @Override String getCurrentSearchFilterString(); @Override void setCurrentSearchFilterString(String searchFilterLabel); void resetSearchFilter(); void resetCurrentHitIndex(); boolean isSortingEnabled(); List<SearchQueryGroup> getAdvancedQueryGroups(); boolean addNewAdvancedQueryGroup(); boolean removeAdvancedQueryGroup(SearchQueryGroup group); List<StringPair> getAdvancedSearchSelectItems(String field, String language, boolean hierarchical); List<StringPair> getAllCollections(); List<StringPair> getAllCollections(String language); int getAdvancedSearchGroupOperator(); void setAdvancedSearchGroupOperator(int advancedSearchGroupOperator); List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(); static List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(String language); String getSearchInCurrentItemString(); void setSearchInCurrentItemString(String searchInCurrentItemString); Search getCurrentSearch(); void setCurrentSearch(Search currentSearch); String saveSearchAction(); String getRssUrl(); boolean isSearchSavingEnabled(); String executeSavedSearchAction(Search search); String exportSearchAsExcelAction(); int getHitsPerPage(); void setHitsPerPage(int hitsPerPage); String getAdvancedSearchQueryInfo(); @Override SearchFacets getFacets(); Future<Boolean> isDownloadReady(); long getTotalNumberOfVolumes(); String getSearchUrl(); @Override int getLastPage(); StructElement getStructElement(String pi); @Override String getCurrentSearchUrlRoot(); String getCurrentSearchUrlPart(); void updateFacetItem(String field, boolean hierarchical); List<FacetItem> getStaticDrillDown(String field, String subQuery, Integer resultLimit, final Boolean reverseOrder); @Override boolean isSearchPerformed(); @Override boolean isExplicitSearchPerformed(); boolean isShowReducedSearchOptions(); void setShowReducedSearchOptions(boolean showReducedSearchOptions); void setFirstQueryItemValue(String value); void getFirstQueryItemValue(); void setBookmarkListName(String name); String getBookmarkListName(); void setBookmarkListSharedKey(String key); String getBookmarkListSharedKey(); }
|
SearchBean implements SearchInterface, Serializable { public String getSearchUrl() { if (navigationHelper == null) { return null; } switch (activeSearchType) { case SearchHelper.SEARCH_TYPE_ADVANCED: return navigationHelper.getAdvancedSearchUrl(); default: return navigationHelper.getSearchUrl(); } } SearchBean(); @PostConstruct void init(); void setNavigationHelper(NavigationHelper navigationHelper); void clearSearchItemLists(); String search(); @Override String searchSimple(); String searchSimple(boolean resetParameters); String searchSimple(boolean resetParameters, boolean resetFacets); String searchSimpleResetCollections(); String searchSimpleSetFacets(String facetString); @Override String searchAdvanced(); String searchAdvanced(boolean resetParameters); String searchDirect(); String resetSearchAction(); @Override String resetSearch(); void resetSearchResults(); void resetSearchParameters(); void resetSearchParameters(boolean resetAll); void setAdvancedQueryItemsReset(boolean reset); void hitsPerPageListener(); void executeSearch(); @Override int getActiveSearchType(); @Override void setActiveSearchType(int activeSearchType); void resetActiveSearchType(); @Override List<String> autocomplete(String suggest); @Override boolean isSearchInDcFlag(); String getInvisibleSearchString(); void setInvisibleSearchString(String invisibleSearchString); @Override String getSearchString(); String getSearchStringForUrl(); void setSearchStringForUrl(String searchString); @Override void setSearchString(String searchString); @Override String getExactSearchString(); void setExactSearchString(String inSearchString); String getExactSearchStringResetGui(); void setExactSearchStringResetGui(String inSearchString); @Override void setSortString(String sortString); @Override String getSortString(); void mirrorAdvancedSearchCurrentHierarchicalFacets(); String removeFacetAction(String facetQuery); @Override int getCurrentPage(); void setCurrentPage(int currentPage); @Override long getHitsCount(); void setHitsCount(long hitsCount); Map<String, Set<String>> getSearchTerms(); int getCurrentHitIndex(); int getCurrentHitIndexDisplay(); void increaseCurrentHitIndex(); int getHitIndexOperand(); void setHitIndexOperand(int hitIndexOperand); void findCurrentHitIndex(String pi, int page, boolean aggregateHits); BrowseElement getNextElement(); BrowseElement getPreviousElement(); @Override List<SearchFilter> getSearchFilters(); @Override String getCurrentSearchFilterString(); @Override void setCurrentSearchFilterString(String searchFilterLabel); void resetSearchFilter(); void resetCurrentHitIndex(); boolean isSortingEnabled(); List<SearchQueryGroup> getAdvancedQueryGroups(); boolean addNewAdvancedQueryGroup(); boolean removeAdvancedQueryGroup(SearchQueryGroup group); List<StringPair> getAdvancedSearchSelectItems(String field, String language, boolean hierarchical); List<StringPair> getAllCollections(); List<StringPair> getAllCollections(String language); int getAdvancedSearchGroupOperator(); void setAdvancedSearchGroupOperator(int advancedSearchGroupOperator); List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(); static List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(String language); String getSearchInCurrentItemString(); void setSearchInCurrentItemString(String searchInCurrentItemString); Search getCurrentSearch(); void setCurrentSearch(Search currentSearch); String saveSearchAction(); String getRssUrl(); boolean isSearchSavingEnabled(); String executeSavedSearchAction(Search search); String exportSearchAsExcelAction(); int getHitsPerPage(); void setHitsPerPage(int hitsPerPage); String getAdvancedSearchQueryInfo(); @Override SearchFacets getFacets(); Future<Boolean> isDownloadReady(); long getTotalNumberOfVolumes(); String getSearchUrl(); @Override int getLastPage(); StructElement getStructElement(String pi); @Override String getCurrentSearchUrlRoot(); String getCurrentSearchUrlPart(); void updateFacetItem(String field, boolean hierarchical); List<FacetItem> getStaticDrillDown(String field, String subQuery, Integer resultLimit, final Boolean reverseOrder); @Override boolean isSearchPerformed(); @Override boolean isExplicitSearchPerformed(); boolean isShowReducedSearchOptions(); void setShowReducedSearchOptions(boolean showReducedSearchOptions); void setFirstQueryItemValue(String value); void getFirstQueryItemValue(); void setBookmarkListName(String name); String getBookmarkListName(); void setBookmarkListSharedKey(String key); String getBookmarkListSharedKey(); static final String URL_ENCODING; }
|
@Test public void getAdvancedSearchAllowedFields_shouldOmitLanguagedFieldsForOtherLanguages() throws Exception { List<AdvancedSearchFieldConfiguration> fields = SearchBean.getAdvancedSearchAllowedFields("en"); boolean en = false; boolean de = false; boolean es = false; for (AdvancedSearchFieldConfiguration field : fields) { switch (field.getField()) { case "MD_FOO_LANG_EN": en = true; break; case "MD_FOO_LANG_DE": de = true; break; case "MD_FOO_LANG_ES": es = true; break; } } Assert.assertTrue(en); Assert.assertFalse(de); Assert.assertFalse(es); }
|
public List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields() { return getAdvancedSearchAllowedFields(navigationHelper.getLocaleString()); }
|
SearchBean implements SearchInterface, Serializable { public List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields() { return getAdvancedSearchAllowedFields(navigationHelper.getLocaleString()); } }
|
SearchBean implements SearchInterface, Serializable { public List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields() { return getAdvancedSearchAllowedFields(navigationHelper.getLocaleString()); } SearchBean(); }
|
SearchBean implements SearchInterface, Serializable { public List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields() { return getAdvancedSearchAllowedFields(navigationHelper.getLocaleString()); } SearchBean(); @PostConstruct void init(); void setNavigationHelper(NavigationHelper navigationHelper); void clearSearchItemLists(); String search(); @Override String searchSimple(); String searchSimple(boolean resetParameters); String searchSimple(boolean resetParameters, boolean resetFacets); String searchSimpleResetCollections(); String searchSimpleSetFacets(String facetString); @Override String searchAdvanced(); String searchAdvanced(boolean resetParameters); String searchDirect(); String resetSearchAction(); @Override String resetSearch(); void resetSearchResults(); void resetSearchParameters(); void resetSearchParameters(boolean resetAll); void setAdvancedQueryItemsReset(boolean reset); void hitsPerPageListener(); void executeSearch(); @Override int getActiveSearchType(); @Override void setActiveSearchType(int activeSearchType); void resetActiveSearchType(); @Override List<String> autocomplete(String suggest); @Override boolean isSearchInDcFlag(); String getInvisibleSearchString(); void setInvisibleSearchString(String invisibleSearchString); @Override String getSearchString(); String getSearchStringForUrl(); void setSearchStringForUrl(String searchString); @Override void setSearchString(String searchString); @Override String getExactSearchString(); void setExactSearchString(String inSearchString); String getExactSearchStringResetGui(); void setExactSearchStringResetGui(String inSearchString); @Override void setSortString(String sortString); @Override String getSortString(); void mirrorAdvancedSearchCurrentHierarchicalFacets(); String removeFacetAction(String facetQuery); @Override int getCurrentPage(); void setCurrentPage(int currentPage); @Override long getHitsCount(); void setHitsCount(long hitsCount); Map<String, Set<String>> getSearchTerms(); int getCurrentHitIndex(); int getCurrentHitIndexDisplay(); void increaseCurrentHitIndex(); int getHitIndexOperand(); void setHitIndexOperand(int hitIndexOperand); void findCurrentHitIndex(String pi, int page, boolean aggregateHits); BrowseElement getNextElement(); BrowseElement getPreviousElement(); @Override List<SearchFilter> getSearchFilters(); @Override String getCurrentSearchFilterString(); @Override void setCurrentSearchFilterString(String searchFilterLabel); void resetSearchFilter(); void resetCurrentHitIndex(); boolean isSortingEnabled(); List<SearchQueryGroup> getAdvancedQueryGroups(); boolean addNewAdvancedQueryGroup(); boolean removeAdvancedQueryGroup(SearchQueryGroup group); List<StringPair> getAdvancedSearchSelectItems(String field, String language, boolean hierarchical); List<StringPair> getAllCollections(); List<StringPair> getAllCollections(String language); int getAdvancedSearchGroupOperator(); void setAdvancedSearchGroupOperator(int advancedSearchGroupOperator); List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(); static List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(String language); String getSearchInCurrentItemString(); void setSearchInCurrentItemString(String searchInCurrentItemString); Search getCurrentSearch(); void setCurrentSearch(Search currentSearch); String saveSearchAction(); String getRssUrl(); boolean isSearchSavingEnabled(); String executeSavedSearchAction(Search search); String exportSearchAsExcelAction(); int getHitsPerPage(); void setHitsPerPage(int hitsPerPage); String getAdvancedSearchQueryInfo(); @Override SearchFacets getFacets(); Future<Boolean> isDownloadReady(); long getTotalNumberOfVolumes(); String getSearchUrl(); @Override int getLastPage(); StructElement getStructElement(String pi); @Override String getCurrentSearchUrlRoot(); String getCurrentSearchUrlPart(); void updateFacetItem(String field, boolean hierarchical); List<FacetItem> getStaticDrillDown(String field, String subQuery, Integer resultLimit, final Boolean reverseOrder); @Override boolean isSearchPerformed(); @Override boolean isExplicitSearchPerformed(); boolean isShowReducedSearchOptions(); void setShowReducedSearchOptions(boolean showReducedSearchOptions); void setFirstQueryItemValue(String value); void getFirstQueryItemValue(); void setBookmarkListName(String name); String getBookmarkListName(); void setBookmarkListSharedKey(String key); String getBookmarkListSharedKey(); }
|
SearchBean implements SearchInterface, Serializable { public List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields() { return getAdvancedSearchAllowedFields(navigationHelper.getLocaleString()); } SearchBean(); @PostConstruct void init(); void setNavigationHelper(NavigationHelper navigationHelper); void clearSearchItemLists(); String search(); @Override String searchSimple(); String searchSimple(boolean resetParameters); String searchSimple(boolean resetParameters, boolean resetFacets); String searchSimpleResetCollections(); String searchSimpleSetFacets(String facetString); @Override String searchAdvanced(); String searchAdvanced(boolean resetParameters); String searchDirect(); String resetSearchAction(); @Override String resetSearch(); void resetSearchResults(); void resetSearchParameters(); void resetSearchParameters(boolean resetAll); void setAdvancedQueryItemsReset(boolean reset); void hitsPerPageListener(); void executeSearch(); @Override int getActiveSearchType(); @Override void setActiveSearchType(int activeSearchType); void resetActiveSearchType(); @Override List<String> autocomplete(String suggest); @Override boolean isSearchInDcFlag(); String getInvisibleSearchString(); void setInvisibleSearchString(String invisibleSearchString); @Override String getSearchString(); String getSearchStringForUrl(); void setSearchStringForUrl(String searchString); @Override void setSearchString(String searchString); @Override String getExactSearchString(); void setExactSearchString(String inSearchString); String getExactSearchStringResetGui(); void setExactSearchStringResetGui(String inSearchString); @Override void setSortString(String sortString); @Override String getSortString(); void mirrorAdvancedSearchCurrentHierarchicalFacets(); String removeFacetAction(String facetQuery); @Override int getCurrentPage(); void setCurrentPage(int currentPage); @Override long getHitsCount(); void setHitsCount(long hitsCount); Map<String, Set<String>> getSearchTerms(); int getCurrentHitIndex(); int getCurrentHitIndexDisplay(); void increaseCurrentHitIndex(); int getHitIndexOperand(); void setHitIndexOperand(int hitIndexOperand); void findCurrentHitIndex(String pi, int page, boolean aggregateHits); BrowseElement getNextElement(); BrowseElement getPreviousElement(); @Override List<SearchFilter> getSearchFilters(); @Override String getCurrentSearchFilterString(); @Override void setCurrentSearchFilterString(String searchFilterLabel); void resetSearchFilter(); void resetCurrentHitIndex(); boolean isSortingEnabled(); List<SearchQueryGroup> getAdvancedQueryGroups(); boolean addNewAdvancedQueryGroup(); boolean removeAdvancedQueryGroup(SearchQueryGroup group); List<StringPair> getAdvancedSearchSelectItems(String field, String language, boolean hierarchical); List<StringPair> getAllCollections(); List<StringPair> getAllCollections(String language); int getAdvancedSearchGroupOperator(); void setAdvancedSearchGroupOperator(int advancedSearchGroupOperator); List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(); static List<AdvancedSearchFieldConfiguration> getAdvancedSearchAllowedFields(String language); String getSearchInCurrentItemString(); void setSearchInCurrentItemString(String searchInCurrentItemString); Search getCurrentSearch(); void setCurrentSearch(Search currentSearch); String saveSearchAction(); String getRssUrl(); boolean isSearchSavingEnabled(); String executeSavedSearchAction(Search search); String exportSearchAsExcelAction(); int getHitsPerPage(); void setHitsPerPage(int hitsPerPage); String getAdvancedSearchQueryInfo(); @Override SearchFacets getFacets(); Future<Boolean> isDownloadReady(); long getTotalNumberOfVolumes(); String getSearchUrl(); @Override int getLastPage(); StructElement getStructElement(String pi); @Override String getCurrentSearchUrlRoot(); String getCurrentSearchUrlPart(); void updateFacetItem(String field, boolean hierarchical); List<FacetItem> getStaticDrillDown(String field, String subQuery, Integer resultLimit, final Boolean reverseOrder); @Override boolean isSearchPerformed(); @Override boolean isExplicitSearchPerformed(); boolean isShowReducedSearchOptions(); void setShowReducedSearchOptions(boolean showReducedSearchOptions); void setFirstQueryItemValue(String value); void getFirstQueryItemValue(); void setBookmarkListName(String name); String getBookmarkListName(); void setBookmarkListSharedKey(String key); String getBookmarkListSharedKey(); static final String URL_ENCODING; }
|
@Test public void testGetAllMediaCategories() throws DAOException { List<CMSCategory> tags = bean.getAllMediaCategories(); Assert.assertEquals(7, tags.size()); }
|
public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); }
|
CmsMediaBean implements Serializable { public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); } }
|
CmsMediaBean implements Serializable { public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); } CmsMediaBean(); }
|
CmsMediaBean implements Serializable { public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAllMedia(); TableDataProvider<CategorizableTranslatedSelectable<CMSMediaItem>> getDataProvider(); List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems(); void reloadMediaList(); void reloadMediaList(boolean resetCurrentPage); void deleteSelectedItems(); void saveSelectedItems(); static String getMediaUrl(CMSMediaItem item); static String getMediaUrl(CMSMediaItem item, String width, String height); static String getMediaFileAsString(CMSMediaItem item); static String getMediaPreviewUrl(CMSMediaItem item); boolean isImage(CMSMediaItem item); boolean isText(CMSMediaItem item); void saveSelectedMediaItem(); void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories); void saveMedia(CMSMediaItem media); static String getFileName(Part filePart); void setSelectedTag(String selectedTag); String getSelectedTag(); List<CMSCategory> getAllMediaCategories(); Collection<CMSMediaItem.DisplaySize> getMediaItemDisplaySizes(); static String getImageFilter(); static String getDocumentFilter(); String getFilter(); void setFilter(String filter); String getFilenameFilter(); void setFilenameFilter(String filter); void setSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); TranslatedSelectable<CMSMediaItem> getSelectedMediaItem(); void setAllSelected(boolean allSelected); boolean isAllSelected(); boolean needsPaginator(); }
|
CmsMediaBean implements Serializable { public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAllMedia(); TableDataProvider<CategorizableTranslatedSelectable<CMSMediaItem>> getDataProvider(); List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems(); void reloadMediaList(); void reloadMediaList(boolean resetCurrentPage); void deleteSelectedItems(); void saveSelectedItems(); static String getMediaUrl(CMSMediaItem item); static String getMediaUrl(CMSMediaItem item, String width, String height); static String getMediaFileAsString(CMSMediaItem item); static String getMediaPreviewUrl(CMSMediaItem item); boolean isImage(CMSMediaItem item); boolean isText(CMSMediaItem item); void saveSelectedMediaItem(); void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories); void saveMedia(CMSMediaItem media); static String getFileName(Part filePart); void setSelectedTag(String selectedTag); String getSelectedTag(); List<CMSCategory> getAllMediaCategories(); Collection<CMSMediaItem.DisplaySize> getMediaItemDisplaySizes(); static String getImageFilter(); static String getDocumentFilter(); String getFilter(); void setFilter(String filter); String getFilenameFilter(); void setFilenameFilter(String filter); void setSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); TranslatedSelectable<CMSMediaItem> getSelectedMediaItem(); void setAllSelected(boolean allSelected); boolean isAllSelected(); boolean needsPaginator(); }
|
@Test public void testGetMediaItems() throws DAOException { bean.setFilter(""); Assert.assertEquals(4, bean.getMediaItems().size()); bean.setFilter("tag1"); Assert.assertEquals(3, bean.getMediaItems().size()); bean.setFilter(""); bean.setFilenameFilter(bean.getImageFilter()); Assert.assertEquals(4, bean.getMediaItems().size()); bean.setFilenameFilter(".*\\.xml"); Assert.assertEquals(0, bean.getMediaItems().size()); }
|
public List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems() throws DAOException { return this.dataProvider.getPaginatorList(); }
|
CmsMediaBean implements Serializable { public List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems() throws DAOException { return this.dataProvider.getPaginatorList(); } }
|
CmsMediaBean implements Serializable { public List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems() throws DAOException { return this.dataProvider.getPaginatorList(); } CmsMediaBean(); }
|
CmsMediaBean implements Serializable { public List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems() throws DAOException { return this.dataProvider.getPaginatorList(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAllMedia(); TableDataProvider<CategorizableTranslatedSelectable<CMSMediaItem>> getDataProvider(); List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems(); void reloadMediaList(); void reloadMediaList(boolean resetCurrentPage); void deleteSelectedItems(); void saveSelectedItems(); static String getMediaUrl(CMSMediaItem item); static String getMediaUrl(CMSMediaItem item, String width, String height); static String getMediaFileAsString(CMSMediaItem item); static String getMediaPreviewUrl(CMSMediaItem item); boolean isImage(CMSMediaItem item); boolean isText(CMSMediaItem item); void saveSelectedMediaItem(); void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories); void saveMedia(CMSMediaItem media); static String getFileName(Part filePart); void setSelectedTag(String selectedTag); String getSelectedTag(); List<CMSCategory> getAllMediaCategories(); Collection<CMSMediaItem.DisplaySize> getMediaItemDisplaySizes(); static String getImageFilter(); static String getDocumentFilter(); String getFilter(); void setFilter(String filter); String getFilenameFilter(); void setFilenameFilter(String filter); void setSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); TranslatedSelectable<CMSMediaItem> getSelectedMediaItem(); void setAllSelected(boolean allSelected); boolean isAllSelected(); boolean needsPaginator(); }
|
CmsMediaBean implements Serializable { public List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems() throws DAOException { return this.dataProvider.getPaginatorList(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAllMedia(); TableDataProvider<CategorizableTranslatedSelectable<CMSMediaItem>> getDataProvider(); List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems(); void reloadMediaList(); void reloadMediaList(boolean resetCurrentPage); void deleteSelectedItems(); void saveSelectedItems(); static String getMediaUrl(CMSMediaItem item); static String getMediaUrl(CMSMediaItem item, String width, String height); static String getMediaFileAsString(CMSMediaItem item); static String getMediaPreviewUrl(CMSMediaItem item); boolean isImage(CMSMediaItem item); boolean isText(CMSMediaItem item); void saveSelectedMediaItem(); void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories); void saveMedia(CMSMediaItem media); static String getFileName(Part filePart); void setSelectedTag(String selectedTag); String getSelectedTag(); List<CMSCategory> getAllMediaCategories(); Collection<CMSMediaItem.DisplaySize> getMediaItemDisplaySizes(); static String getImageFilter(); static String getDocumentFilter(); String getFilter(); void setFilter(String filter); String getFilenameFilter(); void setFilenameFilter(String filter); void setSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); TranslatedSelectable<CMSMediaItem> getSelectedMediaItem(); void setAllSelected(boolean allSelected); boolean isAllSelected(); boolean needsPaginator(); }
|
@Test public void testGetImageFilter() { String file1 = "image.jpg"; String file2 = "image.JPEG"; String file3 = "image.xml"; Assert.assertTrue(file1.matches(bean.getImageFilter())); Assert.assertTrue(file2.matches(bean.getImageFilter())); Assert.assertFalse(file3.matches(bean.getImageFilter())); }
|
public static String getImageFilter() { return "(?i).*\\.(png|jpe?g|gif|tiff?|jp2)"; }
|
CmsMediaBean implements Serializable { public static String getImageFilter() { return "(?i).*\\.(png|jpe?g|gif|tiff?|jp2)"; } }
|
CmsMediaBean implements Serializable { public static String getImageFilter() { return "(?i).*\\.(png|jpe?g|gif|tiff?|jp2)"; } CmsMediaBean(); }
|
CmsMediaBean implements Serializable { public static String getImageFilter() { return "(?i).*\\.(png|jpe?g|gif|tiff?|jp2)"; } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAllMedia(); TableDataProvider<CategorizableTranslatedSelectable<CMSMediaItem>> getDataProvider(); List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems(); void reloadMediaList(); void reloadMediaList(boolean resetCurrentPage); void deleteSelectedItems(); void saveSelectedItems(); static String getMediaUrl(CMSMediaItem item); static String getMediaUrl(CMSMediaItem item, String width, String height); static String getMediaFileAsString(CMSMediaItem item); static String getMediaPreviewUrl(CMSMediaItem item); boolean isImage(CMSMediaItem item); boolean isText(CMSMediaItem item); void saveSelectedMediaItem(); void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories); void saveMedia(CMSMediaItem media); static String getFileName(Part filePart); void setSelectedTag(String selectedTag); String getSelectedTag(); List<CMSCategory> getAllMediaCategories(); Collection<CMSMediaItem.DisplaySize> getMediaItemDisplaySizes(); static String getImageFilter(); static String getDocumentFilter(); String getFilter(); void setFilter(String filter); String getFilenameFilter(); void setFilenameFilter(String filter); void setSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); TranslatedSelectable<CMSMediaItem> getSelectedMediaItem(); void setAllSelected(boolean allSelected); boolean isAllSelected(); boolean needsPaginator(); }
|
CmsMediaBean implements Serializable { public static String getImageFilter() { return "(?i).*\\.(png|jpe?g|gif|tiff?|jp2)"; } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAllMedia(); TableDataProvider<CategorizableTranslatedSelectable<CMSMediaItem>> getDataProvider(); List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems(); void reloadMediaList(); void reloadMediaList(boolean resetCurrentPage); void deleteSelectedItems(); void saveSelectedItems(); static String getMediaUrl(CMSMediaItem item); static String getMediaUrl(CMSMediaItem item, String width, String height); static String getMediaFileAsString(CMSMediaItem item); static String getMediaPreviewUrl(CMSMediaItem item); boolean isImage(CMSMediaItem item); boolean isText(CMSMediaItem item); void saveSelectedMediaItem(); void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories); void saveMedia(CMSMediaItem media); static String getFileName(Part filePart); void setSelectedTag(String selectedTag); String getSelectedTag(); List<CMSCategory> getAllMediaCategories(); Collection<CMSMediaItem.DisplaySize> getMediaItemDisplaySizes(); static String getImageFilter(); static String getDocumentFilter(); String getFilter(); void setFilter(String filter); String getFilenameFilter(); void setFilenameFilter(String filter); void setSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem); TranslatedSelectable<CMSMediaItem> getSelectedMediaItem(); void setAllSelected(boolean allSelected); boolean isAllSelected(); boolean needsPaginator(); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.