package q02b.cuestionarioVAPM.router;





//import java.util.ArrayList;

import java.util.HashMap;

//import org.apache.struts.action.ActionError;

import org.apache.struts.action.ActionErrors;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;



import q02b.exe.cuestionarioVAPM.valueobjects.Q02bCuestionarioVAPMFiltro;

import q02b.exe.utils.Q02bVoUtils;

import q02b.exe.utils.Q02bFormatData;



import es.ejie.frmk.presentacion.operacion.Q70DefaultRouterClass;

import es.ejie.frmk.presentacion.sesiondatos.Q70ContextoEJIE;

//import es.ejie.frmk.infraestructura.traza.Q70TraceLevel;

//import es.ejie.frmk.infraestructura.traza.Q70Traza;



public class Q02bRouterObtenerGrupoCuestionarioVAPM extends Q70DefaultRouterClass {

	

	//private static Q70Traza tr = Q70Traza.getSingleton();

	//private static final String COMPONENTE = "Q70_ROUTERCLASS";

	

	final static String VARIABLE_FILTRO= "filtro";

	final static String VARIABLE_NI_GRUPO= "niCuesVAPM";

	final static String VARIABLE_INICIO= "inicio";

	final static String VARIABLE_PORTADA= "JSP_PORTADA";

	final static String  MAPPING_ERROR_FILTRO_NULO= "error.oi.obtenerCuestionarioVAPM";

	

	final static String MAPPING_ERROR = "error";

	final static String MAPPING_SIN_LICENCIAS_MES = "noLicenMes";

	final static String MAPPING_LISTA="irObtener";

	final static String MAPPING_PORTADAVTM="irPortadaVAPM";

	

	//final static String MAPPING_ERROR_NO_CUES= "error.oi.noCuestionariosSMAnu";

	

	

		/**

		 * @see es.ejie.frmk.presentacion.operacion.paso.ActionPasoOP#processForward(es.ejie.frmk.presentacion.sesiondatos.ContextoEJIE, org.apache.struts.action.ActionErrors, org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

		 */  

	public  ActionForward processForward(Q70ContextoEJIE contexto,ActionErrors errores,ActionMapping mapping) throws Exception 

	{    

			ActionForward salida = new ActionForward();			

			Q02bCuestionarioVAPMFiltro cuestionarioVAPMFiltro= null;

			String concedeLicen = null;

			//HashMap cuestionarioSMAnu = new HashMap();			

			HashMap mapaCuestionarioVAPMFiltro = (HashMap)contexto.get(VARIABLE_FILTRO); 

			String niCuesVAPM = (String)contexto.get(VARIABLE_NI_GRUPO);

			String inicio = (String)contexto.get(VARIABLE_INICIO);



			

			if((Q02bFormatData.esNull(inicio)).equals(VARIABLE_PORTADA)){

				salida = mapping.findForward(MAPPING_PORTADAVTM);	

			}

			else{

				if (mapaCuestionarioVAPMFiltro != null)

				{

					cuestionarioVAPMFiltro = (Q02bCuestionarioVAPMFiltro)Q02bVoUtils.getValueObject(mapaCuestionarioVAPMFiltro,"q02b.exe.cuestionarioVAPM.valueobjects.Q02bCuestionarioVAPMFiltro");

					concedeLicen =	Q02bFormatData.checkStringNull(cuestionarioVAPMFiltro.getConcedidoLicen());

					

					if(concedeLicen.equals("1"))

					{

						if(Q02bFormatData.esVacio(niCuesVAPM))

						{

							salida = mapping.findForward(MAPPING_ERROR);	

							//errores.add("filtrar",new ActionError(MAPPING_ERROR_FILTRO_NULO));

						}

						else{

							salida = mapping.findForward(MAPPING_LISTA);	
                        }
							

					}

					else{

						salida = mapping.findForward(MAPPING_SIN_LICENCIAS_MES);	
                    }
				}

				else

				{

					salida = mapping.findForward(MAPPING_ERROR);	

					//errores.add("filtrar",new ActionError(MAPPING_ERROR_FILTRO_NULO));

				}

				

			}

				

				return salida;

	}

}

