@Override public Choices getMatches(String field, String query, Collection collection, int start, int limit, String locale) { String formName; try { init(); if (collection == null) { Set<Choice> choices = new HashSet<Choice>(); //workaround search in all authority configured for (ChoiceAuthority ca : delegates.values()) { Choices tmp = ca.getMatches(field, query, null, start, limit, locale); if (tmp.total > 0) { Set<Choice> mySet = new HashSet<Choice>(Arrays.asList(tmp.values)); choices.addAll(mySet); } } if (!choices.isEmpty()) { Choice[] results = new Choice[choices.size() - 1]; choices.toArray(results); return new Choices(results, 0, choices.size(), Choices.CF_AMBIGUOUS, false); } } else { formName = dci.getInputFormNameByCollectionAndField(collection, field); return delegates.get(formName).getMatches(field, query, collection, start, limit, locale); } } catch (DCInputsReaderException e) { log.error(e.getMessage(), e); } return new Choices(Choices.CF_NOTFOUND); }
@Override public Choices getBestMatch(String field, String text, Collection collection, String locale) { String formName; try { init(); if (collection == null) { Set<Choice> choices = new HashSet<Choice>(); //workaround search in all authority configured for (ChoiceAuthority ca : delegates.values()) { Choices tmp = ca.getBestMatch(field, text, null, locale); if (tmp.total > 0) { Set<Choice> mySet = new HashSet<Choice>(Arrays.asList(tmp.values)); choices.addAll(mySet); } } if (!choices.isEmpty()) { Choice[] results = new Choice[choices.size() - 1]; choices.toArray(results); return new Choices(results, 0, choices.size(), Choices.CF_UNCERTAIN, false); } } else { formName = dci.getInputFormNameByCollectionAndField(collection, field); return delegates.get(formName).getBestMatch(field, text, collection, locale); } } catch (DCInputsReaderException e) { log.error(e.getMessage(), e); } return new Choices(Choices.CF_NOTFOUND); }