use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class HarmonizedDatasetHelperTest method createStudyTable.
private StudyTable createStudyTable(String studyId) {
StudyTable table = new StudyTable();
initTable(studyId, table);
table.setDataCollectionEventId(RandomStringUtils.random(10, true, true));
return table;
}
use of org.obiba.mica.core.domain.StudyTable 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.core.domain.StudyTable 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());
}
}
}
}
}
use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class PublishedCollectedDatasetVariableResource method getContingencyDto.
private Mica.DatasetVariableContingencyDto getContingencyDto(DatasetVariable var, DatasetVariable crossVar) {
StudyDataset dataset = getDataset(StudyDataset.class, datasetId);
StudyTable studyTable = dataset.getSafeStudyTable();
try {
return dtos.asContingencyDto(studyTable, var, crossVar, datasetService.getContingencyTable(dataset, var, crossVar)).build();
} catch (Exception e) {
log.warn("Unable to retrieve contingency table: " + e.getMessage(), e);
return dtos.asContingencyDto(studyTable, var, crossVar, null).build();
}
}
Aggregations