Search in sources :

Example 1 with DocumentSetDeletedEvent

use of org.obiba.mica.core.event.DocumentSetDeletedEvent in project mica2 by obiba.

the class StudyIndexer method documentSetDeleted.

@Async
@Subscribe
public synchronized void documentSetDeleted(DocumentSetDeletedEvent event) {
    if (!studySetService.isForType(event.getPersistable()))
        return;
    DocumentSet documentSet = event.getPersistable();
    List<BaseStudy> toIndex = Lists.newArrayList();
    {
        List<BaseStudy> toRemove = studySetService.getPublishedStudies(event.getPersistable(), false);
        toRemove.forEach(std -> std.removeSet(documentSet.getId()));
        toIndex.addAll(toRemove);
    }
    indexer.indexAllIndexables(Indexer.PUBLISHED_STUDY_INDEX, toIndex);
}
Also used : Async(org.springframework.scheduling.annotation.Async) DocumentSetUpdatedEvent(org.obiba.mica.core.event.DocumentSetUpdatedEvent) PersonService(org.obiba.mica.core.service.PersonService) Logger(org.slf4j.Logger) DocumentSetDeletedEvent(org.obiba.mica.core.event.DocumentSetDeletedEvent) BaseStudy(org.obiba.mica.study.domain.BaseStudy) Indexable(org.obiba.mica.spi.search.Indexable) LoggerFactory(org.slf4j.LoggerFactory) Membership(org.obiba.mica.core.domain.Membership) StudyService(org.obiba.mica.study.service.StudyService) Indexer(org.obiba.mica.spi.search.Indexer) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Component(org.springframework.stereotype.Component) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Subscribe(com.google.common.eventbus.Subscribe) org.obiba.mica.study.event(org.obiba.mica.study.event) StudySetService(org.obiba.mica.study.service.StudySetService) List(java.util.List) DocumentSet(org.obiba.mica.core.domain.DocumentSet) BaseStudy(org.obiba.mica.study.domain.BaseStudy) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with DocumentSetDeletedEvent

use of org.obiba.mica.core.event.DocumentSetDeletedEvent in project mica2 by obiba.

the class VariableIndexer method documentSetDeleted.

@Async
@Subscribe
public synchronized void documentSetDeleted(DocumentSetDeletedEvent event) {
    if (!variableSetService.isForType(event.getPersistable()))
        return;
    DocumentSet documentSet = event.getPersistable();
    List<DatasetVariable> toIndex = Lists.newArrayList();
    {
        List<DatasetVariable> toRemove = variableSetService.getVariables(event.getPersistable(), false);
        toRemove.forEach(var -> var.removeSet(documentSet.getId()));
        toIndex.addAll(toRemove);
    }
    indexer.indexAllIndexables(Indexer.PUBLISHED_VARIABLE_INDEX, toIndex);
}
Also used : Async(org.springframework.scheduling.annotation.Async) DocumentSetUpdatedEvent(org.obiba.mica.core.event.DocumentSetUpdatedEvent) DatasetDeletedEvent(org.obiba.mica.dataset.event.DatasetDeletedEvent) Logger(org.slf4j.Logger) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) DocumentSetDeletedEvent(org.obiba.mica.core.event.DocumentSetDeletedEvent) VariableSetService(org.obiba.mica.dataset.service.VariableSetService) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) LoggerFactory(org.slf4j.LoggerFactory) CollectedDatasetService(org.obiba.mica.dataset.service.CollectedDatasetService) Dataset(org.obiba.mica.dataset.domain.Dataset) Indexer(org.obiba.mica.spi.search.Indexer) DatasetUnpublishedEvent(org.obiba.mica.dataset.event.DatasetUnpublishedEvent) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Inject(javax.inject.Inject) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Component(org.springframework.stereotype.Component) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Subscribe(com.google.common.eventbus.Subscribe) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) List(java.util.List) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with DocumentSetDeletedEvent

use of org.obiba.mica.core.event.DocumentSetDeletedEvent in project mica2 by obiba.

the class NetworkIndexer method documentSetDeleted.

@Async
@Subscribe
public synchronized void documentSetDeleted(DocumentSetDeletedEvent event) {
    if (!networkSetService.isForType(event.getPersistable()))
        return;
    DocumentSet documentSet = event.getPersistable();
    List<Network> toIndex = Lists.newArrayList();
    {
        List<Network> toRemove = networkSetService.getPublishedNetworks(event.getPersistable(), false);
        toRemove.forEach(ntw -> ntw.removeSet(documentSet.getId()));
        toIndex.addAll(toRemove);
    }
    indexer.indexAll(Indexer.PUBLISHED_NETWORK_INDEX, toIndex);
}
Also used : Async(org.springframework.scheduling.annotation.Async) DocumentSetUpdatedEvent(org.obiba.mica.core.event.DocumentSetUpdatedEvent) PersonService(org.obiba.mica.core.service.PersonService) Logger(org.slf4j.Logger) DocumentSetDeletedEvent(org.obiba.mica.core.event.DocumentSetDeletedEvent) LoggerFactory(org.slf4j.LoggerFactory) Membership(org.obiba.mica.core.domain.Membership) Indexer(org.obiba.mica.spi.search.Indexer) org.obiba.mica.network.event(org.obiba.mica.network.event) Collectors(java.util.stream.Collectors) NetworkSetService(org.obiba.mica.network.service.NetworkSetService) Inject(javax.inject.Inject) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Component(org.springframework.stereotype.Component) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Subscribe(com.google.common.eventbus.Subscribe) Network(org.obiba.mica.network.domain.Network) NetworkService(org.obiba.mica.network.service.NetworkService) Network(org.obiba.mica.network.domain.Network) List(java.util.List) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with DocumentSetDeletedEvent

use of org.obiba.mica.core.event.DocumentSetDeletedEvent in project mica2 by obiba.

the class DocumentSetService method delete.

/**
 * Delete definitely a document set.
 *
 * @param documentSet
 */
public void delete(DocumentSet documentSet) {
    ensureType(documentSet);
    if (!documentSet.isNew()) {
        documentSetRepository.delete(documentSet);
        eventBus.post(new DocumentSetDeletedEvent(documentSet));
    }
}
Also used : DocumentSetDeletedEvent(org.obiba.mica.core.event.DocumentSetDeletedEvent)

Aggregations

DocumentSetDeletedEvent (org.obiba.mica.core.event.DocumentSetDeletedEvent)4 Lists (com.google.common.collect.Lists)3 Subscribe (com.google.common.eventbus.Subscribe)3 List (java.util.List)3 Map (java.util.Map)3 Inject (javax.inject.Inject)3 DocumentSet (org.obiba.mica.core.domain.DocumentSet)3 DocumentSetUpdatedEvent (org.obiba.mica.core.event.DocumentSetUpdatedEvent)3 Indexer (org.obiba.mica.spi.search.Indexer)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Async (org.springframework.scheduling.annotation.Async)3 Component (org.springframework.stereotype.Component)3 Collectors (java.util.stream.Collectors)2 Membership (org.obiba.mica.core.domain.Membership)2 PersonService (org.obiba.mica.core.service.PersonService)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Dataset (org.obiba.mica.dataset.domain.Dataset)1 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)1 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)1