use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class DraftProjectResource method update.
@PUT
public Response update(@SuppressWarnings("TypeMayBeWeakened") Mica.ProjectDto projectDto, @Nullable @QueryParam("comment") String comment) {
checkPermission("/draft/project", "EDIT");
// ensure network exists
projectService.findById(id);
Project project = dtos.fromDto(projectDto);
projectService.save(project, comment);
return Response.noContent().build();
}
use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class ProjectService method dataAccessRequestUpdated.
//
// Event handling
//
@Async
@Subscribe
public void dataAccessRequestUpdated(DataAccessRequestUpdatedEvent event) {
DataAccessRequest request = event.getPersistable();
if (!projectRepository.exists(request.getId()) && request.getStatus() == DataAccessRequest.Status.APPROVED) {
Project project = new Project();
project.setId(event.getPersistable().getId());
project.setDataAccessRequestId(event.getPersistable().getId());
String title = dataAccessRequestUtilService.getRequestTitle(request);
if (!Strings.isNullOrEmpty(title)) {
project.setTitle(LocalizedString.from(micaConfigService.getConfig().getLocales(), title));
}
String summary = dataAccessRequestUtilService.getRequestSummary(request);
if (!Strings.isNullOrEmpty(summary)) {
project.setSummary(LocalizedString.from(micaConfigService.getConfig().getLocales(), summary));
}
save(project, "Created from Data Access Request");
}
}
use of org.obiba.mica.project.domain.Project 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));
}
}
use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class ProjectDtos method fromDto.
@NotNull
public Project fromDto(@NotNull Mica.ProjectDto dto) {
Project.Builder builder = Project.newBuilder();
builder.content(dto.hasContent() ? dto.getContent() : null);
builder.title(localizedStringDtos.fromDto(dto.getTitleList()));
builder.summary(localizedStringDtos.fromDto(dto.getSummaryList()));
Project project = builder.build();
if (dto.hasId())
project.setId(dto.getId());
TimestampsDtos.fromDto(dto.getTimestamps(), project);
return project;
}
use of org.obiba.mica.project.domain.Project 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);
}
Aggregations