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();
}
Aggregations