Search in sources :

Example 11 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class TestDataCollectionEventSort method test_all_date_fields.

@Test
public void test_all_date_fields() {
    Population population = createPopulation("Test Population", createEvent("A", 2010, 1, 2020, 12), createEvent("A", 1997, 1, 2000, 12), createEvent("A", 1997, 8, 2000, 12));
    population.setName(en("Test Population"));
    DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
    assertThat(event.getStart()).isEqualTo(of(1997, 1));
}
Also used : DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 12 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class StudySummaryDtosTest method populations.

private List<Population> populations(List<String> countriesIsos) {
    HashMap<String, Object> selectionCriteria = new HashMap<>();
    selectionCriteria.put("countriesIso", countriesIsos);
    HashMap<String, Object> model = new HashMap<>();
    model.put("selectionCriteria", selectionCriteria);
    List<Population> populations = new ArrayList<>();
    Population population = new Population();
    population.setModel(model);
    populations.add(population);
    return populations;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Population(org.obiba.mica.study.domain.Population)

Example 13 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class Mica310Upgrade method transformExistingStudies.

private void transformExistingStudies(Study study) {
    try {
        for (Population population : study.getPopulations()) {
            List<String> dataSources = (List<String>) ((Map<String, Object>) population.getModel().get("recruitment")).get("dataSources");
            dataSources.remove("existing_studies");
            dataSources.add("exist_studies");
        }
    } catch (RuntimeException ignore) {
    }
}
Also used : Population(org.obiba.mica.study.domain.Population) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) JSONObject(org.json.JSONObject)

Example 14 with Population

use of org.obiba.mica.study.domain.Population 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 Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class CollectedDatasetService method prepareForIndex.

private void prepareForIndex(StudyDataset dataset) {
    if (dataset.hasStudyTable()) {
        StudyTable studyTable = dataset.getStudyTable();
        BaseStudy study = publishedStudyService.findById(dataset.getStudyTable().getStudyId());
        if (study != null) {
            Population population = study.findPopulation(studyTable.getPopulationId());
            if (population != null) {
                studyTable.setPopulationWeight(population.getWeight());
                DataCollectionEvent dataCollectionEvent = population.findDataCollectionEvent(studyTable.getDataCollectionEventId());
                if (dataCollectionEvent != null) {
                    studyTable.setDataCollectionEventWeight(dataCollectionEvent.getWeight());
                }
            }
        }
    }
}
Also used : 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)

Aggregations

Population (org.obiba.mica.study.domain.Population)15 DataCollectionEvent (org.obiba.mica.study.domain.DataCollectionEvent)9 Test (org.junit.Test)7 Study (org.obiba.mica.study.domain.Study)5 BaseStudy (org.obiba.mica.study.domain.BaseStudy)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 NotNull (javax.validation.constraints.NotNull)2 StudyTable (org.obiba.mica.core.domain.StudyTable)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 EventBus (com.google.common.eventbus.EventBus)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1