use of org.obiba.mica.study.date.PersistableYearMonth in project mica2 by obiba.
the class StudySummaryDtos method asDto.
@NotNull
Mica.DataCollectionEventSummaryDto asDto(@NotNull DataCollectionEvent dce) {
Mica.DataCollectionEventSummaryDto.Builder builder = Mica.DataCollectionEventSummaryDto.newBuilder().setId(dce.getId()).addAllName(localizedStringDtos.asDto(dce.getName()));
if (dce.getDescription() != null)
builder.addAllDescription(localizedStringDtos.asDto(dce.getDescription()));
if (dce.hasModel())
builder.setContent(JSONUtils.toJSON(dce.getModel()));
if (dce.hasStart()) {
PersistableYearMonth start = dce.getStart();
builder.setStart(start.getDay() != null ? start.getDay().format(DateTimeFormatter.ISO_DATE) : dce.getStart().getYearMonth());
}
if (dce.hasEnd()) {
PersistableYearMonth end = dce.getEnd();
builder.setEnd(end.getDay() != null ? end.getDay().format(DateTimeFormatter.ISO_DATE) : end.getYearMonth());
}
return builder.build();
}
use of org.obiba.mica.study.date.PersistableYearMonth in project mica2 by obiba.
the class PersistableDateTest method test_year_month_day_creation_format.
@Test
public void test_year_month_day_creation_format() {
PersistableYearMonth ym = PersistableYearMonth.of(2010, 2, LocalDate.parse("2010-02-22", DateTimeFormatter.ISO_DATE));
assertThat(ym.getYearMonth()).isEqualTo("2010-02");
assertThat(ym.getDay().getDayOfMonth()).isEqualTo(22);
}
use of org.obiba.mica.study.date.PersistableYearMonth in project mica2 by obiba.
the class StudyPopulationDCECsvReportGenerator method writeEachLine.
@Override
protected void writeEachLine(CSVWriter writer) {
studies.forEach(study -> study.getPopulationsSorted().forEach(pop -> pop.getDataCollectionEventsSorted().forEach(dce -> {
List<String> line = Lists.newArrayList();
line.add(study.getId());
line.add(pop.getId());
line.add(dce.getId());
line.add(translate(dce.getName()));
line.add(translate(dce.getDescription()));
if (dce.hasStart()) {
PersistableYearMonth start = dce.getStart();
line.add(start.getDay() != null ? start.getDay().format(DateTimeFormatter.ISO_DATE) : dce.getStart().getYearMonth());
} else {
line.add("");
}
if (dce.hasEnd()) {
PersistableYearMonth end = dce.getEnd();
line.add(end.getDay() != null ? end.getDay().format(DateTimeFormatter.ISO_DATE) : dce.getEnd().getYearMonth());
} else {
line.add("");
}
Map<String, Object> model = getModels().get(getIdKey(study, pop, dce));
for (String key : getModelKeys()) {
Object value = model.get(key);
line.add(value == null ? "" : value.toString());
}
writer.writeNext(line.toArray(new String[line.size()]));
})));
}
Aggregations