if (studentGroup.getShift().getAssociatedStudentGroups() != null) { studentGroup.getShift().getAssociatedStudentGroups().remove(studentGroup); }
    public Boolean run(String userName, Integer studentGroupCode) throws FenixServiceException,            ExcepcaoPersistencia {        ISuportePersistente persistentSuport = PersistenceSupportFactory.getDefaultPersistenceSupport();        IPersistentStudentGroup persistentStudentGroup = persistentSuport.getIPersistentStudentGroup();        IPersistentStudent persistentStudent = persistentSuport.getIPersistentStudent();        IStudentGroup studentGroup = (IStudentGroup) persistentStudentGroup.readByOID(                StudentGroup.class, studentGroupCode);        if (studentGroup == null) {            throw new InvalidSituationServiceException();        }        IStudent student = persistentStudent.readByUsername(userName);        IGrouping groupProperties = studentGroup.getGrouping();        IAttends attend = groupProperties.getStudentAttend(student);        if (attend == null) {            throw new NotAuthorizedException();        }                IGroupEnrolmentStrategyFactory enrolmentGroupPolicyStrategyFactory = GroupEnrolmentStrategyFactory                .getInstance();                IGroupEnrolmentStrategy strategy = enrolmentGroupPolicyStrategyFactory                .getGroupEnrolmentStrategyInstance(groupProperties);        boolean resultEmpty = strategy.checkIfStudentGroupIsEmpty(attend,                studentGroup);                studentGroup.removeAttends(attend);                                       if (resultEmpty) {            groupProperties.removeStudentGroups(studentGroup);            if (studentGroup.getShift().getAssociatedStudentGroups() != null) {                studentGroup.getShift().getAssociatedStudentGroups().remove(studentGroup);            }            studentGroup.setShift(null);            persistentStudentGroup.deleteByOID(StudentGroup.class, studentGroup.getIdInternal());            return new Boolean(false);        }        return new Boolean(true);    }