Search in sources :

Example 1 with HarmonizationDatasetState

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

Example 2 with HarmonizationDatasetState

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;
}
Also used : Search(org.obiba.opal.web.model.Search) OpalTable(org.obiba.mica.core.domain.OpalTable) MicaConfig(org.obiba.mica.micaConfig.domain.MicaConfig) Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) HarmonizationStudyTable(org.obiba.mica.core.domain.HarmonizationStudyTable) Inject(javax.inject.Inject) Term(org.obiba.opal.core.domain.taxonomy.Term) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) Map(java.util.Map) JSONUtils(org.obiba.mica.JSONUtils) Attributes(org.obiba.mica.core.domain.Attributes) HarmonizationDatasetState(org.obiba.mica.dataset.domain.HarmonizationDatasetState) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Nullable(javax.annotation.Nullable) SubjectAclService(org.obiba.mica.security.service.SubjectAclService) Math(org.obiba.opal.web.model.Math) Collection(java.util.Collection) DatasetCategory(org.obiba.mica.dataset.domain.DatasetCategory) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) NotNull(javax.validation.constraints.NotNull) Dataset(org.obiba.mica.dataset.domain.Dataset) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) PublishedStudyService(org.obiba.mica.study.service.PublishedStudyService) List(java.util.List) Component(org.springframework.stereotype.Component) HarmonizationDatasetStateRepository(org.obiba.mica.dataset.HarmonizationDatasetStateRepository) StudyDatasetState(org.obiba.mica.dataset.domain.StudyDatasetState) StudyDatasetStateRepository(org.obiba.mica.dataset.StudyDatasetStateRepository) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Optional(java.util.Optional) Vocabulary(org.obiba.opal.core.domain.taxonomy.Vocabulary) Collections(java.util.Collections) StudyTable(org.obiba.mica.core.domain.StudyTable) Assert(org.springframework.util.Assert) HarmonizationDatasetState(org.obiba.mica.dataset.domain.HarmonizationDatasetState) NotNull(javax.validation.constraints.NotNull)

Example 3 with HarmonizationDatasetState

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"));
}
Also used : HarmonizationDatasetState(org.obiba.mica.dataset.domain.HarmonizationDatasetState) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Test(org.junit.Test)

Aggregations

HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)3 HarmonizationDatasetState (org.obiba.mica.dataset.domain.HarmonizationDatasetState)3 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 NotNull (javax.validation.constraints.NotNull)1 Test (org.junit.Test)1 JSONUtils (org.obiba.mica.JSONUtils)1 Attributes (org.obiba.mica.core.domain.Attributes)1 HarmonizationStudyTable (org.obiba.mica.core.domain.HarmonizationStudyTable)1 OpalTable (org.obiba.mica.core.domain.OpalTable)1 StudyTable (org.obiba.mica.core.domain.StudyTable)1