@Test public void missingTranslationsDontAffectBehavior() { SolrInputDocument doc = new SolrInputDocument(); String testId = "HP:0000001"; doc.setField("id", testId); VocabularyInputTerm term = new SolrVocabularyInputTerm(doc, this.vocabularyInstance); this.extension.extendTerm(term, this.vocabularyInstance); assertEquals(testId, term.getId()); assertNull(term.get("id_es")); assertNull(term.get("name_es")); assertNull(term.get("def_es")); assertNull(term.get("synonym_es")); }
@Override public void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary) { Locale targetLocale = getTargetLocale(); String label = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(NAME_KEY), targetLocale); String definition = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(DESCRIPTION_KEY), targetLocale); String synonyms = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(SYNONYM_KEY), targetLocale); if (StringUtils.isNotBlank(label)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, NAME_KEY, targetLocale), label); } if (StringUtils.isNotBlank(definition)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, DESCRIPTION_KEY, targetLocale), definition); } if (StringUtils.isNotBlank(synonyms)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, SYNONYM_KEY, targetLocale), splitMultiValuedText(synonyms)); } }
AbstractXliffTranslatedVocabularyExtension implements VocabularyExtension { @Override public void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary) { Locale targetLocale = getTargetLocale(); String label = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(NAME_KEY), targetLocale); String definition = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(DESCRIPTION_KEY), targetLocale); String synonyms = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(SYNONYM_KEY), targetLocale); if (StringUtils.isNotBlank(label)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, NAME_KEY, targetLocale), label); } if (StringUtils.isNotBlank(definition)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, DESCRIPTION_KEY, targetLocale), definition); } if (StringUtils.isNotBlank(synonyms)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, SYNONYM_KEY, targetLocale), splitMultiValuedText(synonyms)); } } }
AbstractXliffTranslatedVocabularyExtension implements VocabularyExtension { @Override public void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary) { Locale targetLocale = getTargetLocale(); String label = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(NAME_KEY), targetLocale); String definition = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(DESCRIPTION_KEY), targetLocale); String synonyms = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(SYNONYM_KEY), targetLocale); if (StringUtils.isNotBlank(label)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, NAME_KEY, targetLocale), label); } if (StringUtils.isNotBlank(definition)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, DESCRIPTION_KEY, targetLocale), definition); } if (StringUtils.isNotBlank(synonyms)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, SYNONYM_KEY, targetLocale), splitMultiValuedText(synonyms)); } }  }
AbstractXliffTranslatedVocabularyExtension implements VocabularyExtension { @Override public void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary) { Locale targetLocale = getTargetLocale(); String label = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(NAME_KEY), targetLocale); String definition = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(DESCRIPTION_KEY), targetLocale); String synonyms = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(SYNONYM_KEY), targetLocale); if (StringUtils.isNotBlank(label)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, NAME_KEY, targetLocale), label); } if (StringUtils.isNotBlank(definition)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, DESCRIPTION_KEY, targetLocale), definition); } if (StringUtils.isNotBlank(synonyms)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, SYNONYM_KEY, targetLocale), splitMultiValuedText(synonyms)); } }  @Override boolean isVocabularySupported(Vocabulary vocabulary); @Override void indexingStarted(Vocabulary vocabulary); @Override void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary); @Override void indexingEnded(Vocabulary vocabulary); @Override void extendQuery(SolrQuery query, Vocabulary vocabulary); }
AbstractXliffTranslatedVocabularyExtension implements VocabularyExtension { @Override public void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary) { Locale targetLocale = getTargetLocale(); String label = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(NAME_KEY), targetLocale); String definition = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(DESCRIPTION_KEY), targetLocale); String synonyms = this.translator.getTranslation(vocabulary.getIdentifier(), term.getId().replace(':', '_') + KEY_MAP.get(SYNONYM_KEY), targetLocale); if (StringUtils.isNotBlank(label)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, NAME_KEY, targetLocale), label); } if (StringUtils.isNotBlank(definition)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, DESCRIPTION_KEY, targetLocale), definition); } if (StringUtils.isNotBlank(synonyms)) { term.set(String.format(TRANSLATED_FIELD_FORMAT, SYNONYM_KEY, targetLocale), splitMultiValuedText(synonyms)); } }  @Override boolean isVocabularySupported(Vocabulary vocabulary); @Override void indexingStarted(Vocabulary vocabulary); @Override void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary); @Override void indexingEnded(Vocabulary vocabulary); @Override void extendQuery(SolrQuery query, Vocabulary vocabulary);  }