public String findValueInDictionaryWithName(String version, String key) { if (Arrays.asList(BaseSurvey.SURVEY_VERSION_ZAMBIA).contains(version)) for (DictionaryItem dictionaryItem : zambiaDictionary) { if (dictionaryItem.getId().compareToIgnoreCase(key) == 0) { return dictionaryItem.getName(); } } else if (Arrays.asList(BaseSurvey.SURVEY_VERSION_TUNISIA).contains(version)) for (DictionaryItem dictionaryItem : tunisiaDictionary) { if (dictionaryItem.getId().compareToIgnoreCase(key) == 0) { return dictionaryItem.getName(); } } else if (Arrays.asList(BaseSurvey.SURVEY_VERSION_SENEGAL).contains(version)) for (DictionaryItem dictionaryItem : senegalDictionary) { if (dictionaryItem.getId().compareToIgnoreCase(key) == 0) { return dictionaryItem.getName(); } } else if (Arrays.asList(BaseSurvey.SURVEY_VERSION_CAMEROON).contains(version)) for (DictionaryItem dictionaryItem : cameroonDictionary) { if (dictionaryItem.getId().compareToIgnoreCase(key) == 0) { return dictionaryItem.getName(); } } return null; }
public String findKeyInDictionary(String version, String value, String group) { String findValue = value.replaceAll("\\s+", ""); String key = null; if (Arrays.asList(BaseSurvey.SURVEY_VERSION_ZAMBIA).contains(version)) { for (DictionaryItem dictionaryItem : zambiaDictionary) { String sourceValue = dictionaryItem.getName().replaceAll("\\s+", ""); if (sourceValue.compareToIgnoreCase(findValue) == 0 && (group == null || group.compareToIgnoreCase(dictionaryItem.getGroup()) == 0)) { key = dictionaryItem.getId(); break; } } } else if (Arrays.asList(BaseSurvey.SURVEY_VERSION_TUNISIA).contains(version)) { for (DictionaryItem dictionaryItem : tunisiaDictionary) { String sourceValue = dictionaryItem.getName().replaceAll("\\s+", ""); if (sourceValue.compareToIgnoreCase(findValue) == 0 && (group == null || group.compareToIgnoreCase(dictionaryItem.getGroup()) == 0)) { key = dictionaryItem.getId(); break; } } } else if (Arrays.asList(BaseSurvey.SURVEY_VERSION_SENEGAL).contains(version)) { for (DictionaryItem dictionaryItem : senegalDictionary) { String sourceValue = dictionaryItem.getName().replaceAll("\\s+", ""); if (sourceValue.compareToIgnoreCase(findValue) == 0 && (group == null || group.compareToIgnoreCase(dictionaryItem.getGroup()) == 0)) { key = dictionaryItem.getId(); break; } } } else if (Arrays.asList(BaseSurvey.SURVEY_VERSION_CAMEROON).contains(version)) { for (DictionaryItem dictionaryItem : cameroonDictionary) { String sourceValue = dictionaryItem.getName().replaceAll("\\s+", ""); if (sourceValue.compareToIgnoreCase(findValue) == 0 && (group == null || group.compareToIgnoreCase(dictionaryItem.getGroup()) == 0)) { key = dictionaryItem.getId(); break; } } } return key; }