use of org.obiba.mica.micaConfig.event.OpalTaxonomiesUpdatedEvent 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().map(taxonomyDto -> {
Taxonomy taxonomy = fromDto(taxonomyDto);
String defaultTermsSortOrder = opalTaxonomiesProperties.getProperty("defaultTermsSortOrder");
if (!Strings.isNullOrEmpty(defaultTermsSortOrder)) {
taxonomy.getVocabularies().forEach(vocabulary -> vocabulary.addAttribute("termsSortKey", defaultTermsSortOrder));
}
return taxonomy;
}).collect(Collectors.toConcurrentMap(TaxonomyEntity::getName, taxonomy -> taxonomy));
eventBus.post(new OpalTaxonomiesUpdatedEvent(taxonomiesList));
return taxonomiesList;
}
Aggregations