Search in sources :

Example 16 with HarmonizationDataset

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;
}
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 17 with HarmonizationDataset

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

Example 18 with HarmonizationDataset

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

Example 19 with HarmonizationDataset

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

Example 20 with HarmonizationDataset

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

Aggregations

HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)28 Path (javax.ws.rs.Path)10 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)9 GET (javax.ws.rs.GET)8 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)8 Timed (com.codahale.metrics.annotation.Timed)7 ImmutableList (com.google.common.collect.ImmutableList)7 IOException (java.io.IOException)4 List (java.util.List)4 BaseStudyTable (org.obiba.mica.core.domain.BaseStudyTable)4 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)4 Mica (org.obiba.mica.web.model.Mica)4 Lists (com.google.common.collect.Lists)3 Inject (javax.inject.Inject)3 HarmonizationStudyTable (org.obiba.mica.core.domain.HarmonizationStudyTable)3 StudyTable (org.obiba.mica.core.domain.StudyTable)3 Dataset (org.obiba.mica.dataset.domain.Dataset)3 Strings (com.google.common.base.Strings)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Collection (java.util.Collection)2