Package org.fenixedu.academic.ui.struts.action.person

Source Code of org.fenixedu.academic.ui.struts.action.person.IRSDeclarationAction

/**
* Copyright © 2002 Instituto Superior Técnico
*
* This file is part of FenixEdu Academic.
*
* FenixEdu Academic 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 Academic 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 Academic.  If not, see <http://www.gnu.org/licenses/>.
*/
package org.fenixedu.academic.ui.struts.action.person;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.fenixedu.academic.domain.IrsDeclarationLink;
import org.fenixedu.academic.predicate.AccessControl;
import org.fenixedu.academic.ui.struts.action.base.FenixDispatchAction;
import org.fenixedu.academic.ui.struts.action.person.PersonApplication.PersonalAreaApp;
import org.fenixedu.bennu.struts.annotations.Forward;
import org.fenixedu.bennu.struts.annotations.Forwards;
import org.fenixedu.bennu.struts.annotations.Mapping;
import org.fenixedu.bennu.struts.portal.EntryPoint;
import org.fenixedu.bennu.struts.portal.StrutsFunctionality;

import pt.utl.ist.fenix.tools.util.i18n.MultiLanguageString;

@StrutsFunctionality(app = PersonalAreaApp.class, descriptionKey = "label.irs.information", path = "irs-declaration",
        titleKey = "label.irs.information")
@Mapping(module = "person", path = "/irsDeclaration", scope = "request", parameter = "method")
@Forwards(value = { @Forward(name = "edit.IRSDeclaration.link", path = "/person/editIRSDeclarationLink.jsp"),
        @Forward(name = "view.irsDocument.information", path = "/person/irs/irsDocumentInformation.jsp") })
public class IRSDeclarationAction extends FenixDispatchAction {

    public static class IRSDeclarationBean implements Serializable {
        MultiLanguageString title;
        Boolean available;
        String irsLink;

        public IRSDeclarationBean(IrsDeclarationLink irsDeclarationLink) {
            title = irsDeclarationLink.getTitle();
            available = irsDeclarationLink.getAvailable();
            irsLink = irsDeclarationLink.getIrsLink();
        }

        public MultiLanguageString getTitle() {
            return title;
        }

        public void setTitle(MultiLanguageString title) {
            this.title = title;
        }

        public Boolean getAvailable() {
            return available;
        }

        public void setAvailable(Boolean available) {
            this.available = available;
        }

        public String getIrsLink() {
            return irsLink;
        }

        public void setIrsLink(String irsLink) {
            this.irsLink = irsLink;
        }
    }

    public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
        final IrsDeclarationLink irsDeclarationLink = IrsDeclarationLink.getInstance();
        final IRSDeclarationBean declarationBean = new IRSDeclarationBean(irsDeclarationLink);
        request.setAttribute("declarationBean", declarationBean);
        return mapping.findForward("edit.IRSDeclaration.link");
    }

    public ActionForward editBean(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
        final IRSDeclarationBean declarationBean = getRenderedObject("declarationBean");
        IrsDeclarationLink.set(declarationBean.getTitle(), declarationBean.getAvailable(), declarationBean.getIrsLink());
        return mapping.findForward("edit.IRSDeclaration.link");
    }

    @EntryPoint
    public ActionForward viewIrsDocumentInformation(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) {
        request.setAttribute("loggedPerson", AccessControl.getPerson());

        return mapping.findForward("view.irsDocument.information");
    }

}
TOP

Related Classes of org.fenixedu.academic.ui.struts.action.person.IRSDeclarationAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.