Search in sources :

Example 1 with ProjectUpdatedEvent

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

the class ProjectService method save.

@Override
public void save(@NotNull @Valid Project project, String comments) {
    Project saved = project;
    if (project.isNew()) {
        generateId(saved);
    } else {
        saved = projectRepository.findOne(project.getId());
        if (saved != null) {
            BeanUtils.copyProperties(project, saved, "id", "version", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate", "dataAccessRequestId");
        } else {
            saved = project;
        }
    }
    ProjectState projectState = findEntityState(project, () -> {
        ProjectState defaultState = new ProjectState();
        defaultState.setTitle(project.getTitle());
        return defaultState;
    });
    if (!project.isNew())
        ensureGitRepository(projectState);
    projectState.incrementRevisionsAhead();
    projectStateRepository.save(projectState);
    saved.setLastModifiedDate(DateTime.now());
    projectRepository.save(saved);
    eventBus.post(new ProjectUpdatedEvent(saved));
    gitService.save(saved);
}
Also used : Project(org.obiba.mica.project.domain.Project) ProjectState(org.obiba.mica.project.domain.ProjectState) ProjectUpdatedEvent(org.obiba.mica.project.event.ProjectUpdatedEvent)

Example 2 with ProjectUpdatedEvent

use of org.obiba.mica.project.event.ProjectUpdatedEvent 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 ProjectState (org.obiba.mica.project.domain.ProjectState)2 ProjectUpdatedEvent (org.obiba.mica.project.event.ProjectUpdatedEvent)2 ProjectPublishedEvent (org.obiba.mica.project.event.ProjectPublishedEvent)1