Search in sources :

Example 1 with NetworkUnpublishedEvent

use of org.obiba.mica.network.event.NetworkUnpublishedEvent in project mica2 by obiba.

the class NetworkService method index.

/**
 * Index a specific {@link Network} without updating it.
 *
 * @param id
 * @throws NoSuchNetworkException
 */
public void index(@NotNull String id) throws NoSuchNetworkException {
    NetworkState networkState = getEntityState(id);
    Network network = findById(id);
    eventBus.post(new NetworkUpdatedEvent(network));
    processNetworkForPublishedNumberOfStudies(network);
    if (networkState.isPublished())
        eventBus.post(new NetworkPublishedEvent(network, getCurrentUsername()));
    else
        eventBus.post(new NetworkUnpublishedEvent(network));
}
Also used : NetworkUnpublishedEvent(org.obiba.mica.network.event.NetworkUnpublishedEvent) NetworkPublishedEvent(org.obiba.mica.network.event.NetworkPublishedEvent) Network(org.obiba.mica.network.domain.Network) NetworkUpdatedEvent(org.obiba.mica.network.event.NetworkUpdatedEvent) NetworkState(org.obiba.mica.network.domain.NetworkState)

Example 2 with NetworkUnpublishedEvent

use of org.obiba.mica.network.event.NetworkUnpublishedEvent in project mica2 by obiba.

the class NetworkService method publish.

/**
 * Set the publication flag on a {@link Network}.
 *
 * @param id
 * @throws NoSuchNetworkException
 */
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'network'") })
public void publish(@NotNull String id, boolean publish, PublishCascadingScope cascadingScope) throws NoSuchEntityException {
    Network network = networkRepository.findOne(id);
    if (network == null)
        return;
    if (publish) {
        processNetworkForPublishedNumberOfStudies(network);
        publishState(id);
        eventBus.post(new NetworkPublishedEvent(network, getCurrentUsername(), cascadingScope));
    } else {
        unPublishState(id);
        eventBus.post(new NetworkUnpublishedEvent(network));
    }
}
Also used : NetworkUnpublishedEvent(org.obiba.mica.network.event.NetworkUnpublishedEvent) NetworkPublishedEvent(org.obiba.mica.network.event.NetworkPublishedEvent) Network(org.obiba.mica.network.domain.Network) Caching(org.springframework.cache.annotation.Caching)

Aggregations

Network (org.obiba.mica.network.domain.Network)2 NetworkPublishedEvent (org.obiba.mica.network.event.NetworkPublishedEvent)2 NetworkUnpublishedEvent (org.obiba.mica.network.event.NetworkUnpublishedEvent)2 NetworkState (org.obiba.mica.network.domain.NetworkState)1 NetworkUpdatedEvent (org.obiba.mica.network.event.NetworkUpdatedEvent)1 Caching (org.springframework.cache.annotation.Caching)1