public void deleteSelectedGroup() {
    if (selectedGroup == null) {
      LOGGER.debug("Trying to remove selected group, but none selected " + subject.getName());
      return;
    }

    subject.getGroups().remove(selectedGroup);
    setSelectedGroup(null);
  }
 public SubjectGroupManagementController(Subject subject, Person currentPerson) {
   this.subject = subject;
   this.currentPerson = currentPerson;
   this.selectedGroup = retrieveSelectedGroup();
   if (selectedGroup != null) {
     LOGGER.debug("Selected group for " + subject.getName() + " - " + selectedGroup.getName());
   }
 }
  public void setSelectedGroup(Group selectedGroup) {
    if (selectedGroup != null) {
      LOGGER.debug(subject.getName() + " - Setting selected group to " + selectedGroup.getName());
    } else {
      LOGGER.debug(subject.getName() + " - Deselecting selected group");
    }

    /* Exceeded capacity */
    if ((selectedGroup != null)
        && (!selectedGroup.equals(selectedGroup))
        && (selectedGroup.getPersons().size() + 1
            > selectedGroup.getSubject().getTeamsCapacity())) {
      FacesContext.getCurrentInstance()
          .addMessage(
              "",
              new FacesMessage(
                  FacesMessage.SEVERITY_WARN,
                  "C: Group " + selectedGroup.getName() + " is already full.",
                  ""));
      LOGGER.debug("Overflow detected when setting selected group.");
    } else {
      this.selectedGroup = selectedGroup;
    }
  }