use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class Mica310Upgrade method setDefaultWeightForStudyPopulations.
private void setDefaultWeightForStudyPopulations(BaseStudy study) {
int i = 0;
for (Population population : study.getPopulations()) {
population.setWeight(i++);
setDefaultWeightForPopulationDataCollectionEvents(population);
}
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class SpecificStudyReportGenerator method writeEachLine.
@Override
protected void writeEachLine(CSVWriter writer) {
for (String studyId : studyIds) {
BaseStudy publishedStudy = publishedStudyService.findById(studyId);
if (publishedStudy != null) {
List<String> publishedStudyDetails = generatePublishedStudyDetails(publishedStudy);
Iterator<Population> populationIterator = publishedStudy.getPopulations().iterator();
if (!populationIterator.hasNext()) {
writer.writeNext(publishedStudyDetails.toArray(new String[publishedStudyDetails.size()]));
}
while (populationIterator.hasNext()) {
List<String> buildingCompleteLine = new ArrayList<>(publishedStudyDetails);
Population next = populationIterator.next();
buildingCompleteLine.addAll(generatePopulationDetails(next));
writer.writeNext(buildingCompleteLine.toArray(new String[buildingCompleteLine.size()]));
}
} else {
BaseStudy draftStudy = studyService.findStudy(studyId);
if (draftStudy != null) {
List<String> lineOfDratStudy = generateDraftStudyDetails(draftStudy);
writer.writeNext(lineOfDratStudy.toArray(new String[lineOfDratStudy.size()]));
}
}
}
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class TestDataCollectionEventSort method test_partial_date_fields.
@Test
public void test_partial_date_fields() {
Population population = createPopulation("Test Population", createEvent("A", 2010, null, 2020, null), createEvent("A", 1997, 1, 2000, null));
DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
assertThat(event.getStart()).isEqualTo(of(1997, 1));
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class TestDataCollectionEventSort method test_study_population_sort_with_duplicate_event_dates.
@Test
public void test_study_population_sort_with_duplicate_event_dates() {
Study study = new Study();
study.setId("01234567889");
study.addPopulation(createPopulation("Population001", createEvent("A", 2010, 1, 2020, 12), createEvent("B", 2014, 1, 2035, 12), createEvent("C", 2010, 1, 2020, 12)));
Population population = Iterables.get(study.getPopulations(), 0);
SortedSet<DataCollectionEvent> events = population.getDataCollectionEvents();
assertThat(events.size()).isEqualTo(3);
assertThat(Iterables.get(events, 0).getStart()).isEqualTo(of(2010, 1));
assertThat(Iterables.get(events, 1).getStart()).isEqualTo(of(2010, 1));
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class TestDataCollectionEventSort method test_study_population_sort.
@Test
public void test_study_population_sort() {
Study study = new Study();
study.setId("01234567889");
study.addPopulation(createPopulation("Population001", createEvent("A", 2010, 1, 2020, 12), createEvent("A", 2014, 1, 2035, 12)));
study.addPopulation(createPopulation("Population001", createEvent("A", 1997, 8, 1998, 12), createEvent("A", 1996, 1, 2000, 12)));
Population population = Iterables.get(study.getPopulations(), 0);
DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
assertThat(event.getStart()).isEqualTo(of(1996, 1));
}
Aggregations