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