@Override public void init(Curator curator, String taskId) throws IOException { super.init(curator, taskId); try { reader = new DCInputsReader(); } catch (DCInputsReaderException dcrE) { throw new IOException(dcrE.getMessage(), dcrE); } }
@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); }
setResult(sb.toString()); } catch (DCInputsReaderException dcrE) { throw new IOException(dcrE.getMessage(), dcrE);
throw new IllegalStateException(e.getMessage(), e);
private void autoRegisterAuthorityFromInputReader() { try { DCInputsReader dcInputsReader = new DCInputsReader(); for (DCInputSet dcinputSet : dcInputsReader.getAllInputs(Integer.MAX_VALUE, 0)) { DCInput[][] dcinputs = dcinputSet.getFields(); for (DCInput[] dcrows : dcinputs) { for (DCInput dcinput : dcrows) { if (StringUtils.isNotBlank(dcinput.getPairsType()) || StringUtils.isNotBlank(dcinput.getVocabulary())) { String authorityName = dcinput.getPairsType(); if (StringUtils.isBlank(authorityName)) { authorityName = dcinput.getVocabulary(); } if (!StringUtils.equals(dcinput.getInputType(), "qualdrop_value")) { String fieldKey = makeFieldKey(dcinput.getSchema(), dcinput.getElement(), dcinput.getQualifier()); boolean req = ConfigurationManager .getBooleanProperty("authority.required." + fieldKey, false); controlled.put(fieldKey, true); isAuthorityRequired.put(fieldKey, req); } } } } } } catch (DCInputsReaderException e) { throw new IllegalStateException(e.getMessage(), e); } } }