use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.
the class DceIdAggregationMetaDataHelper method mapIdToMetadata.
private void mapIdToMetadata(Map<String, AggregationMetaDataProvider.LocalizedMetaData> map, BaseStudy study, Population population, DataCollectionEvent dce) {
MonikerData md = new MonikerData(study.getAcronym(), population, dce);
LocalizedString title = new LocalizedString();
study.getAcronym().entrySet().forEach(e -> title.put(e.getKey(), md.getTitle(e.getKey())));
LocalizedString description = new LocalizedString();
study.getAcronym().entrySet().forEach(e -> description.put(e.getKey(), md.getDescription(e.getKey())));
if (dce == null) {
map.put(StudyTable.getDataCollectionEventUId(study.getId(), population.getId()), new AggregationMetaDataProvider.LocalizedMetaData(title, description, "", null, null));
} else {
String start = dce.hasStart() ? dce.getStart().getYearMonth() : null;
String end = dce.hasEnd() ? dce.getEnd().getYearMonth() : null;
map.put(StudyTable.getDataCollectionEventUId(study.getId(), population.getId(), dce.getId()), new AggregationMetaDataProvider.LocalizedMetaData(title, description, dce.getClass().getSimpleName(), start, end));
}
}
use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.
the class DatasetService method getNextId.
@Nullable
protected String getNextId(@Nullable LocalizedString suggested) {
if (suggested == null)
return null;
String prefix = suggested.asUrlSafeString().toLowerCase();
if (Strings.isNullOrEmpty(prefix))
return null;
String next = prefix;
try {
findById(next);
for (int i = 1; i <= 1000; i++) {
next = prefix + "-" + i;
findById(next);
}
return null;
} catch (NoSuchDatasetException e) {
return next;
}
}
use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.
the class CustomTranslationsResource method importTranslations.
@PUT
@Path("/import")
@Consumes("application/json")
public Response importTranslations(String translations, @QueryParam("merge") @DefaultValue("false") boolean merge) throws IOException {
MicaConfig config = micaConfigService.getConfig();
JsonNode node = objectMapper.readTree(translations);
List<String> locales = config.getLocalesAsString();
if (!config.hasTranslations()) {
config.setTranslations(new LocalizedString());
}
if (merge) {
locales.forEach(l -> {
JsonNode merged = micaConfigService.mergeJson(getTranslations(l), node.get(l));
config.getTranslations().put(l, merged.toString());
});
} else {
locales.forEach(l -> config.getTranslations().put(l, node.get(l).toString()));
}
micaConfigService.save(config);
return Response.ok().build();
}
use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.
the class ProjectService method getNextId.
private String getNextId(LocalizedString suggested) {
if (suggested == null)
return null;
String prefix = suggested.asUrlSafeString().toLowerCase();
if (Strings.isNullOrEmpty(prefix))
return null;
String next = prefix;
if (!projectRepository.exists(next))
return next;
for (int i = 1; i <= 1000; i++) {
next = prefix + "-" + i;
if (!projectRepository.exists(next))
return next;
}
return null;
}
use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.
the class StudyIdGeneratorServiceTest method acronym.
private LocalizedString acronym(String englishId, String frenchId) {
LocalizedString localizedString = acronym(englishId);
localizedString.put(Locale.FRENCH, frenchId);
return localizedString;
}
Aggregations