class ObjectiveMapper implements DataMapper<Objective, ObjectiveDto> {

  @Override
  public ObjectiveDto mapEntityToDto(Objective objective) {
    ObjectiveDto objectiveDto = new ObjectiveDto();

    objectiveDto.setId(objective.getId());
    objectiveDto.setTitle(objective.getName());
    objectiveDto.setDescription(objective.getDescription());
    objectiveDto.setRemark(objective.getRemark());
    objectiveDto.setReview(objective.getReview());
    objectiveDto.setContactPersonId(objective.getContactPersonId());
    objectiveDto.setIsActive(objective.isActive());
    objectiveDto.setParentUnitId(objective.getParentOkrUnit().getId());
    objectiveDto.setSequence(objective.getSequence());

    if (objective.hasParentObjective()) {
      objectiveDto.setParentObjectiveId(objective.getParentObjective().getId());
    }

    Collection<Long> subObjectiveIds = new ArrayList<>();
    for (Objective subObjective : objective.getSubObjectives()) {
      subObjectiveIds.add(subObjective.getId());
    }
    objectiveDto.setSubObjectiveIds(subObjectiveIds);

    Collection<Long> keyResultIds = new ArrayList<>();
    for (KeyResult keyResult : objective.getKeyResults()) {
      keyResultIds.add(keyResult.getId());
    }
    objectiveDto.setKeyResultIds(keyResultIds);

    logger.info("Mapped Objective (id:" + objective.getId() + ") successful into ObjectiveDto.");
    return objectiveDto;
  }

}