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);
}
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));
}
Aggregations