use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class TestDataCollectionEventSort method test_all_date_fields.
@Test
public void test_all_date_fields() {
Population population = createPopulation("Test Population", createEvent("A", 2010, 1, 2020, 12), createEvent("A", 1997, 1, 2000, 12), createEvent("A", 1997, 8, 2000, 12));
population.setName(en("Test Population"));
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 StudySummaryDtosTest method populations.
private List<Population> populations(List<String> countriesIsos) {
HashMap<String, Object> selectionCriteria = new HashMap<>();
selectionCriteria.put("countriesIso", countriesIsos);
HashMap<String, Object> model = new HashMap<>();
model.put("selectionCriteria", selectionCriteria);
List<Population> populations = new ArrayList<>();
Population population = new Population();
population.setModel(model);
populations.add(population);
return populations;
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class Mica310Upgrade method transformExistingStudies.
private void transformExistingStudies(Study study) {
try {
for (Population population : study.getPopulations()) {
List<String> dataSources = (List<String>) ((Map<String, Object>) population.getModel().get("recruitment")).get("dataSources");
dataSources.remove("existing_studies");
dataSources.add("exist_studies");
}
} catch (RuntimeException ignore) {
}
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class CollectedDatasetService method processVariablesForStudyDataset.
public List<DatasetVariable> processVariablesForStudyDataset(StudyDataset dataset, Iterable<DatasetVariable> variables) {
if (!dataset.hasStudyTable()) {
return Lists.newArrayList(variables);
}
StudyTable studyTable = dataset.getStudyTable();
BaseStudy study = studyService.findStudy(dataset.getStudyTable().getStudyId());
Population population = study.findPopulation(studyTable.getPopulationId());
if (population == null) {
return Lists.newArrayList(variables);
}
int populationWeight = population.getWeight();
DataCollectionEvent dataCollectionEvent = population.findDataCollectionEvent(studyTable.getDataCollectionEventId());
if (dataCollectionEvent == null) {
return Lists.newArrayList(variables);
}
int dataCollectionEventWeight = dataCollectionEvent.getWeight();
return StreamSupport.stream(variables.spliterator(), false).map(datasetVariable -> {
datasetVariable.setPopulationWeight(populationWeight);
datasetVariable.setDataCollectionEventWeight(dataCollectionEventWeight);
return datasetVariable;
}).collect(toList());
}
use of org.obiba.mica.study.domain.Population in project mica2 by obiba.
the class CollectedDatasetService method prepareForIndex.
private void prepareForIndex(StudyDataset dataset) {
if (dataset.hasStudyTable()) {
StudyTable studyTable = dataset.getStudyTable();
BaseStudy study = publishedStudyService.findById(dataset.getStudyTable().getStudyId());
if (study != null) {
Population population = study.findPopulation(studyTable.getPopulationId());
if (population != null) {
studyTable.setPopulationWeight(population.getWeight());
DataCollectionEvent dataCollectionEvent = population.findDataCollectionEvent(studyTable.getDataCollectionEventId());
if (dataCollectionEvent != null) {
studyTable.setDataCollectionEventWeight(dataCollectionEvent.getWeight());
}
}
}
}
}
Aggregations