use of org.obiba.mica.dataset.domain.HarmonizationDatasetState in project mica2 by obiba.
the class HarmonizedDatasetService method saveInternal.
//
// Private methods
//
@SuppressWarnings("OverlyLongMethod")
private void saveInternal(HarmonizationDataset dataset, String comment) {
HarmonizationDataset saved = prepareSave(dataset);
HarmonizationDatasetState harmonizationDatasetState = findEntityState(dataset, HarmonizationDatasetState::new);
if (!dataset.isNew())
ensureGitRepository(harmonizationDatasetState);
harmonizationDatasetState.incrementRevisionsAhead();
harmonizationDatasetStateRepository.save(harmonizationDatasetState);
saved.setLastModifiedDate(DateTime.now());
harmonizationDatasetRepository.save(saved);
gitService.save(saved, comment);
helper.getPublishedVariables(saved);
}
use of org.obiba.mica.dataset.domain.HarmonizationDatasetState 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.HarmonizationDatasetState 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"));
}
Aggregations