public SqlAdvisorHint(SqlMoniker id) { this.id = id.toString(); final List<String> names = id.getFullyQualifiedNames(); this.names = names == null ? null : names.toArray(new String[0]); type = id.getType().name(); } }
public int compare(SqlMoniker o1, SqlMoniker o2) { int c = o1.getType().compareTo(o2.getType()); if (c == 0) { c = listOrdering.compare(o1.getFullyQualifiedNames(), o2.getFullyQualifiedNames()); } return c; } };
public int compare(SqlMoniker o1, SqlMoniker o2) { int c = o1.getType().compareTo(o2.getType()); if (c == 0) { c = listOrdering.compare(o1.getFullyQualifiedNames(), o2.getFullyQualifiedNames()); } return c; } };
public SqlAdvisorHint(SqlMoniker id) { this.id = id.toString(); final List<String> names = id.getFullyQualifiedNames(); this.names = names == null ? null : names.toArray(new String[0]); type = id.getType().name(); } }
/** * Builds the response object for query suggestions. * * @param suggestionList The suggestion list returned from the SqlAdvisor. * * @return The built SuggestionResponse object or null if there are no suggestions. */ public SuggestionResponse buildSuggestionResponse(List<SqlMoniker> suggestionList) { // Return empty response in REST request if (suggestionList == null || suggestionList.isEmpty()) { return null; } // Create and populate suggestion response list List<SuggestionResponse.Suggestion> suggestions = new ArrayList<>(); for (SqlMoniker hint : suggestionList) { // Quote the identifiers if they are not keywords or functions, // and are required to be quoted. List<String> qualifiedNames = hint.getFullyQualifiedNames(); if ((hint.getType() != SqlMonikerType.KEYWORD) && (hint.getType() != SqlMonikerType.FUNCTION)) { qualifiedNames = qualifiedNames.stream().map(name -> quoteIdentifier(name)).collect(Collectors.toList()); } suggestions.add( new SuggestionResponse.Suggestion(Joiner.on(".").join(qualifiedNames),hint.getType().name())); } SuggestionResponse response = new SuggestionResponse(suggestions); return response; }