class KeyResultService {

  @Transactional
  public KeyResult updateKeyResult(KeyResult updatedKeyResult, User user) {
    KeyResult referencedKeyResult = findById(updatedKeyResult.getId());
    throwIfCycleOfKeyResultIsClosed(referencedKeyResult);

    referencedKeyResult.setName(updatedKeyResult.getName());
    referencedKeyResult.setDescription(updatedKeyResult.getDescription());
    referencedKeyResult.setStartValue(updatedKeyResult.getStartValue());
    referencedKeyResult.setCurrentValue(updatedKeyResult.getCurrentValue());
    referencedKeyResult.setTargetValue(updatedKeyResult.getTargetValue());
    referencedKeyResult.setUnit(updatedKeyResult.getUnit());

    referencedKeyResult = keyResultRepository.save(referencedKeyResult);
    logger.info(
        "Updated Key Result "
            + referencedKeyResult.getName()
            + "(id:"
            + referencedKeyResult.getId()
            + ")");
    activityService.createActivity(user, referencedKeyResult, Action.EDITED);
    return referencedKeyResult;
  }

  @Autowired public  KeyResultService(
      KeyResultRepository keyResultRepository,
      NoteRepository noteRepository,
      ActivityService activityService,
      EntityCrawlerService entityCrawlerService,
      ObjectiveService objectiveService);

}