package q02b.agentes.router;



import org.apache.struts.action.ActionErrors;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;



import q02b.exe.utils.Q02bFormatData;



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

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

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



public class Q02bRouterAfterInsertAgente extends Q70DefaultRouterClass{



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

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

	

	final static String VARIABLE_ACCION= "accion";

	final static String VARIABLE_GUARDAR= "KEY_GUARDAR";

	final static String VARIABLE_REPETIR= "KEY_GUARDAR_REPETIR";	

	final static String VARIABLE_INICIO= "inicio";

	final static String VARIABLE_FILTRO= "FILTRO";

	

	final static String MAPPING_ERROR = "error";

	final static String MAPPING_LISTADO="irListadoAgentes";

	final static String MAPPING_ALTA="irRepetirAlta";

	final static String MAPPING_FILTRO="irFiltroAgentes";

	final static String VARIABLE_ID_AGENTE = "idAgente";

	final static String MAPPING_MODIFICAR="irModificarAgente";

	

	

	

	

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

	{    

			ActionForward salida = new ActionForward();			

			String accion = (String)contexto.get(VARIABLE_ACCION);

			String idAgente = (String)contexto.get(VARIABLE_ID_AGENTE); 

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

			

			if(Q02bFormatData.esVacio(idAgente)){

				salida = mapping.findForward(MAPPING_ERROR);

			}

			else if(accion.equals(VARIABLE_REPETIR)){

				salida = mapping.findForward(MAPPING_ALTA);

			}

			else if(accion.equals(VARIABLE_GUARDAR)){

				/*if (inicio.equals(VARIABLE_FILTRO))					

					salida = mapping.findForward(MAPPING_FILTRO);

				else

					salida = mapping.findForward(MAPPING_LISTADO);*/

				salida = mapping.findForward(MAPPING_MODIFICAR);

					

			}

			return salida;

	}

}

