Search in sources :

Example 1 with Vocabulary

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;
}
Also used : Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy)

Example 2 with Vocabulary

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;
}
Also used : Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary) Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Term(org.obiba.opal.core.domain.taxonomy.Term)

Example 3 with Vocabulary

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();
}
Also used : Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary)

Example 4 with Vocabulary

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);
}
Also used : Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary) Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy)

Example 5 with Vocabulary

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;
}
Also used : Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary)

Aggregations

Vocabulary (org.obiba.opal.core.domain.taxonomy.Vocabulary)14 Taxonomy (org.obiba.opal.core.domain.taxonomy.Taxonomy)6 Term (org.obiba.opal.core.domain.taxonomy.Term)4 Map (java.util.Map)2 LocalizedString (org.obiba.mica.core.domain.LocalizedString)2 Timed (com.codahale.metrics.annotation.Timed)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 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 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 TaxonomyEntityWrapper (org.obiba.mica.core.domain.TaxonomyEntityWrapper)1 OpalService (org.obiba.mica.micaConfig.service.OpalService)1 AggregationMetaDataProvider (org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider)1 TaxonomyTarget (org.obiba.mica.spi.search.TaxonomyTarget)1