Search in sources :

Example 1 with StudyDatasetState

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;
}
Also used : StudyDatasetState(org.obiba.mica.dataset.domain.StudyDatasetState)

Example 2 with StudyDatasetState

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;
}
Also used : StudyDatasetState(org.obiba.mica.dataset.domain.StudyDatasetState) NotNull(javax.validation.constraints.NotNull)

Example 3 with StudyDatasetState

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));
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) StudyDatasetState(org.obiba.mica.dataset.domain.StudyDatasetState) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Aggregations

StudyDatasetState (org.obiba.mica.dataset.domain.StudyDatasetState)3 NotNull (javax.validation.constraints.NotNull)1 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)1 DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)1