use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DatasetDtos method asDtoBuilder.
@NotNull
Mica.DatasetDto.Builder asDtoBuilder(@NotNull HarmonizationDataset dataset, boolean asDraft, boolean studySummary) {
Mica.DatasetDto.Builder builder = asBuilder(dataset);
builder.setVariableType(DatasetVariable.Type.Dataschema.name());
Mica.HarmonizedDatasetDto.Builder hbuilder = Mica.HarmonizedDatasetDto.newBuilder();
if (dataset.hasHarmonizationTable() && !Strings.isNullOrEmpty(dataset.getHarmonizationTable().getStudyId()) && isStudyTablePermitted(asDraft, "harmonization", dataset.getHarmonizationTable().getStudyId())) {
hbuilder.setHarmonizationTable(createHarmonizationLinkDtoFromHarmonizationTable(dataset.getHarmonizationTable(), asDraft));
}
if (!dataset.getStudyTables().isEmpty()) {
dataset.getStudyTables().stream().filter(studyTable -> isStudyTablePermitted(asDraft, "individual", studyTable.getStudyId())).forEach(studyTable -> hbuilder.addStudyTables(asDto(studyTable, studySummary)));
}
if (!dataset.getHarmonizationTables().isEmpty()) {
dataset.getHarmonizationTables().stream().filter(studyTable -> isStudyTablePermitted(asDraft, "harmonization", studyTable.getStudyId())).forEach(harmonizationTable -> hbuilder.addHarmonizationTables(asDto(harmonizationTable, studySummary)));
}
builder.setExtension(Mica.HarmonizedDatasetDto.type, hbuilder.build());
Mica.PermissionsDto permissionsDto = permissionsDtos.asDto(dataset);
if (asDraft) {
HarmonizationDatasetState state = harmonizationDatasetStateRepository.findOne(dataset.getId());
if (state != null) {
builder.setPublished(state.isPublished());
builder.setExtension(Mica.EntityStateDto.datasetState, entityStateDtos.asDto(state).setPermissions(permissionsDto).build());
}
}
builder.setPermissions(permissionsDto);
return builder;
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class HarmonizedDatasetServiceTest method buildHarmonizationDataset.
private HarmonizationDataset buildHarmonizationDataset(String id, StudyTable... studyTables) {
HarmonizationDataset ds = new HarmonizationDataset();
for (StudyTable s : studyTables) {
ds.addStudyTable(s);
}
ds.setId(id);
ds.setName(new LocalizedString(Locale.CANADA, "dataset" + id));
return ds;
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class HarmonizedDatasetHelperTest method createDataset.
private HarmonizationDataset createDataset(List<String> studyIds, List<String> harmoStudyIds) {
HarmonizationDataset dataset = new HarmonizationDataset();
studyIds.forEach(id -> dataset.addStudyTable(createStudyTable(id)));
harmoStudyIds.forEach(id -> dataset.addHarmonizationTable(createHarmonizationStudyTable(id)));
return dataset;
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DatasetDtosTest method test_harmonized_dataset_dto.
@Test
public void test_harmonized_dataset_dto() throws Exception {
when(harmonizationDatasetStateRepository.findOne(anyString())).thenReturn(new HarmonizationDatasetState());
HarmonizationDataset harmonizationDataset = createHarmonizedDataset();
Mica.DatasetDto dto = datasetDtos.asDto(harmonizationDataset);
assertThat(dto.getId(), is("123"));
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DatasetDtosTest method createHarmonizedDataset.
private HarmonizationDataset createHarmonizedDataset() {
HarmonizationDataset harmonizationDataset = new HarmonizationDataset();
harmonizationDataset.setId("123");
HarmonizationStudyTable harmonizationLink = new HarmonizationStudyTable();
harmonizationLink.setProject("project123");
harmonizationLink.setTable("table123");
harmonizationLink.setStudyId("study123");
harmonizationLink.setPopulationId("population123");
harmonizationDataset.setHarmonizationTable(harmonizationLink);
return harmonizationDataset;
}
Aggregations