Search in sources :

Example 1 with HarmonizationPopulationConfig

use of org.obiba.mica.micaConfig.domain.HarmonizationPopulationConfig 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;
}
Also used : RegexHashMap(org.obiba.mica.core.support.RegexHashMap) PopulationConfig(org.obiba.mica.micaConfig.domain.PopulationConfig) HarmonizationPopulationConfig(org.obiba.mica.micaConfig.domain.HarmonizationPopulationConfig) StudyDatasetConfig(org.obiba.mica.micaConfig.domain.StudyDatasetConfig) NetworkConfig(org.obiba.mica.micaConfig.domain.NetworkConfig) DataCollectionEventConfig(org.obiba.mica.micaConfig.domain.DataCollectionEventConfig) HarmonizationDatasetConfig(org.obiba.mica.micaConfig.domain.HarmonizationDatasetConfig) ProjectConfig(org.obiba.mica.micaConfig.domain.ProjectConfig) HarmonizationPopulationConfig(org.obiba.mica.micaConfig.domain.HarmonizationPopulationConfig) StudyConfig(org.obiba.mica.micaConfig.domain.StudyConfig) HarmonizationStudyConfig(org.obiba.mica.micaConfig.domain.HarmonizationStudyConfig) JsonTranslator(org.obiba.core.translator.JsonTranslator) PrefixedValueTranslator(org.obiba.core.translator.PrefixedValueTranslator) Translator(org.obiba.core.translator.Translator) HarmonizationStudyConfig(org.obiba.mica.micaConfig.domain.HarmonizationStudyConfig)

Aggregations

JsonTranslator (org.obiba.core.translator.JsonTranslator)1 PrefixedValueTranslator (org.obiba.core.translator.PrefixedValueTranslator)1 Translator (org.obiba.core.translator.Translator)1 RegexHashMap (org.obiba.mica.core.support.RegexHashMap)1 DataCollectionEventConfig (org.obiba.mica.micaConfig.domain.DataCollectionEventConfig)1 HarmonizationDatasetConfig (org.obiba.mica.micaConfig.domain.HarmonizationDatasetConfig)1 HarmonizationPopulationConfig (org.obiba.mica.micaConfig.domain.HarmonizationPopulationConfig)1 HarmonizationStudyConfig (org.obiba.mica.micaConfig.domain.HarmonizationStudyConfig)1 NetworkConfig (org.obiba.mica.micaConfig.domain.NetworkConfig)1 PopulationConfig (org.obiba.mica.micaConfig.domain.PopulationConfig)1 ProjectConfig (org.obiba.mica.micaConfig.domain.ProjectConfig)1 StudyConfig (org.obiba.mica.micaConfig.domain.StudyConfig)1 StudyDatasetConfig (org.obiba.mica.micaConfig.domain.StudyDatasetConfig)1