try {
this.likelihoodDataValidator.validateForUpdate(command);
final Likelihood likelihood = this.repository.findOne(likelihoodId);
if (!likelihood.update(command).isEmpty()) {
this.repository.save(likelihood);
if (likelihood.isActivateCommand(command)) {
List<Likelihood> likelihoods = this.repository
.findByPpiNameAndLikeliHoodId(likelihood.getPpiName(), likelihood.getId());
for (Likelihood aLikelihood : likelihoods) {
aLikelihood.disable();
}
this.repository.save(likelihoods);
}
}
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(likelihood.getId()).build();
} catch (final DataIntegrityViolationException dve) {
handleDataIntegrityIssues(dve);
return CommandProcessingResult.empty();
}