public ExerciseSetModel addSetTo(TrainingExerciseModel model, int numberOfRepeats) {

    ArrayList<ExerciseSets> existingSets = exerciseSetsDao.getAllForExercise(model.getId());

    Exercise origEx = exerciseDao.getById(model.getExerciseId());
    Training origTr = trainingDao.getById(model.getTrainingId());

    ExerciseSets set = new ExerciseSets();
    set.setNumberOfRepeats(numberOfRepeats);
    set.setTrainingsExercisesId(model.getId());
    set.setOrder(existingSets.size() + 1);

    ExerciseSets saved = exerciseSetsDao.save(set);

    if (saved != null) {
      ExerciseSetModel exerciseSetModel = new ExerciseSetModel();
      exerciseSetModel.setId(saved.getId());
      exerciseSetModel.setNumberOfRepeats(saved.getNumberOfRepeats());
      exerciseSetModel.setOrder(saved.getOrder());
      exerciseSetModel.setTrainingsExercisesId(saved.getTrainingsExercisesId());
      return exerciseSetModel;
    }

    return null;
  }
  public TrainingModel getById(int trainingId) {
    Training training = trainingDao.getById(trainingId);

    if (training == null) {
      return null;
    }

    TrainingModel model = new TrainingModel();
    model.setId(training.getId());
    model.setName(training.getName());
    model.setDescription(training.getDescription());
    model.setDateCreated(training.getDateCreated());

    ArrayList<TrainingsExercises> trainingsExercises =
        trainingsExercisesDao.getAllForTraining(trainingId);

    for (TrainingsExercises trainingExercise : trainingsExercises) {
      ExerciseModel exerciseModel = new ExerciseModel();
      exerciseModel.setId(trainingExercise.getId());

      Exercise exercise = exerciseDao.getById(trainingExercise.getExerciseId());
      exerciseModel.setName(exercise.getName());
      exerciseModel.setDescription(exercise.getDescription());
      exerciseModel.setImage(exercise.getImage());

      ArrayList<ExerciseSets> exerciseSets =
          exerciseSetsDao.getAllForExercise(trainingExercise.getId());

      for (ExerciseSets exerciseSet : exerciseSets) {
        ExerciseSetModel setModel = new ExerciseSetModel();
        setModel.setId(exerciseSet.getId());
        setModel.setNumberOfRepeats(exerciseSet.getNumberOfRepeats());
        setModel.setOrder(exerciseSet.getOrder());
        exerciseModel.addSet(setModel);
      }
      model.addExercise(exerciseModel);
    }

    return model;
  }