Search in sources :

Example 1 with TaxonomyEntityWrapper

use of org.obiba.mica.core.domain.TaxonomyEntityWrapper in project mica2 by obiba.

the class TaxonomyConfigService method findByTargetInternal.

private Taxonomy findByTargetInternal(TaxonomyTarget target) {
    // taxonomy of taxonomies is not editable so fall back to the one that comes from the classpath
    if (TaxonomyTarget.TAXONOMY.equals(target))
        return defaultTaxonomyTaxonomy;
    String id = target.asId();
    TaxonomyEntityWrapper taxonomyEntityWrapper = taxonomyConfigRepository.findOne(id);
    if (taxonomyEntityWrapper == null) {
        createDefault(target);
        taxonomyEntityWrapper = taxonomyConfigRepository.findOne(id);
    }
    return taxonomyEntityWrapper.getTaxonomy();
}
Also used : TaxonomyEntityWrapper(org.obiba.mica.core.domain.TaxonomyEntityWrapper)

Example 2 with TaxonomyEntityWrapper

use of org.obiba.mica.core.domain.TaxonomyEntityWrapper in project mica2 by obiba.

the class TaxonomyConfigService method updateInternal.

private void updateInternal(TaxonomyTarget target, Taxonomy taxonomy) {
    validateTaxonomy(taxonomy);
    TaxonomyEntityWrapper taxonomyEntityWrapper = new TaxonomyEntityWrapper();
    taxonomyEntityWrapper.setTarget(target.asId());
    taxonomyEntityWrapper.setTaxonomy(taxonomy);
    taxonomyConfigRepository.save(taxonomyEntityWrapper);
}
Also used : TaxonomyEntityWrapper(org.obiba.mica.core.domain.TaxonomyEntityWrapper)

Example 3 with TaxonomyEntityWrapper

use of org.obiba.mica.core.domain.TaxonomyEntityWrapper in project mica2 by obiba.

the class Mica220Upgrade method updateTaxonomyWithRangeCriteria.

void updateTaxonomyWithRangeCriteria(String name) {
    TaxonomyEntityWrapper taxonomy = taxonomyConfigRepository.findOne(name);
    if (taxonomy == null)
        return;
    taxonomy.getTaxonomy().getVocabularies().stream().filter(v -> v.getName().endsWith("-range")).map(TaxonomyEntity::getAttributes).forEach(attributes -> {
        attributes.put("alias", attributes.get("field").replaceAll("\\.", "-") + "-range");
        attributes.put("range", "true");
    });
    taxonomyConfigRepository.save(taxonomy);
}
Also used : TaxonomyEntityWrapper(org.obiba.mica.core.domain.TaxonomyEntityWrapper)

Example 4 with TaxonomyEntityWrapper

use of org.obiba.mica.core.domain.TaxonomyEntityWrapper in project mica2 by obiba.

the class Mica220UpgradeTest method getWrapper.

private TaxonomyEntityWrapper getWrapper(String name) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    Taxonomy taxonomy = mapper.readValue(new File("src/test/resources/config/mica-" + name + ".json"), Taxonomy.class);
    TaxonomyEntityWrapper wrapper = new TaxonomyEntityWrapper();
    wrapper.setTarget(name);
    wrapper.setTaxonomy(taxonomy);
    return wrapper;
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) TaxonomyEntityWrapper(org.obiba.mica.core.domain.TaxonomyEntityWrapper) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with TaxonomyEntityWrapper

use of org.obiba.mica.core.domain.TaxonomyEntityWrapper in project mica2 by obiba.

the class Mica220Upgrade method updateFixWrongKeysInStudyTaxonomy.

private void updateFixWrongKeysInStudyTaxonomy() {
    TaxonomyEntityWrapper studyTaxonomy = taxonomyConfigRepository.findOne("study");
    if (studyTaxonomy == null)
        return;
    List<Vocabulary> vocabularies = studyTaxonomy.getTaxonomy().getVocabularies();
    vocabularies.stream().filter(vocabulary -> vocabulary.getName().equals("numberOfParticipants-sample-number") || vocabulary.getName().equals("numberOfParticipants-sample-range")).map(TaxonomyEntity::getAttributes).forEach(attributes -> {
        attributes.put("field", "model." + attributes.get("field"));
        attributes.put("alias", "model-" + attributes.get("alias"));
    });
    taxonomyConfigRepository.save(studyTaxonomy);
}
Also used : Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary) TaxonomyEntityWrapper(org.obiba.mica.core.domain.TaxonomyEntityWrapper)

Aggregations

TaxonomyEntityWrapper (org.obiba.mica.core.domain.TaxonomyEntityWrapper)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 Taxonomy (org.obiba.opal.core.domain.taxonomy.Taxonomy)1 Vocabulary (org.obiba.opal.core.domain.taxonomy.Vocabulary)1