use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class PublishedStudyResource method getStudyDto.
@GET
@Timed
public Mica.StudyDto getStudyDto(@PathParam("id") String id, @QueryParam("locale") String locale) {
checkAccess(id);
BaseStudy study = getStudy(id, locale);
return study instanceof Study ? dtos.asDto((Study) study) : dtos.asDto((HarmonizationStudy) study);
}
use of org.obiba.mica.study.domain.Study in project mica2 by obiba.
the class Mica2Upgrade method migrateStudies.
private void migrateStudies() {
List<Study> studiesWithoutModel = studyRepository.findWithoutModel();
if (!studiesWithoutModel.isEmpty()) {
logger.info("Migrating studies 1.x to 2.x: START");
for (Study studyWithoutModel : studiesWithoutModel) {
studyWithoutModel.getModel();
studyRepository.save(studyWithoutModel);
}
logger.info("Migrating studies: END");
}
}
use of org.obiba.mica.study.domain.Study 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());
}
Aggregations