package q02b.cuestionariosSMAnu.action;



import java.util.ArrayList;

//import java.util.HashMap;



import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;



import org.apache.struts.action.ActionErrors;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;



import q02b.exe.cuestionariosSMAnu.valueobjects.Q02bCuestionarioSM;

//import q02b.exe.utils.Q02bVoUtils;

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

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

import es.ejie.frmk.presentacion.operacion.paso.Q70ActionPasoOP;

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





/**

 * @version 1.0

 * Fecha: 08-mar-04

 */

public class Q02bActionTodosFirmadosCuestionariosSM extends Q70ActionPasoOP {

	private static Q70Traza tr = Q70Traza.getSingleton();

	private static final String COMPONENTE = "ACTION PASOOP";

	final static String MAPPING_OK = "ok";

	final static String TRACE_METODO_FW= "processForward";

	final static String NO_HAY_DATOS = "NoHayCuestionariosSMAnu";

	/**

	 * @see es.ejie.frmk.presentacion.operacion.paso.ActionPasoOP#processOP(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)

	 */

	protected void processOP(

   

		Q70ContextoEJIE contexto,

		ActionErrors errores,

		ActionMapping mapping,

		ActionForm form,

		HttpServletRequest request,

		HttpServletResponse response)

		throws Exception {



		//Recogida de atributos del contexto de OP

		

		ArrayList listaCuestionariosSMAnu = (ArrayList)contexto.get("listaCuestionariosSMAnu");

		String firmado = "true";		

    	Q02bCuestionarioSM cuesSMAnu = null;    	

    	String firma = null;    	

    	if (listaCuestionariosSMAnu.size() != 0)

    	{

			for (int i=0; i < listaCuestionariosSMAnu.size();i++)

			{

				cuesSMAnu = (Q02bCuestionarioSM)listaCuestionariosSMAnu.get(i);

				firma = cuesSMAnu.getFirmado();

				if (firma.equals("0"))

				{

					firmado = "false";

				}			

			}

    	}

    	else

    	{

    		firmado = "false";

    	}

		

		if (tr.isTraceActive()){

  			tr.trace(COMPONENTE, Q70TraceLevel.INFO, this.getClass().getName() + ":todosFirmadosCuestionariosSMAnu: entrando");

  		}

	

		contexto.set("todosFirmadosSMAnu", firmado);

		

		

		

	}



	/**

	 * @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)

	 */

	protected ActionForward processForward(

		Q70ContextoEJIE contexto,

		ActionErrors errores,

		ActionMapping mapping,

		ActionForm form,

		HttpServletRequest request,

		HttpServletResponse response)

		throws Exception {

		if (tr.isTraceActive()){

			tr.trace(COMPONENTE, Q70TraceLevel.INFO, this.getClass().getName() + TRACE_METODO_FW + " :entrando");

		}

		ActionForward salida = new ActionForward();

		salida = mapping.findForward(MAPPING_OK);

		return salida;

	}



}

