use of org.obiba.mica.study.domain.DataCollectionEvent 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.DataCollectionEvent 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