class ObjectiveMapper implements DataMapper<Objective, ObjectiveDto> {

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

    objective.setId(objectiveDto.getId());
    objective.setName(objectiveDto.getTitle());
    objective.setDescription(objectiveDto.getDescription());
    objective.setRemark(objectiveDto.getRemark());
    objective.setReview(objectiveDto.getReview());
    objective.setContactPersonId(objectiveDto.getContactPersonId());
    objective.setActive(objectiveDto.getIsActive());
    objective.setSequence(objectiveDto.getSequence());

    OkrUnit parentOkrUnit = null;
    if (objectiveDto.getParentUnitId() != null) {
      parentOkrUnit = new OkrDepartment();
      parentOkrUnit.setId(objectiveDto.getParentUnitId());
    }
    objective.setParentOkrUnit(parentOkrUnit);

    Objective parentObjective = null;
    if (objectiveDto.hasParentObjectiveId()) {
      parentObjective = new Objective();
      parentObjective.setId(objectiveDto.getParentObjectiveId());
    }
    objective.setParentObjective(parentObjective);

    objective.setSubObjectives(new ArrayList<>());
    objective.setKeyResults(new ArrayList<>());

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

}