Search in sources :

Example 1 with ProjectPublishedEvent

use of org.obiba.mica.project.event.ProjectPublishedEvent in project mica2 by obiba.

the class ProjectService method publish.

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

Example 2 with ProjectPublishedEvent

use of org.obiba.mica.project.event.ProjectPublishedEvent in project mica2 by obiba.

the class ProjectService method index.

/**
 * Index a specific {@link Project} without updating it.
 *
 * @param id
 * @throws NoSuchProjectException
 */
public void index(@NotNull String id) throws NoSuchProjectException {
    ProjectState projectState = getEntityState(id);
    Project project = findById(id);
    eventBus.post(new ProjectUpdatedEvent(project));
    if (projectState.isPublished())
        eventBus.post(new ProjectPublishedEvent(project, getCurrentUsername()));
    else
        eventBus.post(new ProjectUpdatedEvent(project));
}
Also used : Project(org.obiba.mica.project.domain.Project) ProjectPublishedEvent(org.obiba.mica.project.event.ProjectPublishedEvent) ProjectState(org.obiba.mica.project.domain.ProjectState) ProjectUpdatedEvent(org.obiba.mica.project.event.ProjectUpdatedEvent)

Aggregations

Project (org.obiba.mica.project.domain.Project)2 ProjectPublishedEvent (org.obiba.mica.project.event.ProjectPublishedEvent)2 ProjectState (org.obiba.mica.project.domain.ProjectState)1 ProjectUnpublishedEvent (org.obiba.mica.project.event.ProjectUnpublishedEvent)1 ProjectUpdatedEvent (org.obiba.mica.project.event.ProjectUpdatedEvent)1 Caching (org.springframework.cache.annotation.Caching)1