Java tutorial
/** * Copyright 2002 Instituto Superior Tcnico * * This file is part of FenixEdu Core. * * FenixEdu Core is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FenixEdu Core is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with FenixEdu Core. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.fenixedu.presentationTier.backBeans.coordinator; import java.util.List; import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.FenixServiceException; import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.NonExistingServiceException; import net.sourceforge.fenixedu.dataTransferObject.InfoMasterDegreeThesisDataVersionWithGuidersAndRespAndThesis; import net.sourceforge.fenixedu.domain.DegreeCurricularPlan; import net.sourceforge.fenixedu.domain.MasterDegreeThesisDataVersion; import net.sourceforge.fenixedu.injectionCode.IllegalDataAccessException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Transformer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pt.ist.fenixframework.FenixFramework; /** * * @author - Shezad Anavarali (shezad@ist.utl.pt) * */ public class ListStudentThesis { private static final Logger logger = LoggerFactory.getLogger(ListStudentThesis.class); private String degreeCurricularPlanID; public ListStudentThesis() { } public String getDegreeCurricularPlanID() { return degreeCurricularPlanID; } public void setDegreeCurricularPlanID(String degreeCurricularPlanID) { this.degreeCurricularPlanID = degreeCurricularPlanID; ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()) .setAttribute("degreeCurricularPlanID", degreeCurricularPlanID); } public List getMasterDegreeThesisDataVersions() { try { return run(degreeCurricularPlanID); } catch (IllegalDataAccessException e) { // TODO Auto-generated catch block logger.error(e.getMessage(), e); } catch (FenixServiceException e) { // TODO Auto-generated catch block logger.error(e.getMessage(), e); } return null; } private static List run(String degreeCurricularPlanID) throws FenixServiceException { DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); List masterDegreeThesisDataVersions = degreeCurricularPlan.readActiveMasterDegreeThesisDataVersions(); if (masterDegreeThesisDataVersions == null || masterDegreeThesisDataVersions.isEmpty()) { throw new NonExistingServiceException("error.exception.masterDegree.nonExistingMasterDegreeThesis"); } CollectionUtils.transform(masterDegreeThesisDataVersions, new Transformer() { @Override public Object transform(Object arg0) { MasterDegreeThesisDataVersion masterDegreeThesisDataVersion = (MasterDegreeThesisDataVersion) arg0; return InfoMasterDegreeThesisDataVersionWithGuidersAndRespAndThesis .newInfoFromDomain(masterDegreeThesisDataVersion); } }); return masterDegreeThesisDataVersions; } }