Search in sources :

Example 6 with Translator

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

the class SetsAggregationMetaDataHelper method getSetIds.

public Map<String, LocalizedMetaData> getSetIds() {
    List<String> locales = micaConfigService.getLocales();
    Map<String, Translator> translators = locales.stream().collect(Collectors.toMap(Function.identity(), locale -> JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(locale, false))));
    return getDocumentSetService().getAll().stream().collect(Collectors.toMap(DocumentSet::getId, set -> {
        LocalizedString title = new LocalizedString();
        locales.forEach(locale -> {
            String setName = Strings.isNullOrEmpty(set.getName()) ? translators.get(locale).translate("sets.cart.title") : getDocumentSetName(set);
            title.forLanguageTag(locale, setName);
        });
        return new LocalizedMetaData(title, new LocalizedString(), set.getType());
    }));
}
Also used : Strings(com.google.common.base.Strings) JsonTranslator(org.obiba.core.translator.JsonTranslator) Translator(org.obiba.core.translator.Translator) DocumentSet(org.obiba.mica.core.domain.DocumentSet) LocalizedString(org.obiba.mica.core.domain.LocalizedString) DocumentSetService(org.obiba.mica.core.service.DocumentSetService) List(java.util.List) LocalizedMetaData(org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider.LocalizedMetaData) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) Map(java.util.Map) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) JsonTranslator(org.obiba.core.translator.JsonTranslator) Translator(org.obiba.core.translator.Translator) LocalizedMetaData(org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider.LocalizedMetaData) LocalizedString(org.obiba.mica.core.domain.LocalizedString) LocalizedString(org.obiba.mica.core.domain.LocalizedString)

Aggregations

JsonTranslator (org.obiba.core.translator.JsonTranslator)6 Translator (org.obiba.core.translator.Translator)6 LocalizedString (org.obiba.mica.core.domain.LocalizedString)3 PrefixedValueTranslator (org.obiba.core.translator.PrefixedValueTranslator)2 Strings (com.google.common.base.Strings)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 TranslationUtils (org.obiba.core.translator.TranslationUtils)1 DocumentSet (org.obiba.mica.core.domain.DocumentSet)1 DocumentSetService (org.obiba.mica.core.service.DocumentSetService)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