Search in sources :

Example 1 with Opal

use of org.obiba.opal.web.model.Opal 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;
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Opal(org.obiba.opal.web.model.Opal) URI(java.net.URI) OpalTaxonomiesUpdatedEvent(org.obiba.mica.micaConfig.event.OpalTaxonomiesUpdatedEvent) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

URI (java.net.URI)1 OpalTaxonomiesUpdatedEvent (org.obiba.mica.micaConfig.event.OpalTaxonomiesUpdatedEvent)1 Taxonomy (org.obiba.opal.core.domain.taxonomy.Taxonomy)1 Opal (org.obiba.opal.web.model.Opal)1 Cacheable (org.springframework.cache.annotation.Cacheable)1