Search in sources :

Example 11 with Study

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));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 12 with Study

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));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 13 with Study

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;
}
Also used : Study(org.obiba.mica.study.domain.Study)

Example 14 with 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();
}
Also used : Study(org.obiba.mica.study.domain.Study) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 15 with Study

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);
    }
}
Also used : Study(org.obiba.mica.study.domain.Study) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) List(java.util.List) FileInputStream(java.io.FileInputStream)

Aggregations

Study (org.obiba.mica.study.domain.Study)33 Test (org.junit.Test)16 StudyState (org.obiba.mica.study.domain.StudyState)8 BaseStudy (org.obiba.mica.study.domain.BaseStudy)6 List (java.util.List)5 Population (org.obiba.mica.study.domain.Population)5 Timed (com.codahale.metrics.annotation.Timed)4 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 NotNull (javax.validation.constraints.NotNull)4 Component (org.springframework.stereotype.Component)4 Strings (com.google.common.base.Strings)3 Maps (com.google.common.collect.Maps)3 Map (java.util.Map)3 Collectors.toList (java.util.stream.Collectors.toList)3 NoSuchEntityException (org.obiba.mica.NoSuchEntityException)3 Membership (org.obiba.mica.core.domain.Membership)3 DataCollectionEvent (org.obiba.mica.study.domain.DataCollectionEvent)3 HarmonizationStudy (org.obiba.mica.study.domain.HarmonizationStudy)3