Search in sources :

Example 1 with PrefixedValueTranslator

use of org.obiba.core.translator.PrefixedValueTranslator 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));
}
Also used : JsonTranslator(org.obiba.core.translator.JsonTranslator) Translator(org.obiba.core.translator.Translator) PrefixedValueTranslator(org.obiba.core.translator.PrefixedValueTranslator) PrefixedValueTranslator(org.obiba.core.translator.PrefixedValueTranslator) TranslationUtils(org.obiba.core.translator.TranslationUtils)

Example 2 with PrefixedValueTranslator

use of org.obiba.core.translator.PrefixedValueTranslator in project mica2 by obiba.

the class EntityConfigKeyTranslationService method translateSchemaForm.

private void translateSchemaForm(Translator translator, EntityConfig config) {
    TranslationUtils translationUtils = new TranslationUtils();
    PrefixedValueTranslator prefixedValueTranslator = new PrefixedValueTranslator(translator);
    config.setSchema(translationUtils.translate(config.getSchema(), prefixedValueTranslator));
    config.setDefinition(translationUtils.translate(config.getDefinition(), prefixedValueTranslator));
}
Also used : PrefixedValueTranslator(org.obiba.core.translator.PrefixedValueTranslator) TranslationUtils(org.obiba.core.translator.TranslationUtils)

Aggregations

PrefixedValueTranslator (org.obiba.core.translator.PrefixedValueTranslator)2 TranslationUtils (org.obiba.core.translator.TranslationUtils)2 JsonTranslator (org.obiba.core.translator.JsonTranslator)1 Translator (org.obiba.core.translator.Translator)1