Search in sources :

Example 21 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class VariableSetService method toOpalTableFullName.

private List<String> toOpalTableFullName(Dataset dataset) {
    if (dataset instanceof StudyDataset) {
        OpalTable opalTable = ((StudyDataset) dataset).getSafeStudyTable();
        return Lists.newArrayList(opalTable.getProject() + "." + opalTable.getTable());
    } else {
        HarmonizationDataset harmoDataset = (HarmonizationDataset) dataset;
        // one for each study and harmo tables
        List<String> tableNames = Lists.newArrayList();
        tableNames.addAll(harmoDataset.getStudyTables().stream().map(st -> st.getProject() + "." + st.getTable()).collect(Collectors.toList()));
        tableNames.addAll(harmoDataset.getHarmonizationTables().stream().map(ht -> ht.getProject() + "." + ht.getTable()).collect(Collectors.toList()));
        return tableNames;
    }
}
Also used : OpalTable(org.obiba.mica.core.domain.OpalTable) LocalizedString(org.obiba.mica.core.domain.LocalizedString) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 22 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class CollectedDatasetServiceTest method buildStudyDataset.

private StudyDataset buildStudyDataset() {
    StudyDataset ds = new StudyDataset();
    StudyTable st = new StudyTable();
    st.setProject("proj");
    st.setTable("tab");
    ds.setStudyTable(st);
    ds.setName(new LocalizedString(Locale.CANADA, "test"));
    return ds;
}
Also used : StudyTable(org.obiba.mica.core.domain.StudyTable) LocalizedString(org.obiba.mica.core.domain.LocalizedString) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 23 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class DraftCollectedDatasetsResource method list.

/**
 * Get all {@link org.obiba.mica.dataset.domain.StudyDataset}, optionally filtered by study.
 *
 * @param studyId can be null, in which case all datasets are returned
 * @return
 */
@GET
@Path("/collected-datasets")
@Timed
public List<Mica.DatasetDto> list(@QueryParam("study") String studyId, @QueryParam("query") String query, @QueryParam("from") @DefaultValue("0") Integer from, @QueryParam("limit") Integer limit, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("order") @DefaultValue("asc") String order, @QueryParam("filter") @DefaultValue("ALL") String filter, @Context HttpServletResponse response) {
    long totalCount;
    EntityStateFilter entityStateFilter = EntityStateFilter.valueOf(filter);
    List<String> filteredIds = datasetService.getIdsByStateFilter(entityStateFilter);
    Searcher.IdFilter accessibleIdFilter = AccessibleIdFilterBuilder.newBuilder().aclService(subjectAclService).resources(Lists.newArrayList("/draft/collected-dataset")).ids(filteredIds).build();
    if (limit == null)
        limit = MAX_LIMIT;
    if (limit < 0)
        throw new IllegalArgumentException("limit cannot be negative");
    DocumentService.Documents<StudyDataset> datasets = draftCollectedDatasetService.find(from, limit, sort, order, studyId, query, null, null, accessibleIdFilter);
    totalCount = datasets.getTotal();
    response.addHeader("X-Total-Count", Long.toString(totalCount));
    return datasets.getList().stream().map(dataset -> dtos.asDto(dataset, true)).collect(toList());
}
Also used : EntityStateFilter(org.obiba.mica.core.domain.EntityStateFilter) Async(org.springframework.scheduling.annotation.Async) PathParam(javax.ws.rs.PathParam) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) DraftCollectedDatasetService(org.obiba.mica.dataset.service.DraftCollectedDatasetService) Scope(org.springframework.context.annotation.Scope) Inject(javax.inject.Inject) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) QueryParam(javax.ws.rs.QueryParam) Lists(com.google.common.collect.Lists) Mica(org.obiba.mica.web.model.Mica) DefaultValue(javax.ws.rs.DefaultValue) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Dtos(org.obiba.mica.web.model.Dtos) Nullable(javax.annotation.Nullable) AccessibleIdFilterBuilder(org.obiba.mica.search.AccessibleIdFilterBuilder) POST(javax.ws.rs.POST) Context(javax.ws.rs.core.Context) SubjectAclService(org.obiba.mica.security.service.SubjectAclService) Searcher(org.obiba.mica.spi.search.Searcher) HttpServletResponse(javax.servlet.http.HttpServletResponse) CollectedDatasetService(org.obiba.mica.dataset.service.CollectedDatasetService) Dataset(org.obiba.mica.dataset.domain.Dataset) ApplicationContext(org.springframework.context.ApplicationContext) Timed(com.codahale.metrics.annotation.Timed) List(java.util.List) Component(org.springframework.stereotype.Component) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) DocumentService(org.obiba.mica.core.service.DocumentService) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) EntityStateFilter(org.obiba.mica.core.domain.EntityStateFilter) Searcher(org.obiba.mica.spi.search.Searcher) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) DocumentService(org.obiba.mica.core.service.DocumentService) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 24 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class PublishedDatasetResource method alternativeStudyDataset.

private StudyDataset alternativeStudyDataset(String id, String project, String table) {
    Dataset dataset = getDataset(id);
    if (!(dataset instanceof StudyDataset))
        throw NoSuchDatasetException.withId(id);
    StudyDataset asStudyDataset = (StudyDataset) dataset;
    asStudyDataset.getStudyTable().setProject(project);
    asStudyDataset.getStudyTable().setTable(table);
    return asStudyDataset;
}
Also used : Dataset(org.obiba.mica.dataset.domain.Dataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 25 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class DraftCollectedDatasetResource method update.

@PUT
public Response update(Mica.DatasetDto datasetDto, @Context UriInfo uriInfo, @Nullable @QueryParam("comment") String comment) {
    checkPermission("/draft/collected-dataset", "EDIT");
    if (!datasetDto.hasId() || !datasetDto.getId().equals(id))
        throw new IllegalArgumentException("Not the expected dataset id");
    Dataset dataset = dtos.fromDto(datasetDto);
    if (!(dataset instanceof StudyDataset))
        throw new IllegalArgumentException("A study dataset is expected");
    datasetService.save((StudyDataset) dataset, comment);
    return Response.noContent().build();
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Dataset(org.obiba.mica.dataset.domain.Dataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Aggregations

StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)27 Dataset (org.obiba.mica.dataset.domain.Dataset)10 StudyTable (org.obiba.mica.core.domain.StudyTable)6 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)6 Timed (com.codahale.metrics.annotation.Timed)5 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)5 Lists (com.google.common.collect.Lists)4 IOException (java.io.IOException)4 Inject (javax.inject.Inject)4 DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)4 Component (org.springframework.stereotype.Component)4 Strings (com.google.common.base.Strings)3 Collectors (java.util.stream.Collectors)3 Collectors.toList (java.util.stream.Collectors.toList)3 Path (javax.ws.rs.Path)3 Sets (com.google.common.collect.Sets)2 EventBus (com.google.common.eventbus.EventBus)2 java.util (java.util)2 HashMap (java.util.HashMap)2 List (java.util.List)2