/**
* {@inheritDoc}
*/
@Override
public void updateGenreContribution(
@NotNull @Valid final ContributionUpdate<Genre> contribution,
@Min(1) final Long contributionId,
@NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
log.info("Called with contribution {}, contributionId {}, userId {}",
contribution, contributionId, userId);
final UserEntity user = this.findUser(userId);
final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.GENRE);
this.validIds(contributionEntity, contribution);
this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getGenres());
contribution.getElementsToAdd().forEach((key, value) -> {
this.moviePersistenceService.updateGenre(value, key, contributionEntity.getMovie());
});
contribution.getElementsToUpdate().forEach((key, value) -> {
this.moviePersistenceService.updateGenre(value, key, contributionEntity.getMovie());
});
contribution.getNewElementsToAdd()
.forEach(genre -> {
final Long id = this.moviePersistenceService.createGenre(genre, contributionEntity.getMovie());
contributionEntity.getIdsToAdd().add(id);
});
contributionEntity.setSources(contribution.getSources());
Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
MovieContributionPersistenceServiceImpl.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:REST-Web-Services
作者:
评论列表
文章目录