use of org.obiba.opal.core.domain.taxonomy.Term in project mica2 by obiba.
the class TaxonomyService method copy.
private Taxonomy copy(Taxonomy source) {
Taxonomy target = new Taxonomy();
BeanUtils.copyProperties(source, target, "vocabularies");
if (source.hasVocabularies()) {
source.getVocabularies().forEach(sourceVoc -> {
Vocabulary targetVoc = new Vocabulary();
BeanUtils.copyProperties(sourceVoc, targetVoc, "terms");
if (sourceVoc.hasTerms()) {
sourceVoc.getTerms().forEach(sourceTerm -> {
Term targetTerm = new Term();
BeanUtils.copyProperties(sourceTerm, targetTerm);
targetVoc.addTerm(targetTerm);
});
}
target.addVocabulary(targetVoc);
});
}
return target;
}
use of org.obiba.opal.core.domain.taxonomy.Term in project mica2 by obiba.
the class AbstractIdAggregationMetaDataHelper method createTermFromMetaData.
protected Term createTermFromMetaData(String id, AggregationMetaDataProvider.LocalizedMetaData metaData) {
Term term = new Term(id);
term.setTitle(metaData.getTitle());
term.setDescription(metaData.getDescription());
term.addAttribute("className", metaData.getClassName());
return term;
}
use of org.obiba.opal.core.domain.taxonomy.Term in project mica2 by obiba.
the class DatasetDtos method asDto.
private Mica.TermAttributesDto asDto(Taxonomy taxonomy, Attributes attributes, String locale) {
Mica.TermAttributesDto.Builder builder = //
Mica.TermAttributesDto.newBuilder().setTaxonomy(taxonomyDtos.asDto(taxonomy, locale));
Map<String, Mica.TermAttributeDto.Builder> terms = Maps.newHashMap();
attributes.getAttributes(taxonomy.getName()).forEach(attr -> {
if (taxonomy.hasVocabulary(attr.getName())) {
Vocabulary vocabulary = taxonomy.getVocabulary(attr.getName());
String termStr = attr.getValues().getUndetermined();
if (!Strings.isNullOrEmpty(termStr) && vocabulary.hasTerm(termStr)) {
Mica.TermAttributeDto.Builder termBuilder;
if (terms.containsKey(vocabulary.getName())) {
termBuilder = terms.get(vocabulary.getName());
} else {
termBuilder = Mica.TermAttributeDto.newBuilder();
terms.put(vocabulary.getName(), termBuilder);
termBuilder.setVocabulary(taxonomyDtos.asDto(vocabulary, locale));
}
Term term = vocabulary.getTerm(termStr);
termBuilder.addTerms(taxonomyDtos.asDto(term, locale));
}
}
});
// keep vocabulary order
taxonomy.getVocabularies().forEach(vocabulary -> {
if (terms.containsKey(vocabulary.getName())) {
builder.addVocabularyTerms(terms.get(vocabulary.getName()));
}
});
return builder.build();
}
use of org.obiba.opal.core.domain.taxonomy.Term in project mica2 by obiba.
the class TaxonomyConfigServiceTest method createTerm.
private Term createTerm(String name, String title, String desc) {
Term term = new Term(name);
term.setTitle(LocalizedString.en(title));
term.setDescription(LocalizedString.en(desc));
return term;
}
use of org.obiba.opal.core.domain.taxonomy.Term in project mica2 by obiba.
the class MicaConfigService method addTerms.
private ObjectNode addTerms(ObjectNode parentNode, List<Term> terms, String locale) {
if (!isEmpty(terms)) {
ObjectNode termsArrayNode = new ObjectNode(JsonNodeFactory.instance);
for (Term term : terms) {
ObjectNode termNode = createObjectNode(term, locale);
termNode = addTerms(termNode, term.getTerms(), locale);
termsArrayNode.set(term.getName(), termNode);
}
parentNode.set("term", termsArrayNode);
}
return parentNode;
}
Aggregations