Пример #1
0
  public Phone addPhone(Long teacherId, Phone model) {
    if (teacherId == null) {
      throw new IllegalArgumentException(
          "Cannot find a " + Teacher.class.getName() + " with a null id.");
    }
    if (model == null) {
      throw new IllegalArgumentException("Cannot persist a null " + Phone.class.getName());
    }
    if (model.getId() != null) {
      throw new AlreadyDefinedInOnNonPersistedEntity(
          "Cannot persist a " + Phone.class.getName() + " which already has an ID.");
    }

    model = phoneManager.create(model);

    Teacher fetched = findOneById(teacherId);
    fetched.getContact().addPhone(model);
    teacherRepository.saveAndFlush(new TeacherDomain(fetched));
    return model;
  }
Пример #2
0
 public void removePhone(Long phoneId) {
   phoneManager.delete(phoneId);
 }