use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class VariableController method addStudyTableParameters.
private void addStudyTableParameters(Map<String, Object> params, DatasetVariable variable) {
try {
String studyId = variable.getStudyId();
boolean published = studyService.isPublished(studyId);
BaseStudy study = getStudy(studyId, published);
params.put("studyPublished", published);
params.put("study", study);
Population population = study.findPopulation(variable.getPopulationId().replace(variable.getStudyId() + ":", ""));
params.put("population", population);
DataCollectionEvent dce = population.findDataCollectionEvent(variable.getDceId().replace(variable.getPopulationId() + ":", ""));
params.put("dce", dce);
if (DatasetVariable.Type.Harmonized.equals(variable.getVariableType())) {
HarmonizationDataset dataset = getHarmonizationDataset(variable.getDatasetId());
if (DatasetVariable.OpalTableType.Study.equals(variable.getOpalTableType())) {
Optional<StudyTable> studyTable = dataset.getStudyTables().stream().filter(st -> variable.getStudyId().equals(st.getStudyId()) && variable.getProject().equals(st.getProject()) && variable.getTable().equals(st.getTable())).findFirst();
if (studyTable.isPresent())
params.put("opalTable", studyTable.get());
} else {
Optional<HarmonizationStudyTable> harmoStudyTable = dataset.getHarmonizationTables().stream().filter(st -> variable.getStudyId().equals(st.getStudyId()) && variable.getProject().equals(st.getProject()) && variable.getTable().equals(st.getTable())).findFirst();
if (harmoStudyTable.isPresent())
params.put("opalTable", harmoStudyTable.get());
}
}
} catch (Exception e) {
// ignore
log.warn("Failed at retrieving collected dataset's study/population/dce", e);
}
}
Aggregations