use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class TaxonomyConfigServiceTest method validateRangeTaxonomyWithoutTerms.
@Test(expected = VocabularyMissingRangeTermsException.class)
public void validateRangeTaxonomyWithoutTerms() {
Taxonomy taxonomy = new Taxonomy("tax001");
taxonomy.addVocabulary(createVocabulary("voc001", null, AttributeBuilder.newBuilder().field("tax.voc").alias("tax-voc-range").range("true").type("integer").build()));
new TaxonomyConfigService().validateTaxonomy(taxonomy);
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class AbstractTaxonomySearchResource method filterTerms.
protected List<String> filterTerms(TaxonomyTarget target, String query, String locale, List<String> vocabularies) {
try {
if (vocabularies != null && vocabularies.size() > 0) {
// filter on vocabulary names; remove taxonomy prefixes ('Mica_study:')
String vocabulariesQuery = vocabularies.stream().map(v -> String.format("vocabularyName:%s", v.replaceAll("^([^\\:]+):", ""))).collect(Collectors.joining(" AND "));
query = Strings.isNullOrEmpty(query) ? vocabulariesQuery : query + " " + vocabulariesQuery;
}
return esTaxonomyTermService.find(0, MAX_SIZE, DEFAULT_SORT, "asc", null, getTargettedQuery(target, query), getFields(locale, TERM_FIELDS)).getList();
} catch (Exception e) {
initTaxonomies();
// for a 404 response
throw new NoSuchElementException();
}
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class Mica220UpgradeTest method getWrapper.
private TaxonomyEntityWrapper getWrapper(String name) throws IOException {
ObjectMapper mapper = new ObjectMapper();
Taxonomy taxonomy = mapper.readValue(new File("src/test/resources/config/mica-" + name + ".json"), Taxonomy.class);
TaxonomyEntityWrapper wrapper = new TaxonomyEntityWrapper();
wrapper.setTarget(name);
wrapper.setTaxonomy(taxonomy);
return wrapper;
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class TaxonomyConfigServiceTest method merge_taxonomy_with_one_having_same_vocabulary_but_extra_term.
@Test
public void merge_taxonomy_with_one_having_same_vocabulary_but_extra_term() {
Taxonomy tax001 = new Taxonomy("tax001");
tax001.addVocabulary(createVocabulary("voc001", null, null));
Taxonomy tax002 = new Taxonomy("tax002");
tax002.addVocabulary(createVocabulary("voc001", createTerms("term001"), null));
new TaxonomyConfigService().mergeVocabulariesTerms(tax001, tax002);
assert tax001.getVocabulary("voc001").hasTerm("term001");
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class TaxonomyConfigServiceTest method merge_taxonomy_with_vocabulary_having_one_term_with_one_having_same_vocabulary_without_term.
@Test
public void merge_taxonomy_with_vocabulary_having_one_term_with_one_having_same_vocabulary_without_term() {
Taxonomy tax001 = new Taxonomy("tax001");
tax001.addVocabulary(createVocabulary("voc001", createTerms("term001"), null));
Taxonomy tax002 = new Taxonomy("tax002");
tax002.addVocabulary(createVocabulary("voc001", null, null));
new TaxonomyConfigService().mergeVocabulariesTerms(tax001, tax002);
assert tax001.getVocabulary("voc001").hasTerm("term001");
}
Aggregations