use of org.obiba.core.translator.Translator in project mica2 by obiba.
the class ModelAwareTranslator method translateModel.
public <T extends ModelAware> void translateModel(String locale, T modelAwareObject) {
if (locale == null)
return;
Translator translator = JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(locale, false));
new ForLocale(translator).translateModel(modelAwareObject);
}
use of org.obiba.core.translator.Translator in project mica2 by obiba.
the class SpecificStudyReportGenerator method report.
public void report(String networkId, String locale, OutputStream outputStream) throws IOException {
List<String> studyIds = networkService.findById(networkId).getStudyIds();
Translator translator = JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(locale, false));
report(translator, studyIds, locale, outputStream);
}
use of org.obiba.core.translator.Translator 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.core.translator.Translator in project mica2 by obiba.
the class EntityConfigTranslator method translateSchemaForm.
/**
* Translates both schema and definition JSON strings defined in the entity configuration.
*
* @param locale
* @param entityConfig
* @param <T>
*/
public <T extends EntityConfig> void translateSchemaForm(String locale, T entityConfig) {
if (StringUtils.isEmpty(locale))
return;
Translator translator = JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(locale, false));
translator = new PrefixedValueTranslator(translator);
TranslationUtils translationUtils = new TranslationUtils();
entityConfig.setSchema(translationUtils.translate(entityConfig.getSchema(), translator));
entityConfig.setDefinition(translationUtils.translate(entityConfig.getDefinition(), translator));
}
use of org.obiba.core.translator.Translator in project mica2 by obiba.
the class SpecificStudyReportGenerator method report.
public void report(String rqlQuery, OutputStream outputStream) throws IOException {
JoinQuery joinQuery = searcher.makeJoinQuery(rqlQuery);
List<String> studyIds = joinQueryExecutor.query(QueryType.STUDY, joinQuery).getStudyResultDto().getExtension(MicaSearch.StudyResultDto.result).getSummariesList().stream().map(Mica.StudySummaryDto::getId).collect(toList());
Translator translator = JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(joinQuery.getLocale(), false));
report(translator, studyIds, joinQuery.getLocale(), outputStream);
}
Aggregations