use of org.obiba.mica.micaConfig.domain.StudyConfig in project mica2 by obiba.
the class EntityConfigKeyTranslationService method getCompleteConfigTranslationMap.
public RegexHashMap getCompleteConfigTranslationMap(String serviceTypename, String locale) {
RegexHashMap translationMap = new RegexHashMap();
Translator translator = JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(locale, false));
beanFieldToTranslationKeyMap.forEach((key, translationKey) -> translationMap.put(key, translator.translate(translationKey)));
switch(serviceTypename) {
case "individual-study":
Optional<StudyConfig> optionalIndividualStudySchemaForm = individualStudyConfigService.findComplete();
Optional<PopulationConfig> optionalPopulationSchemaForm = populationConfigService.findComplete();
Optional<DataCollectionEventConfig> optionalDataCollectionEventSchemaForm = dataCollectionEventConfigService.findComplete();
if (optionalIndividualStudySchemaForm.isPresent()) {
StudyConfig individualStudySchemaForm = optionalIndividualStudySchemaForm.get();
translateSchemaForm(translator, individualStudySchemaForm);
translationMap.putAll(getTranslationMap(individualStudySchemaForm, ""));
}
if (optionalPopulationSchemaForm.isPresent()) {
PopulationConfig populationSchemaForm = optionalPopulationSchemaForm.get();
translateSchemaForm(translator, populationSchemaForm);
translationMap.putAll(getTranslationMap(populationSchemaForm, "^populations\\[\\d+\\]\\."));
}
if (optionalDataCollectionEventSchemaForm.isPresent()) {
DataCollectionEventConfig dataCollectionEventSchemaForm = optionalDataCollectionEventSchemaForm.get();
translateSchemaForm(translator, dataCollectionEventSchemaForm);
translationMap.putAll(getTranslationMap(dataCollectionEventSchemaForm, "^populations\\[\\d+\\]\\.dataCollectionEvents\\[\\d+\\]\\."));
}
break;
case "harmonization-study":
Optional<HarmonizationStudyConfig> optionalHarmonizationStudySchemaForm = harmonizationStudyConfigService.findComplete();
Optional<HarmonizationPopulationConfig> optionalHarmonizationPopulationSchemaForm = harmonizationPopulationConfigService.findComplete();
if (optionalHarmonizationStudySchemaForm.isPresent()) {
HarmonizationStudyConfig harmonizationStudySchemaForm = optionalHarmonizationStudySchemaForm.get();
translateSchemaForm(translator, harmonizationStudySchemaForm);
translationMap.putAll(getTranslationMap(harmonizationStudySchemaForm, ""));
}
if (optionalHarmonizationPopulationSchemaForm.isPresent()) {
HarmonizationPopulationConfig harmonizationPopulationSchemaForm = optionalHarmonizationPopulationSchemaForm.get();
translateSchemaForm(translator, harmonizationPopulationSchemaForm);
translationMap.putAll(getTranslationMap(harmonizationPopulationSchemaForm, "^populations\\[\\d+\\]\\."));
}
break;
case "network":
Optional<NetworkConfig> optionalNetworkSchemaForm = networkConfigService.findComplete();
if (optionalNetworkSchemaForm.isPresent()) {
NetworkConfig networkSchemaForm = optionalNetworkSchemaForm.get();
translateSchemaForm(translator, networkSchemaForm);
translationMap.putAll(getTranslationMap(networkSchemaForm, ""));
}
break;
case "collected-dataset":
Optional<StudyDatasetConfig> optionalStudyDatasetSchemaForm = studyDatasetConfigService.findComplete();
if (optionalStudyDatasetSchemaForm.isPresent()) {
StudyDatasetConfig studyDatasetSchemaForm = optionalStudyDatasetSchemaForm.get();
translateSchemaForm(translator, studyDatasetSchemaForm);
translationMap.putAll(getTranslationMap(studyDatasetSchemaForm, ""));
}
break;
case "harmonized-dataset":
Optional<HarmonizationDatasetConfig> optionalHarmonizationDatasetSchemaForm = harmonizationDatasetConfigService.findComplete();
if (optionalHarmonizationDatasetSchemaForm.isPresent()) {
HarmonizationDatasetConfig harmonizationDatasetSchemaForm = optionalHarmonizationDatasetSchemaForm.get();
translateSchemaForm(translator, harmonizationDatasetSchemaForm);
translationMap.putAll(getTranslationMap(harmonizationDatasetSchemaForm, ""));
}
break;
case "project":
Optional<ProjectConfig> optionalProjectSchemaForm = projectConfigService.findComplete();
if (optionalProjectSchemaForm.isPresent()) {
ProjectConfig projectSchemaForm = optionalProjectSchemaForm.get();
translateSchemaForm(translator, projectSchemaForm);
translationMap.putAll(getTranslationMap(projectSchemaForm, ""));
}
break;
default:
break;
}
return translationMap;
}
use of org.obiba.mica.micaConfig.domain.StudyConfig in project mica2 by obiba.
the class Mica220Upgrade method updateBioSamplesAttributes.
private void updateBioSamplesAttributes() throws IOException {
List<StudyConfig> studyConfigs = studyConfigRepository.findAll();
if (studyConfigs.size() != 1)
return;
StudyConfig studyConfig = studyConfigs.get(0);
JsonNode schemaNode = new ObjectMapper().readTree(studyConfig.getSchema());
if (!propertyExistsInSchema(schemaNode))
return;
JsonNode definitionNode = new ObjectMapper().readTree(studyConfig.getDefinition());
if (!replacePropertyInDefinition(definitionNode))
return;
replacePropertyInSchema(schemaNode);
studyConfig.setSchema(new ObjectMapper().writer().writeValueAsString(schemaNode));
studyConfig.setDefinition(new ObjectMapper().writer().writeValueAsString(definitionNode));
studyConfigRepository.save(studyConfig);
updateAttributeNameInStudies();
}
Aggregations