use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class PublishedCollectedDatasetVariableResource method getVariableAggregations.
@GET
@Path("/aggregation")
@Timed
public Mica.DatasetVariableAggregationDto getVariableAggregations() {
StudyDataset dataset = getDataset(StudyDataset.class, datasetId);
StudyTable studyTable = dataset.getSafeStudyTable();
Mica.DatasetVariableAggregationDto.Builder aggDto = //
Mica.DatasetVariableAggregationDto.newBuilder().setStudyTable(dtos.asDto(studyTable));
try {
return dtos.asDto(studyTable, datasetService.getVariableSummary(dataset, variableName).getWrappedDto()).build();
} catch (Exception e) {
log.warn("Unable to retrieve statistics: " + e.getMessage(), e);
return dtos.asDto(studyTable, null).build();
}
}
use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class CsvHarmonizationVariablesWriter method writeBody.
private void writeBody(CSVWriter writer, HarmonizationDataset dataset, DatasetVariablesHarmonizationsDto harmonizationVariables, String locale) {
harmonizationVariables.getVariableHarmonizationsList().forEach(variableHarmonization -> {
List<String> row = Lists.newArrayList();
dataset.getBaseStudyTables().forEach(table -> {
final boolean[] found = { false };
variableHarmonization.getDatasetVariableSummariesList().forEach(summary -> {
String id = table instanceof StudyTable ? ((StudyTable) table).getStudyId() : ((HarmonizationStudyTable) table).getStudyId();
Mica.DatasetVariableResolverDto resolver = summary.getResolver();
if ((resolver.getStudyId().equals(id) && resolver.getProject().equals(table.getProject()) && resolver.getTable().equals(table.getTable()))) {
row.add(getStatus(summary, locale));
found[0] = true;
return;
}
});
if (row.size() == 0 || !found[0]) {
row.add(EMPTY_STATUS);
}
});
row.add(0, variableHarmonization.getResolver().getName());
writer.writeNext(row.toArray(new String[row.size()]));
});
}
use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class PublishedHarmonizedDatasetResource method getVariable.
@Path("/study/{study}/population/{population}/data-collection-event/{dce}/variable/{variable}")
public PublishedHarmonizedDatasetVariableResource getVariable(@PathParam("id") String id, @PathParam("study") String studyId, @PathParam("population") String populationId, @PathParam("dce") String dceId, @PathParam("variable") String variable) {
checkAccess(id);
PublishedHarmonizedDatasetVariableResource resource = applicationContext.getBean(PublishedHarmonizedDatasetVariableResource.class);
resource.setDatasetId(id);
resource.setVariableName(variable);
resource.setStudyId(studyId);
HarmonizationDataset dataset = getDataset(HarmonizationDataset.class, id);
dataset.getStudyTables().stream().filter(t -> t.appliesTo(studyId, populationId, dceId)).forEach(t -> {
resource.setTableType(t instanceof StudyTable ? DatasetVariable.OPAL_STUDY_TABLE_PREFIX : DatasetVariable.OPAL_HARMONIZATION_TABLE_PREFIX);
});
return resource;
}
use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class HarmonizationDatasetUpgrade method execute.
@Override
public void execute(Version version) {
log.info("Executing harmonization datasets network tables upgrade");
List<HarmonizationDataset> datasets = harmonizationDatasetRepository.findAll();
datasets.forEach(dataset -> {
int i = 0;
for (StudyTable st : dataset.getStudyTables()) {
st.setWeight(i++);
}
});
harmonizationDatasetRepository.save(datasets);
eventBus.post(new IndexDatasetsEvent());
}
use of org.obiba.mica.core.domain.StudyTable in project mica2 by obiba.
the class DatasetDtos method fromDto.
private StudyTable fromDto(Mica.DatasetDto.StudyTableDto dto) {
StudyTable table = new StudyTable();
table.setStudyId(dto.getStudyId());
table.setPopulationId(dto.getPopulationId());
table.setDataCollectionEventId(dto.getDataCollectionEventId());
table.setProject(dto.getProject());
table.setTable(dto.getTable());
table.setWeight(dto.getWeight());
table.setName(localizedStringDtos.fromDto(dto.getNameList()));
table.setDescription(localizedStringDtos.fromDto(dto.getDescriptionList()));
return table;
}
Aggregations