
import java.math.BigDecimal;

import com.softwareag.entirex.aci.Broker;
import com.softwareag.entirex.aci.BrokerException;

/**
 * <p>Titre : Jwlwtpl1Web</p>
 * <p>Description : Classe de type de prestataire</p>
 * <p>Copyright : Copyright (c) 2009</p>
 * <p>Societe : ENSOR</p>
 * @author AR & DR & PY <i>06/04/2012</i>
 * @version 1.0
 */
public class Jwlwtpl1Web {	

		private static String PRINT = "NO";
		/**
		 * <p>Titre : getTypesPrestataire</p>
		 * <p>Description : Récupération de l'objet Liste des type de prestataire</p>
		 * <p>Copyright : Copyright (c) 2012</p>
		 * <p>Societe : ENSOR</p>
		 * @author AR & DR & PY <i>06/04/2012</i>
		 * @version 1.0
		 */
		public static Jwlwtpl1 getTypesPrestataire(
			String nbrep,
			String page,
			String fonction,
			String cd_tpe,
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
			// Initialisation des variables en entrees
	     	Jwlwtpl1 jwlwtpl1 = new Jwlwtpl1(broker, Constantes.SERVER_ADRESSE);
			
			// Initialisation de la vWebent depuis les informations de connexion
			Jwlwtpl1.Nwlwtpl1Axwebent vWebent = jwlwtpl1.new Nwlwtpl1Axwebent();
			vWebent.dbid 		   		= new BigDecimal (Constantes.DBID);
			vWebent.cible_exploitant 	= Constantes.CD_CIBLE;
			vWebent.groupe_exploitant 	= groupe_exploitant;
			vWebent.numero_session 		= new BigDecimal (numero_session);
			vWebent.utilisateur 		= utilisateur;
			vWebent.transaction 		= "WLWFPLST";
			vWebent.fonction 			= fonction;
			vWebent.cd_cible 			= cd_cible;
			vWebent.cd_stegrp 			= cd_stegrp;
			vWebent.cd_application 		= Constantes.CD_APPLICATION;
			jwlwtpl1.setNwlwtpl1Axwebent (vWebent);
	        
			// Initialisation des paramètres de pagination
			Jwlwtpl1.Nwlwtpl1Axweblst vWeblst = jwlwtpl1.new Nwlwtpl1Axweblst();
			vWeblst.nb_rep_souhait 		      = new BigDecimal(nbrep);
			vWeblst.num_page_souhait   		  = new BigDecimal(page);
			jwlwtpl1.setNwlwtpl1Axweblst (vWeblst);

			// Initialisation des critères (tous à vide pour l'instant)
			Jwlwtpl1.Nwlwtpl1Awlwtpl1 vLwtpl1 		        					 = jwlwtpl1.new Nwlwtpl1Awlwtpl1();
			Jwlwtpl1.Nwlwtpl1Awlwtpl1Demande vLwtpl1Demande 					 = jwlwtpl1.new Nwlwtpl1Awlwtpl1Demande();
			Jwlwtpl1.Nwlwtpl1Awlwtpl1DemandeCritere_select vLwtpl1DemandeCritere = jwlwtpl1.new Nwlwtpl1Awlwtpl1DemandeCritere_select();
			
			vLwtpl1DemandeCritere.cd_tpe  = cd_tpe;
			vLwtpl1Demande.critere_select = vLwtpl1DemandeCritere;
			vLwtpl1.demande = vLwtpl1Demande;
			
			jwlwtpl1.setNwlwtpl1Awlwtpl1 (vLwtpl1);
			
		    // CALL SERVER
		    jwlwtpl1.nwlwtpl1();
				                                
	        // Verification du code retour
			vWebent = jwlwtpl1.getNwlwtpl1Axwebent();
			System.out.println("Code retour nwlwtpl1() = " + vWebent.code_retour.intValue());
			
			if(vWebent.code_retour.intValue() != 0){
				for(int i=0; i < vWebent.nb_ano.intValue(); i++){
				   System.out.println(vWebent.t_ano[i].code_ano + "[" + vWebent.t_ano[i].type_ano + "] : '" + vWebent.t_ano[i].lib_ano.trim() + "'");
			   	   }
				}
			else {
				//Récupération du résultat si code retour OK
				Jwlwtpl1.Nwlwtpl1Awlwtpl1_tab vWeblsttab = jwlwtpl1.getNwlwtpl1Awlwtpl1_tab();
				
				//Affichage de la liste des résultats
				if(PRINT == "YES") {
					for(int i = 0; i < new BigDecimal(nbrep).intValue(); i++){
							System.out.println ("cd_cible =" + vWeblsttab.ligne_ref[i].cd_tpe
									+ ";num_cli=" 		  	 + vWeblsttab.ligne_ref[i].cd_tdi 
									+ ";num_voie=" 		  	 + vWeblsttab.ligne_ref[i].tpe_libelle
									+ ";voie=" 		  		 + vWeblsttab.ligne_ref[i].tpe_ind_coiffe 
									
							);
							System.out.println("\n");
					}
					//Affichage des informations de pagination
					System.out.println ("nb_rep_rendues : "    + jwlwtpl1.getNwlwtpl1Axweblst().nb_rep_rendues);
					System.out.println ("num_page_rendue : "   + jwlwtpl1.getNwlwtpl1Axweblst().num_page_rendue);
					System.out.println ("top_page_suivante : " + jwlwtpl1.getNwlwtpl1Axweblst().top_page_suivante);
					System.out.println ("nb_pages_totales : "  + jwlwtpl1.getNwlwtpl1Axweblst().nb_pages_totales);
				}
			}
			return jwlwtpl1;
			
	   } // End getTypesPrestataire

		/**
		 * <p>Titre : main</p>
		 * <p>Description : Programme principal de tests</p>
		 * <p>Copyright : Copyright (c) 2012</p>
		 * <p>Societe : ENSOR</p>
		 * @author AR & DR & PY <i>06/04/2012</i>
		 * @version 1.0
		 */
	   	public static void main(String[] args) throws BrokerException {
			Constantes.loadProperties("LW") ;
			JxweblogWeb.setUtilisateur ("MADAA01");
			JxweblogWeb.setPassword ("MADAA01");
			Broker broker 	  = JxweblogWeb.logonBroker();
			Jxweblog jxweblog = JxweblogWeb.getConnexion(broker);
			PRINT = "YES";
			
			Jxweblog.NxweblogAxwebent connexion = jxweblog.getNxweblogAxwebent();
			String groupe_exploitant 			= connexion.groupe_exploitant;
			String numero_session 				= Integer.toString(connexion.numero_session.intValue());
			String utilisateur 					= connexion.utilisateur;
			String cd_cible 					= connexion.cd_cible;
			String cd_stegrp 					= connexion.cd_stegrp;
			
			getTypesPrestataire ( "15", "1", "I",
						"TESTZA", 
						groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp,broker);
						JxweblogWeb.closeConnexion (jxweblog);
	   }
} // END Jwlwdil1Php