use of org.obiba.mica.study.domain.Study 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));
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class TestDataCollectionEventSort method test_study_population_sort_with_duplicate_events.
@Test
public void test_study_population_sort_with_duplicate_events() {
Study study = new Study();
study.setId("01234567889");
study.addPopulation(createPopulation("Population001", createEvent("A", "A", 2010, 1, 2020, 12), createEvent("A", "A", 2014, 1, 2035, 12), createEvent("A", "A", 2010, 1, 2020, 12)));
Population population = Iterables.get(study.getPopulations(), 0);
SortedSet<DataCollectionEvent> events = population.getDataCollectionEvents();
assertThat(events.size()).isEqualTo(2);
assertThat(Iterables.get(events, 0).getStart()).isEqualTo(of(2010, 1));
assertThat(Iterables.get(events, 1).getStart()).isEqualTo(of(2014, 1));
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class StudyDtosTest method createStudy.
private Study createStudy() {
Study study = new Study();
study.setId("study_1");
study.setLogo(createAttachment());
return study;
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class DraftIndividualStudyResource method update.
@PUT
@Timed
public Response update(@SuppressWarnings("TypeMayBeWeakened") Mica.StudyDto studyDto, @Nullable @QueryParam("comment") String comment, @QueryParam("weightChanged") boolean weightChanged) {
checkPermission("/draft/individual-study", "EDIT");
// ensure study exists
individualStudyService.findDraft(id);
Study study = (Study) dtos.fromDto(studyDto);
HashMap<Object, Object> response = Maps.newHashMap();
response.put("study", study);
response.put("potentialConflicts", individualStudyService.getPotentialConflicts(study, false));
individualStudyService.save(study, comment, weightChanged);
return Response.ok(response, MediaType.APPLICATION_JSON_TYPE).build();
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class StudySeedService method importStudies.
/**
* Import Studies from a jackson file.
*
* @param json
* @throws java.io.IOException
*/
private void importStudies(File json) throws IOException {
log.info("Seeding studies with file: {}", json.getAbsolutePath());
InputStream inputStream = new FileInputStream(json);
List<Study> studies = objectMapper.readValue(inputStream, new TypeReference<List<Study>>() {
});
for (Study study : studies) {
individualStudyService.save(study);
individualStudyService.publish(study.getId(), true);
}
}
Aggregations