Search in sources :

Example 1 with AttributeKey

use of org.obiba.mica.spi.search.support.AttributeKey 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();
}
Also used : AttributeKey(org.obiba.mica.spi.search.support.AttributeKey) LocalizedString(org.obiba.mica.core.domain.LocalizedString) Collection(java.util.Collection) Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) AttributeKey(org.obiba.mica.spi.search.support.AttributeKey) OpalService(org.obiba.mica.micaConfig.service.OpalService) AggregationMetaDataProvider(org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider) Maps(com.google.common.collect.Maps) Inject(javax.inject.Inject) Term(org.obiba.opal.core.domain.taxonomy.Term) Strings(com.google.common.base.Strings) List(java.util.List) Component(org.springframework.stereotype.Component) Map(java.util.Map) Optional(java.util.Optional) Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary) Collections(java.util.Collections) Collection(java.util.Collection) LocalizedString(org.obiba.mica.core.domain.LocalizedString)

Aggregations

Strings (com.google.common.base.Strings)1 Maps (com.google.common.collect.Maps)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 LocalizedString (org.obiba.mica.core.domain.LocalizedString)1 OpalService (org.obiba.mica.micaConfig.service.OpalService)1 AggregationMetaDataProvider (org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider)1 AttributeKey (org.obiba.mica.spi.search.support.AttributeKey)1 Taxonomy (org.obiba.opal.core.domain.taxonomy.Taxonomy)1 Term (org.obiba.opal.core.domain.taxonomy.Term)1 Vocabulary (org.obiba.opal.core.domain.taxonomy.Vocabulary)1 Component (org.springframework.stereotype.Component)1