use of org.obiba.opal.core.domain.taxonomy.Vocabulary in project mica2 by obiba.
the class MicaConfigService method getTaxonomyNode.
private JsonNode getTaxonomyNode(TaxonomyTarget taxonomyTarget, String locale) {
Taxonomy taxonomy = taxonomyConfigService.findByTarget(taxonomyTarget);
ObjectNode vocabularies = new ObjectNode(JsonNodeFactory.instance);
for (Vocabulary vocabulary : taxonomy.getVocabularies()) {
ObjectNode vocabularyNode = createObjectNode(vocabulary, locale);
vocabularyNode = addTerms(vocabularyNode, vocabulary.getTerms(), locale);
vocabularies.set(vocabulary.getName(), vocabularyNode);
}
ObjectNode taxonomyNode = createObjectNode(taxonomy, locale);
taxonomyNode.set("vocabulary", vocabularies);
return taxonomyNode;
}
use of org.obiba.opal.core.domain.taxonomy.Vocabulary 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.Vocabulary in project mica2 by obiba.
the class VocabularyMissingRangeAttributeExceptionMapper method getErrorDto.
@Override
protected GeneratedMessage.ExtendableMessage<?> getErrorDto(VocabularyMissingRangeAttributeException e) {
Vocabulary vocabulary = e.getVocabulary();
ErrorDtos.ClientErrorDto.Builder builder = ErrorDtos.ClientErrorDto.newBuilder().setCode(getStatus().getStatusCode());
if (vocabulary != null) {
builder.setMessageTemplate("server.error.taxonomy.range-criterion-missing-range-attribute");
builder.addArguments(vocabulary.getName());
}
return builder.build();
}
use of org.obiba.opal.core.domain.taxonomy.Vocabulary in project mica2 by obiba.
the class ConfigurationTaxonomyMetaDataProvider method getAllLocalizedMetadata.
private Map<String, LocalizedMetaData> getAllLocalizedMetadata(String aggregation) {
Taxonomy taxonomy = getTaxonomy();
Vocabulary v = taxonomyVocabularyWithAlias(taxonomy, aggregation);
if (v == null && taxonomy.hasVocabulary(aggregation)) {
log.debug("Found in taxonomy {} a vocabulary with name: {}", taxonomy.getName(), aggregation);
v = taxonomy.getVocabulary(aggregation);
}
return populateMetadataMap(v);
}
use of org.obiba.opal.core.domain.taxonomy.Vocabulary in project mica2 by obiba.
the class TaxonomyConfigServiceTest method createVocabulary.
private Vocabulary createVocabulary(String name, List<Term> terms, Map<String, String> attributes) {
Vocabulary vocabulary = new Vocabulary(name);
vocabulary.setTitle(LocalizedString.en(name + "-title"));
vocabulary.setDescription(LocalizedString.en(name + "-desc"));
if (terms != null)
vocabulary.setTerms(terms);
if (attributes != null)
vocabulary.setAttributes(attributes);
return vocabulary;
}
Aggregations