Search in sources :

Example 1 with HarmonizationDataset

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

the class HarmonizedDatasetService method index.

/**
 * Index the dataset and associated variables.
 *
 * @param id
 */
public void index(@NotNull String id) {
    HarmonizationDataset dataset = findById(id);
    eventBus.post(new DatasetUpdatedEvent(dataset));
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 2 with HarmonizationDataset

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

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

the class HarmonizedDatasetService method indexAll.

public void indexAll(boolean mustIndexVariables) {
    Set<HarmonizationDataset> publishedDatasets = Sets.newHashSet(findAllPublishedDatasets());
    findAllDatasets().forEach(dataset -> {
        try {
            eventBus.post(new DatasetUpdatedEvent(dataset));
            if (publishedDatasets.contains(dataset)) {
                Map<String, List<DatasetVariable>> harmonizationVariables = mustIndexVariables && publishedDatasets.contains(dataset) ? populateHarmonizedVariablesMap(dataset) : null;
                Iterable<DatasetVariable> datasetVariables = mustIndexVariables && publishedDatasets.contains(dataset) ? wrappedGetDatasetVariables(dataset) : null;
                eventBus.post(new DatasetPublishedEvent(dataset, datasetVariables, harmonizationVariables, getCurrentUsername()));
            }
        } catch (Exception e) {
            log.error(String.format("Error indexing dataset %s", dataset), e);
        }
    });
    eventBus.post(new HarmonizationDatasetIndexedEvent());
}
Also used : HarmonizationDatasetIndexedEvent(org.obiba.mica.dataset.event.HarmonizationDatasetIndexedEvent) DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) NoSuchVariableException(org.obiba.magma.NoSuchVariableException) NoSuchDatasetException(org.obiba.mica.dataset.NoSuchDatasetException) NoSuchEntityException(org.obiba.mica.NoSuchEntityException) NoSuchValueTableException(org.obiba.magma.NoSuchValueTableException) MagmaRuntimeException(org.obiba.magma.MagmaRuntimeException) NoSuchStudyException(org.obiba.mica.study.NoSuchStudyException) ExecutionException(java.util.concurrent.ExecutionException) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 4 with HarmonizationDataset

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

the class HarmonizedDatasetService method publish.

/**
 * Apply dataset publication flag.
 *
 * @param id
 * @param published
 */
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") })
public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) {
    HarmonizationDataset dataset = findById(id);
    helper.evictCache(dataset);
    if (published) {
        checkIsPublishable(dataset);
        publishState(id);
        Map<String, List<DatasetVariable>> harmonizationVariables = populateHarmonizedVariablesMap(dataset);
        eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), harmonizationVariables, getCurrentUsername(), cascadingScope));
    // helper.asyncBuildDatasetVariablesCache(dataset, harmonizationVariables);
    } else {
        unPublishState(id);
        eventBus.post(new DatasetUnpublishedEvent(dataset));
    }
}
Also used : DatasetUnpublishedEvent(org.obiba.mica.dataset.event.DatasetUnpublishedEvent) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Caching(org.springframework.cache.annotation.Caching)

Example 5 with HarmonizationDataset

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

the class PublishedDataschemaDatasetVariableResource method getVariableSummaries.

@GET
@Path("/summary")
@Timed
public List<Math.SummaryStatisticsDto> getVariableSummaries() {
    ImmutableList.Builder<Math.SummaryStatisticsDto> builder = ImmutableList.builder();
    HarmonizationDataset dataset = getDataset(HarmonizationDataset.class, datasetId);
    dataset.getBaseStudyTables().forEach(table -> {
        try {
            String studyId = table.getStudyId();
            builder.add(datasetService.getVariableSummary(dataset, variableName, studyId, table.getProject(), table.getTable()).getWrappedDto());
        } catch (NoSuchVariableException | NoSuchValueTableException e) {
            // case the study has not implemented this dataschema variable
            builder.add(Math.SummaryStatisticsDto.newBuilder().setResource(variableName).build());
        }
    });
    return builder.build();
}
Also used : NoSuchValueTableException(org.obiba.magma.NoSuchValueTableException) NoSuchVariableException(org.obiba.magma.NoSuchVariableException) ImmutableList(com.google.common.collect.ImmutableList) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

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