Search in sources :

Example 11 with StudyDataset

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

the class DatasetDtos method fromDto.

private Dataset fromDto(@NotNull Mica.CollectedDatasetDto dto) {
    Assert.notNull(dto, "StudyDataset dt cannot be null.");
    StudyDataset studyDataset = new StudyDataset();
    Optional.ofNullable(dto).ifPresent(ext -> studyDataset.setStudyTable(fromDto(ext.getStudyTable())));
    return studyDataset;
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 12 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 13 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)

Example 14 with StudyDataset

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

the class CollectedDatasetService method processVariablesForStudyDataset.

public List<DatasetVariable> processVariablesForStudyDataset(StudyDataset dataset, Iterable<DatasetVariable> variables) {
    if (!dataset.hasStudyTable()) {
        return Lists.newArrayList(variables);
    }
    StudyTable studyTable = dataset.getStudyTable();
    BaseStudy study = studyService.findStudy(dataset.getStudyTable().getStudyId());
    Population population = study.findPopulation(studyTable.getPopulationId());
    if (population == null) {
        return Lists.newArrayList(variables);
    }
    int populationWeight = population.getWeight();
    DataCollectionEvent dataCollectionEvent = population.findDataCollectionEvent(studyTable.getDataCollectionEventId());
    if (dataCollectionEvent == null) {
        return Lists.newArrayList(variables);
    }
    int dataCollectionEventWeight = dataCollectionEvent.getWeight();
    return StreamSupport.stream(variables.spliterator(), false).map(datasetVariable -> {
        datasetVariable.setPopulationWeight(populationWeight);
        datasetVariable.setDataCollectionEventWeight(dataCollectionEventWeight);
        return datasetVariable;
    }).collect(toList());
}
Also used : Search(org.obiba.opal.web.model.Search) DatasetDeletedEvent(org.obiba.mica.dataset.event.DatasetDeletedEvent) FileUtils(org.obiba.mica.file.FileUtils) Cacheable(org.springframework.cache.annotation.Cacheable) LoggerFactory(org.slf4j.LoggerFactory) CacheEvict(org.springframework.cache.annotation.CacheEvict) AbstractGitPersistable(org.obiba.mica.core.domain.AbstractGitPersistable) NoSuchVariableException(org.obiba.magma.NoSuchVariableException) DatasetUnpublishedEvent(org.obiba.mica.dataset.event.DatasetUnpublishedEvent) Valid(javax.validation.Valid) StudyDatasetIndexedEvent(org.obiba.mica.dataset.event.StudyDatasetIndexedEvent) PublishCascadingScope(org.obiba.mica.core.domain.PublishCascadingScope) EntityStateRepository(org.obiba.mica.core.repository.EntityStateRepository) NoSuchDatasetException(org.obiba.mica.dataset.NoSuchDatasetException) StudyState(org.obiba.mica.study.domain.StudyState) QueryTermsUtil(org.obiba.mica.dataset.service.support.QueryTermsUtil) Set(java.util.Set) StudyService(org.obiba.mica.study.service.StudyService) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) NoSuchEntityException(org.obiba.mica.NoSuchEntityException) Sets(com.google.common.collect.Sets) List(java.util.List) NoSuchValueTableException(org.obiba.magma.NoSuchValueTableException) Stream(java.util.stream.Stream) Study(org.obiba.mica.study.domain.Study) StudyDatasetState(org.obiba.mica.dataset.domain.StudyDatasetState) StudyDatasetStateRepository(org.obiba.mica.dataset.StudyDatasetStateRepository) Lazy(org.springframework.context.annotation.Lazy) NetworkService(org.obiba.mica.network.service.NetworkService) BeanUtils(org.springframework.beans.BeanUtils) Async(org.springframework.scheduling.annotation.Async) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) RestValueTable(org.obiba.opal.rest.client.magma.RestValueTable) OpalService(org.obiba.mica.micaConfig.service.OpalService) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Caching(org.springframework.cache.annotation.Caching) EventBus(com.google.common.eventbus.EventBus) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) StreamSupport(java.util.stream.StreamSupport) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Validated(org.springframework.validation.annotation.Validated) DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) Logger(org.slf4j.Logger) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) BaseStudy(org.obiba.mica.study.domain.BaseStudy) DateTime(org.joda.time.DateTime) Population(org.obiba.mica.study.domain.Population) FileSystemService(org.obiba.mica.file.service.FileSystemService) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) NoSuchStudyException(org.obiba.mica.study.NoSuchStudyException) PublishedStudyService(org.obiba.mica.study.service.PublishedStudyService) IndividualStudyService(org.obiba.mica.study.service.IndividualStudyService) Component(org.springframework.stereotype.Component) Collectors.toList(java.util.stream.Collectors.toList) StudyDatasetRepository(org.obiba.mica.dataset.StudyDatasetRepository) StudyTable(org.obiba.mica.core.domain.StudyTable) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) StudyTable(org.obiba.mica.core.domain.StudyTable) Population(org.obiba.mica.study.domain.Population) BaseStudy(org.obiba.mica.study.domain.BaseStudy)

Example 15 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset 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

StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)16 StudyTable (org.obiba.mica.core.domain.StudyTable)4 IOException (java.io.IOException)3 Dataset (org.obiba.mica.dataset.domain.Dataset)3 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)3 DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)3 Timed (com.codahale.metrics.annotation.Timed)2 Strings (com.google.common.base.Strings)2 Lists (com.google.common.collect.Lists)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 NotNull (javax.validation.constraints.NotNull)2 BadRequestException (javax.ws.rs.BadRequestException)2 Path (javax.ws.rs.Path)2 DateTime (org.joda.time.DateTime)2 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)2 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)2 StudyDatasetState (org.obiba.mica.dataset.domain.StudyDatasetState)2 DatasetDeletedEvent (org.obiba.mica.dataset.event.DatasetDeletedEvent)2