executionYear = previousExecutionPeriod.getExecutionYear();
if (previousExecutionPeriod != null) { executionYear = previousExecutionPeriod.getExecutionYear(); } else { executionYear = actualExecutionPeriod.getExecutionYear(); }
    public SiteView run(String user, String argExecutionYear) throws FenixServiceException,            ExcepcaoPersistencia {        InfoSiteTeacherInformation infoSiteTeacherInformation = new InfoSiteTeacherInformation();        ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();        IPersistentTeacher persistentTeacher = sp.getIPersistentTeacher();        Teacher teacher = persistentTeacher.readTeacherByUsername(user);        // if no execution year is specified, the info shown should refer to        // the previous execution year        IPersistentExecutionYear persistentExecutionYear = sp.getIPersistentExecutionYear();        ExecutionYear executionYear = null;        if (argExecutionYear == null || argExecutionYear.equals("")) {            IPersistentExecutionPeriod persistentExecutionPeriod = sp.getIPersistentExecutionPeriod();            ExecutionPeriod actualExecutionPeriod = persistentExecutionPeriod                    .readActualExecutionPeriod();            ExecutionPeriod previousExecutionPeriod = actualExecutionPeriod                    .getPreviousExecutionPeriod();            while (previousExecutionPeriod.getExecutionYear().equals(                    actualExecutionPeriod.getExecutionYear())) {                previousExecutionPeriod = previousExecutionPeriod.getPreviousExecutionPeriod();            }            executionYear = previousExecutionPeriod.getExecutionYear();        } else            executionYear = persistentExecutionYear.readExecutionYearByName(argExecutionYear);        InfoTeacher infoTeacher = InfoTeacherWithPersonAndCategory.newInfoFromDomain(teacher);        infoSiteTeacherInformation.setInfoTeacher(infoTeacher);        infoSiteTeacherInformation.setInfoQualifications(getInfoQualifications(sp, teacher));        infoSiteTeacherInformation.setInfoProfessionalCareers(getInfoCareers(teacher,                CareerType.PROFESSIONAL));        infoSiteTeacherInformation.setInfoTeachingCareers(getInfoCareers(teacher, CareerType.TEACHING));        IPersistentServiceProviderRegime persistentServiceProviderRegime = sp                .getIPersistentServiceProviderRegime();        ServiceProviderRegime serviceProviderRegime = persistentServiceProviderRegime                .readByTeacherId(teacher.getIdInternal());        if (serviceProviderRegime == null) {            InfoServiceProviderRegime infoServiceProviderRegime = new InfoServiceProviderRegime();            infoServiceProviderRegime.setInfoTeacher(infoTeacher);            infoSiteTeacherInformation.setInfoServiceProviderRegime(infoServiceProviderRegime);        } else {            InfoServiceProviderRegime infoServiceProviderRegime = InfoServiceProviderRegime                    .newInfoFromDomain(serviceProviderRegime);            infoSiteTeacherInformation.setInfoServiceProviderRegime(infoServiceProviderRegime);        }        infoSiteTeacherInformation.setInfoExternalActivities(getInfoExternalActivities(sp, teacher));        infoSiteTeacherInformation.setInfoLecturingExecutionCourses(getInfoLecturingExecutionCourses(sp,                teacher, executionYear));        infoSiteTeacherInformation                .setInfoResponsibleExecutionCourses(getInfoResponsibleExecutionCourses(sp, teacher,                        executionYear));        IPersistentWeeklyOcupation persistentWeeklyOcupation = sp.getIPersistentWeeklyOcupation();        WeeklyOcupation weeklyOcupation = persistentWeeklyOcupation.readByTeacherId(teacher                .getIdInternal());        if (weeklyOcupation == null) {            InfoWeeklyOcupation infoWeeklyOcupation = new InfoWeeklyOcupation();            infoWeeklyOcupation.setInfoTeacher(infoTeacher);            infoWeeklyOcupation.setResearch(new Integer(0));            infoWeeklyOcupation.setManagement(new Integer(0));            infoWeeklyOcupation.setLecture(new Integer(0));            infoWeeklyOcupation.setSupport(new Integer(0));            infoWeeklyOcupation.setOther(new Integer(0));            infoSiteTeacherInformation.setInfoWeeklyOcupation(infoWeeklyOcupation);        } else {            InfoWeeklyOcupation infoWeeklyOcupation = InfoWeeklyOcupation                    .newInfoFromDomain(weeklyOcupation);            infoWeeklyOcupation.setInfoTeacher(infoTeacher);            infoSiteTeacherInformation.setInfoWeeklyOcupation(infoWeeklyOcupation);        }        infoSiteTeacherInformation.setInfoDegreeOrientation(getInfoOrientation(sp, teacher,                OrientationType.DEGREE));        infoSiteTeacherInformation.setInfoMasterOrientation(getInfoOrientation(sp, teacher,                OrientationType.MASTER));        infoSiteTeacherInformation.setInfoPhdOrientation(getInfoOrientation(sp, teacher,                OrientationType.PHD));        infoSiteTeacherInformation.setInfoArticleChapterPublicationsNumber(getInfoPublicationsNumber(sp,                teacher, PublicationType.ARTICLES_CHAPTERS));        infoSiteTeacherInformation.setInfoEditBookPublicationsNumber(getInfoPublicationsNumber(sp,                teacher, PublicationType.EDITOR_BOOK));        infoSiteTeacherInformation.setInfoAuthorBookPublicationsNumber(getInfoPublicationsNumber(sp,                teacher, PublicationType.AUTHOR_BOOK));        infoSiteTeacherInformation.setInfoMagArticlePublicationsNumber(getInfoPublicationsNumber(sp,                teacher, PublicationType.MAG_ARTICLE));        infoSiteTeacherInformation.setInfoComunicationPublicationsNumber(getInfoPublicationsNumber(sp,                teacher, PublicationType.COMUNICATION));        infoSiteTeacherInformation.setInfoOldCientificPublications(getInfoOldPublications(sp, teacher                .getIdInternal(), OldPublicationType.CIENTIFIC));        infoSiteTeacherInformation.setInfoOldDidacticPublications(getInfoOldPublications(sp, teacher                .getIdInternal(), OldPublicationType.DIDACTIC));        infoSiteTeacherInformation.setInfoDidaticPublications(getInfoPublications(sp, teacher,                PublicationConstants.DIDATIC));        infoSiteTeacherInformation.setInfoCientificPublications(getInfoPublications(sp, teacher,                PublicationConstants.CIENTIFIC));                // FIXME possible cause of error: this execution period is used for        // what?        infoSiteTeacherInformation.setInfoExecutionPeriod(InfoExecutionPeriodWithInfoExecutionYear                .newInfoFromDomain(executionYear.getExecutionPeriods().get(0)));        infoSiteTeacherInformation.setPersonFunctions(getPersonFunctions(teacher, executionYear));                return new SiteView(infoSiteTeacherInformation);    }