use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class TaxonomyConfigServiceTest method validateRangeTaxonomyWithoutRangeAttribute.
@Test(expected = VocabularyMissingRangeAttributeException.class)
public void validateRangeTaxonomyWithoutRangeAttribute() {
Taxonomy taxonomy = new Taxonomy("tax001");
taxonomy.addVocabulary(createVocabulary("voc001", createTerms("term001", "term002"), AttributeBuilder.newBuilder().field("tax.voc").alias("tax-voc-range").type("integer").build()));
new TaxonomyConfigService().validateTaxonomy(taxonomy);
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class Mica310Upgrade method addDefaultFacets.
private void addDefaultFacets() {
logger.info("Add default facets in study taxonomy");
ImmutableList<String> vocabulariesWithFacet = ImmutableList.<String>builder().add("methods-design").add("start").add("end").add("populations-selectionCriteria-countriesIso").add("populations-selectionCriteria-ageMin").add("populations-selectionCriteria-ageMax").add("populations-selectionCriteria-gender").add("populations-selectionCriteria-pregnantWomen").add("populations-selectionCriteria-newborn").add("populations-selectionCriteria-twins").add("numberOfParticipants-participant-number").add("numberOfParticipants-sample-number").add("methods-recruitments").add("populations-recruitment-dataSources").add("populations-dataCollectionEvents-dataSources").add("populations-dataCollectionEvents-bioSamples").add("access", "19").build();
Taxonomy studyTaxonomy = taxonomyConfigService.findByTarget(TaxonomyTarget.STUDY);
for (Vocabulary vocabulary : studyTaxonomy.getVocabularies()) {
if (vocabulariesWithFacet.contains(vocabulary.getName())) {
vocabulary.addAttribute("facet", "true");
vocabulary.addAttribute("facetPosition", "0");
vocabulary.addAttribute("facetExpanded", "false");
}
}
taxonomyConfigService.update(TaxonomyTarget.STUDY, studyTaxonomy);
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class TaxonomyConfigService method mergeWithDefault.
public void mergeWithDefault(TaxonomyTarget target) {
Taxonomy targetTaxonomy = findByTarget(target);
mergeVocabulariesTerms(targetTaxonomy, getDefault(target));
updateInternal(target, targetTaxonomy);
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class OpalServiceHelper method getTaxonomies.
// opal root url as key
@Cacheable(value = "opal-taxonomies", key = "#opalJavaClient.newUri().build()")
public Map<String, Taxonomy> getTaxonomies(OpalJavaClient opalJavaClient) {
log.info("Fetching opal taxonomies");
URI uri = opalJavaClient.newUri().segment("system", "conf", "taxonomies").build();
List<Opal.TaxonomyDto> taxonomies = opalJavaClient.getResources(Opal.TaxonomyDto.class, uri, Opal.TaxonomyDto.newBuilder());
ConcurrentMap<String, Taxonomy> taxonomiesList = taxonomies.stream().collect(Collectors.toConcurrentMap(Opal.TaxonomyDto::getName, this::fromDto));
eventBus.post(new OpalTaxonomiesUpdatedEvent(taxonomiesList));
return taxonomiesList;
}
use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.
the class TaxonomyAggregationMetaDataProvider method getVocabulary.
private Optional<Vocabulary> getVocabulary(String aggregation) {
String key = aggregation.replaceAll("^attributes-", "").replaceAll("-und$", "");
AttributeKey attrKey = AttributeKey.from(key);
String targetTaxonomy = attrKey.hasNamespace(null) ? "Default" : attrKey.getNamespace();
String targetVocabulary = attrKey.getName();
return //
getTaxonomies().stream().filter(//
taxonomy -> !Strings.isNullOrEmpty(targetTaxonomy) && taxonomy.getName().equals(targetTaxonomy)).map(//
Taxonomy::getVocabularies).flatMap(//
Collection::stream).filter(//
vocabulary -> vocabulary.getName().equals(targetVocabulary)).findFirst();
}
Aggregations