Subversion Repositories bacoAlunos

Rev

Rev 857 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.web.form.processes;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.upload.FormFile;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.MetaProcess;
import pt.estgp.estgweb.domain.MetaProcessImpl;
import pt.estgp.estgweb.utils.StringsUtils;
import pt.estgp.estgweb.web.form.ApplicationForm;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jorge Machado
 * @date 25/Jun/2008
 * @see pt.estgp.estgweb.web.form.courses
 */

public class NewMetaProcessForm extends ApplicationForm
{

    private MetaProcessImpl metaProcess;
    private FormFile file;
    private 1.5.0/docs/api/java/lang/String.html">String fileName;


    private 1.5.0/docs/api/java/lang/String.html">String personToAdd;
    private 1.5.0/docs/api/java/lang/String.html">String personToRemove;
    private 1.5.0/docs/api/java/lang/String.html">String roleToAdd;
    private 1.5.0/docs/api/java/lang/String.html">String roleToRemove;



    public NewMetaProcessForm()
    {
        metaProcess = DomainObjectFactory.createMetaProcessImpl();
    }

    public 1.5.0/docs/api/java/lang/String.html">String getFileName() {
        return fileName;
    }

    public void setFileName(1.5.0/docs/api/java/lang/String.html">String fileName) {
        this.fileName = fileName;
    }


    public FormFile getFile() {
        return file;
    }

    public void setFile(FormFile file) {
        this.file = file;
    }

    public MetaProcessImpl getMetaProcess() {
        return metaProcess;
    }

    public void setMetaProcess(MetaProcessImpl metaProcess) {
        this.metaProcess = metaProcess;
    }


    public 1.5.0/docs/api/java/lang/String.html">String getPersonToRemove() {
        return personToRemove;
    }

    public void setPersonToRemove(1.5.0/docs/api/java/lang/String.html">String personToRemove) {
        this.personToRemove = personToRemove;
    }

    public 1.5.0/docs/api/java/lang/String.html">String getRoleToRemove() {
        return roleToRemove;
    }

    public void setRoleToRemove(1.5.0/docs/api/java/lang/String.html">String roleToRemove) {
        this.roleToRemove = roleToRemove;
    }

    public List<String> getPossiblePersons()
    {
        if(metaProcess.getPossiblePersons() != null && metaProcess.getPossiblePersons().length()>0)
        {
            return StringsUtils.getStringsFromSerial(metaProcess.getPossiblePersons(),";");
        }
        return new ArrayList<String>();
    }

    public List<String> getPossibleTargets()
    {
        if(metaProcess.getPossibleTargets() != null && metaProcess.getPossibleTargets().length()>0)
        {
            return StringsUtils.getStringsFromSerial(metaProcess.getPossibleTargets(),";");
        }
        return new ArrayList<String>();
    }

    public 1.5.0/docs/api/java/lang/String.html">String getPersonToAdd() {
        return personToAdd;
    }

    public void setPersonToAdd(1.5.0/docs/api/java/lang/String.html">String personToAdd) {
        this.personToAdd = personToAdd;
    }
    public List<String> getAddedPersonsList()
    {
        return StringsUtils.getStringsFromSerial(getMetaProcess().getPossiblePersons(),";");
    }


    public 1.5.0/docs/api/java/lang/String.html">String getRoleToAdd() {
        return roleToAdd;
    }

    public void setRoleToAdd(1.5.0/docs/api/java/lang/String.html">String roleToAdd) {
        this.roleToAdd = roleToAdd;
    }



    public List<String> getAddedRolesList()
    {
        return StringsUtils.getStringsFromSerial(getMetaProcess().getPossibleTargets(),";");
    }

    public ActionErrors validate(org.apache.struts.action.ActionMapping actionMapping, javax.servlet.http.HttpServletRequest httpServletRequest)
    {
        ActionErrors errors = new ActionErrors();
        if(fileName==null || fileName.length()==0)
        {
            addMessage(errors, httpServletRequest, "errors.required","ficheiro");
        }
        if(metaProcess.getCategory()==null || metaProcess.getCategory().length()==0)
        {
            addMessage(errors, httpServletRequest, "errors.required","categoria");
        }
        if(metaProcess.getSubCategory()==null || metaProcess.getSubCategory().length()==0)
        {
            addMessage(errors, httpServletRequest, "errors.required","subcategoria");
        }
        if(metaProcess.getTargetRole()==null || metaProcess.getTargetRole().length()==0)
        {
            addMessage(errors, httpServletRequest, "errors.required","Atendido por");
        }
        if(metaProcess.getSrcRole()==null || metaProcess.getSrcRole().length()==0)
        {
            addMessage(errors, httpServletRequest, "errors.required","Tipo de requerente");
        }
        if(metaProcess.getName()==null || metaProcess.getName().length()==0)
        {
            addMessage(errors, httpServletRequest, "errors.required","Nome do MetaProcesso");
        }

        if((metaProcess.getPossiblePersons()==null || metaProcess.getPossibleTargets().length()==0)
                &&
                ( metaProcess.getPossibleTargets()==null || metaProcess.getPossibleTargets().length()==0))
        {
            addMessage(errors, httpServletRequest, "errors.required","Intervenientes");
        }


        return errors;
    }

}