use of org.obiba.mica.dataset.domain.StudyDatasetState in project mica2 by obiba.
the class CollectedDatasetServiceTest method buildStudyDatasetState.
private StudyDatasetState buildStudyDatasetState(StudyDataset dataset) {
StudyDatasetState state = new StudyDatasetState();
state.setId(dataset.getId());
return state;
}
use of org.obiba.mica.dataset.domain.StudyDatasetState in project mica2 by obiba.
the class DatasetDtos method asDtoBuilder.
@NotNull
Mica.DatasetDto.Builder asDtoBuilder(@NotNull StudyDataset dataset, boolean asDraft, boolean studySummary) {
Mica.DatasetDto.Builder builder = asBuilder(dataset);
builder.setVariableType(DatasetVariable.Type.Collected.name());
if (dataset.hasStudyTable() && !Strings.isNullOrEmpty(dataset.getStudyTable().getStudyId()) && isStudyTablePermitted(asDraft, "individual", dataset.getStudyTable().getStudyId())) {
Mica.CollectedDatasetDto.Builder sbuilder = Mica.CollectedDatasetDto.newBuilder().setStudyTable(asDto(dataset.getStudyTable(), studySummary));
builder.setExtension(Mica.CollectedDatasetDto.type, sbuilder.build());
}
Mica.PermissionsDto permissionsDto = permissionsDtos.asDto(dataset);
if (asDraft) {
StudyDatasetState state = studyDatasetStateRepository.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.StudyDatasetState in project mica2 by obiba.
the class CollectedDatasetService method saveInternal.
private void saveInternal(StudyDataset dataset, String comment) {
StudyDataset saved = prepareSave(dataset);
StudyDatasetState studyDatasetState = findEntityState(dataset, StudyDatasetState::new);
if (!dataset.isNew())
ensureGitRepository(studyDatasetState);
studyDatasetState.incrementRevisionsAhead();
studyDatasetStateRepository.save(studyDatasetState);
saved.setLastModifiedDate(DateTime.now());
studyDatasetRepository.save(saved);
gitService.save(saved, comment);
eventBus.post(new DatasetUpdatedEvent(saved));
}
Aggregations