use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessResource method getDataAccessForm.
@GET
@Path("/form")
@Timed
public Mica.DataAccessFormDto getDataAccessForm(@QueryParam("lang") String lang) {
Optional<DataAccessForm> d = dataAccessFormService.find();
if (!d.isPresent())
throw NoSuchDataAccessFormException.withDefaultMessage();
DataAccessForm dataAccessForm = d.get();
Mica.DataAccessFormDto.Builder builder = Mica.DataAccessFormDto.newBuilder(dtos.asDto(dataAccessForm)).clearProperties().clearPdfTemplates();
String langTag = !Strings.isNullOrEmpty(lang) ? Locale.forLanguageTag(lang).toLanguageTag() : LanguageTag.UNDETERMINED;
Map<String, LocalizedString> properties = dataAccessForm.getProperties().entrySet().stream().map(e -> Maps.immutableEntry(e.getKey(), new LocalizedString().forLanguageTag(langTag, e.getValue().get(langTag)))).collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
builder.addAllProperties(dtos.asDtoList(properties));
return builder.build();
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessFormService method createDefaultDataAccessForm.
private DataAccessForm createDefaultDataAccessForm() {
DataAccessForm form = new DataAccessForm();
form.setDefinition(getDefaultDataAccessFormResourceAsString("definition.json"));
form.setSchema(getDefaultDataAccessFormResourceAsString("schema.json"));
form.setCsvExportFormat(getDefaultDataAccessFormResourceAsString("export-csv-schema.json"));
form.setTitleFieldPath("projectTitle");
form.setSummaryFieldPath("summary");
return form;
}
Aggregations