Search in sources :

Example 1 with NetworkPublishedEvent

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

the class NetworkService method removeRoles.

private void removeRoles(@NotNull Network network, Iterable<String> roles) {
    saveInternal(network, String.format("Removed roles: %s", Joiner.on(", ").join(roles)), false);
    NetworkState state = findStateById(network.getId());
    if (state.isPublished()) {
        processNetworkForPublishedNumberOfStudies(network);
        publishState(network.getId());
        eventBus.post(new NetworkPublishedEvent(network, getCurrentUsername(), PublishCascadingScope.NONE));
    }
}
Also used : NetworkPublishedEvent(org.obiba.mica.network.event.NetworkPublishedEvent) NetworkState(org.obiba.mica.network.domain.NetworkState)

Example 2 with NetworkPublishedEvent

use of org.obiba.mica.network.event.NetworkPublishedEvent 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 3 with NetworkPublishedEvent

use of org.obiba.mica.network.event.NetworkPublishedEvent 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

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