import java.math.BigDecimal;

import com.softwareag.entirex.aci.Broker;
import com.softwareag.entirex.aci.BrokerException;

/**
* <p>Titre : Jwlwvol1Web</p>
* <p>Description : Consultation , Liste des voies </p>
* <p>Copyright : Copyright (c) 2013</p>
* <p>Societe : ENSOR</p>
* @author AR & DR & PY <i>23/01/2013</i>
* @version 1.0
 */
public class Jwlwvol1Web {	

		private static String PRINT = "NO";
		/**
		 * <p>Titre : getListeVoies </p>
		 * <p>Description : Consultation , Liste des voies </p>
		 * <p>Copyright : Copyright (c) 2013</p>
		 * <p>Societe : ENSOR</p>
		 * @author AR & DR & PY <i>23/01/2013</i>
		 * @version 1.0
		 */
		public static Jwlwvol1 getListeVoies (
			String nbrep,
			String page,
			String fonction,
			String f_cd_insee,
			String f_localite,
			String f_mot_directeur,
			String f_matricule_mere_org,
			String f_filtre_type,
			String f_filtre_cd_zpo,
			String f_filtre_ordo,
			String f_filtre_zone,
			String f_top_ts,
			String f_top_liste_2,		
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
			// Initialisation des variables en entrees
	     	Jwlwvol1 jwlwvol1 = new Jwlwvol1(broker, Constantes.SERVER_ADRESSE);
			// Initialisation de la vWebent depuis les informations de connexion
			Jwlwvol1.Nwlwvol1Axwebent vWebent = jwlwvol1.new Nwlwvol1Axwebent();
			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 	  = "WLWCLLST";
			vWebent.fonction 		  = fonction;
			vWebent.cd_cible 		  = cd_cible;
			vWebent.cd_stegrp 		  = cd_stegrp;
			vWebent.cd_application 	  = Constantes.CD_APPLICATION;
			jwlwvol1.setNwlwvol1Axwebent (vWebent);
	        
			// Initialisation des parametres de pagination
			Jwlwvol1.Nwlwvol1Axweblst vWeblst = jwlwvol1.new Nwlwvol1Axweblst();
			vWeblst.nb_rep_souhait 			  = new BigDecimal(nbrep);
			vWeblst.num_page_souhait 		  = new BigDecimal(page);
			jwlwvol1.setNwlwvol1Axweblst (vWeblst);

			// Initialisation des criteres (tous a vide pour l instant)
			Jwlwvol1.Nwlwvol1Awlwvol1 vLwvol1 = jwlwvol1.new Nwlwvol1Awlwvol1();
			Jwlwvol1.Nwlwvol1Awlwvol1Demande vLwvol1Demande = jwlwvol1.new Nwlwvol1Awlwvol1Demande();
			
			Jwlwvol1.Nwlwvol1Awlwvol1DemandeCritere_select vLwvol1DemandeCritere = jwlwvol1.new Nwlwvol1Awlwvol1DemandeCritere_select();
			
            vLwvol1DemandeCritere.f_cd_insee 	   = f_cd_insee;
            vLwvol1DemandeCritere.f_localite  	   = f_localite;
            vLwvol1DemandeCritere.f_mot_directeur  = f_mot_directeur;
            vLwvol1DemandeCritere.f_filtre_type    = f_filtre_type;
            vLwvol1DemandeCritere.f_filtre_cd_zpo  = f_filtre_cd_zpo;
            vLwvol1DemandeCritere.f_filtre_ordo    = f_filtre_ordo;
            vLwvol1DemandeCritere.f_filtre_zone    = f_filtre_zone;
            vLwvol1DemandeCritere.f_top_ts    	   = f_top_ts;
            vLwvol1DemandeCritere.f_top_liste_2    = f_top_liste_2;
			if(!"".equals(f_matricule_mere_org) && f_matricule_mere_org!=null){
				vLwvol1DemandeCritere.f_matricule_mere_org = new BigDecimal(f_matricule_mere_org);
			}			

			vLwvol1Demande.critere_select = vLwvol1DemandeCritere;
			vLwvol1.demande = vLwvol1Demande;

			jwlwvol1.setNwlwvol1Awlwvol1 (vLwvol1);
			
		    // CALL SERVER
		    jwlwvol1.nwlwvol1();
				                                
	        // Verification du code retour
			vWebent = jwlwvol1.getNwlwvol1Axwebent();
			System.out.println("Code retour nwlwvol1() = " + 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 {
				//Recuperation du resultat si code retour OK
				Jwlwvol1.Nwlwvol1Awlwvol1_tab vWeblsttab = jwlwvol1.getNwlwvol1Awlwvol1_tab();
				System.out.println("code retour  "+vWeblsttab.code_retour.intValue());
				System.out.println(vWebent.t_ano[0].lib_ano.trim());
				//Affichage de la liste des resultats
				if(PRINT == "YES") {
					
					System.out.println("\n");
					for(int i = 0; i < new BigDecimal(nbrep).intValue(); i++){
							System.out.println (
									  "  mot_dir_voie="	    + vWeblsttab.ligne_ref[i].mot_dir_voie 
									+ "; libelle_voie="  	+ vWeblsttab.ligne_ref[i].libelle_voie
									+ "; code_postal="  	+ vWeblsttab.ligne_ref[i].code_postal 
									+ "; bureau_dis=" 	 	+ vWeblsttab.ligne_ref[i].bureau_dis
									+ "; matricule_voie=" 	+ vWeblsttab.ligne_ref[i].matricule_voie
									+ "; matricule_cible=" 	+ vWeblsttab.ligne_ref[i].matricule_cible 
									+ "; top_voie_mere=" 	+ vWeblsttab.ligne_ref[i].top_voie_mere
									+ "; type_portage_ntr=" + vWeblsttab.ligne_ref[i].type_portage_ntr
									); 
							System.out.println("\n");
					}
					//Affichage des informations de pagination
					System.out.println ("nb_rep_rendues : "    + jwlwvol1.getNwlwvol1Axweblst().nb_rep_rendues);
					System.out.println ("num_page_rendue : "   + jwlwvol1.getNwlwvol1Axweblst().num_page_rendue);
					System.out.println ("top_page_suivante : " + jwlwvol1.getNwlwvol1Axweblst().top_page_suivante);
					System.out.println ("nb_pages_totales : "  + jwlwvol1.getNwlwvol1Axweblst().nb_pages_totales);
				}
			}
			return jwlwvol1;
			
	   } // End getListeVoies 
/**
***/
	   public static Jwlwvol1 getListeVoiesMultiple (
			String nbrep,
			String page,
			String fonction,
			String f_cd_insee,
			String f_localite,
			String f_mot_directeur,
			String f_matricule_mere_org,
			String f_localite_org,
			String f_mot_directeur_org,
			String f_cd_insee_org,
			String f_bur_distr_org,
			String f_cd_postal_org,
			String f_libelle_voie_org,
			String f_matricule_voie_org,	
			String f_voi_id_org,
			String f_top_ts,
			String f_top_liste_2,				
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
			// Initialisation des variables en entrees
	     	Jwlwvol1 jwlwvol1 = new Jwlwvol1(broker, Constantes.SERVER_ADRESSE);
			// Initialisation de la vWebent depuis les informations de connexion
			Jwlwvol1.Nwlwvol1Axwebent vWebent = jwlwvol1.new Nwlwvol1Axwebent();
			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 	  = "WLWCLLST";
			vWebent.fonction 		  = fonction;
			vWebent.cd_cible 		  = cd_cible;
			vWebent.cd_stegrp 		  = cd_stegrp;
			vWebent.cd_application 	  = Constantes.CD_APPLICATION;
			jwlwvol1.setNwlwvol1Axwebent (vWebent);
	        
			// Initialisation des parametres de pagination
			Jwlwvol1.Nwlwvol1Axweblst vWeblst = jwlwvol1.new Nwlwvol1Axweblst();
			vWeblst.nb_rep_souhait 			  = new BigDecimal(nbrep);
			vWeblst.num_page_souhait 		  = new BigDecimal(page);
			jwlwvol1.setNwlwvol1Axweblst (vWeblst);

			// Initialisation des criteres (tous a vide pour l instant)
			Jwlwvol1.Nwlwvol1Awlwvol1 vLwvol1 = jwlwvol1.new Nwlwvol1Awlwvol1();
			Jwlwvol1.Nwlwvol1Awlwvol1Demande vLwvol1Demande = jwlwvol1.new Nwlwvol1Awlwvol1Demande();			  
			Jwlwvol1.Nwlwvol1Awlwvol1DemandeCritere_select vLwvol1DemandeCritere = jwlwvol1.new Nwlwvol1Awlwvol1DemandeCritere_select();
			
			 vLwvol1DemandeCritere.f_cd_insee 	   = f_cd_insee;
            vLwvol1DemandeCritere.f_localite  	   = f_localite;
            vLwvol1DemandeCritere.f_mot_directeur  = f_mot_directeur;
			if(!"".equals(f_matricule_mere_org) && f_matricule_mere_org!=null){
				vLwvol1DemandeCritere.f_matricule_mere_org = new BigDecimal(f_matricule_mere_org);
			}
			if(!"".equals(f_matricule_voie_org) && f_matricule_voie_org!=null){
				vLwvol1DemandeCritere.f_matricule_voie_org = new BigDecimal(f_matricule_voie_org);
			}
			if(!"".equals(f_voi_id_org) && f_voi_id_org!=null){
				vLwvol1DemandeCritere.f_voi_id_org = new BigDecimal(f_voi_id_org);
			}
			
            vLwvol1DemandeCritere.f_localite_org 	   = f_localite_org;
            vLwvol1DemandeCritere.f_mot_directeur_org  	   = f_mot_directeur_org;
            vLwvol1DemandeCritere.f_cd_insee_org  = f_cd_insee_org;
            vLwvol1DemandeCritere.f_bur_distr_org    = f_bur_distr_org;
            vLwvol1DemandeCritere.f_cd_postal_org  = f_cd_postal_org;
            vLwvol1DemandeCritere.f_libelle_voie_org    = f_libelle_voie_org;						
            vLwvol1DemandeCritere.f_top_ts    	   = f_top_ts;
            vLwvol1DemandeCritere.f_top_liste_2    = f_top_liste_2;   

			vLwvol1Demande.critere_select = vLwvol1DemandeCritere;
			vLwvol1.demande = vLwvol1Demande;

			jwlwvol1.setNwlwvol1Awlwvol1 (vLwvol1);
			
		    // CALL SERVER
		    jwlwvol1.nwlwvol1();
				                                
	        // Verification du code retour
			vWebent = jwlwvol1.getNwlwvol1Axwebent();
			System.out.println("Code retour nwlwvol1() = " + 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 {
				//Recuperation du resultat si code retour OK
				Jwlwvol1.Nwlwvol1Awlwvol1_tab vWeblsttab = jwlwvol1.getNwlwvol1Awlwvol1_tab();
				System.out.println("code retour  "+vWeblsttab.code_retour.intValue());
				System.out.println(vWebent.t_ano[0].lib_ano.trim());
				//Affichage de la liste des resultats
				if(PRINT == "YES") {
					
					System.out.println("\n");
					for(int i = 0; i < new BigDecimal(nbrep).intValue(); i++){
							System.out.println (
									"  top_select="	    + vWeblsttab.ligne_ref[i].top_select 
									 + "  mot_dir_voie="	    + vWeblsttab.ligne_ref[i].mot_dir_voie 
									+ "; libelle_voie="  	+ vWeblsttab.ligne_ref[i].libelle_voie
									+ "; code_postal="  	+ vWeblsttab.ligne_ref[i].code_postal 
									+ "; bureau_dis=" 	 	+ vWeblsttab.ligne_ref[i].bureau_dis
									+ "; matricule_voie=" 	+ vWeblsttab.ligne_ref[i].matricule_voie
									+ "; matricule_cible=" 	+ vWeblsttab.ligne_ref[i].matricule_cible 
									+ "; top_voie_mere=" 	+ vWeblsttab.ligne_ref[i].top_voie_mere
									+ "; type_portage_ntr=" + vWeblsttab.ligne_ref[i].type_portage_ntr
									); 
							System.out.println("\n");
					}
					//Affichage des informations de pagination
					System.out.println ("nb_rep_rendues : "    + jwlwvol1.getNwlwvol1Axweblst().nb_rep_rendues);
					System.out.println ("num_page_rendue : "   + jwlwvol1.getNwlwvol1Axweblst().num_page_rendue);
					System.out.println ("top_page_suivante : " + jwlwvol1.getNwlwvol1Axweblst().top_page_suivante);
					System.out.println ("nb_pages_totales : "  + jwlwvol1.getNwlwvol1Axweblst().nb_pages_totales);
				}
			}
			return jwlwvol1;
			
	   } // End getListeVoies 
	   
	   
		/**
		 * <p>Titre : main</p>
		 * <p>Description : Programme principal de tests</p>
		 * <p>Copyright : Copyright (c) 2013</p>
		 * <p>Societe : ENSOR</p>
		 * @author AR & DR & PY <i>23/01/2013</i>
		 * @version 1.0
		 */
	   	public static void main(String[] args) throws BrokerException {
			Constantes.loadProperties("LW") ;
			JxweblogWeb.setUtilisateur ("MADAA02");
			JxweblogWeb.setPassword ("MADAA12");
			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;
		
			//--------------------Donnee test------------------
			String nbrep 		   = "40";
			String page 		   = "1";
			String fonction 	   = "I";
			String f_cd_insee 	   = "75115";
			String f_localite 	   = null;
			String f_mot_directeur = "CARREL";
			String f_filtre_type   = null;
			String f_filtre_cd_zpo = null;
			String f_filtre_ordo   = null;
			String f_filtre_zone   = null;
			String f_top_ts		   = null;
			String f_top_liste_2   = "F";
			String f_matricule_mere_org = "101436174" ;
			getListeVoies(nbrep, page, fonction,
					f_cd_insee, f_localite, f_mot_directeur, f_matricule_mere_org, f_filtre_type, f_filtre_cd_zpo, 
					f_filtre_ordo, f_filtre_zone,f_top_ts, f_top_liste_2,
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			
			
			//--------------------Donnee test vois multiple------------------
			/*
			String f_matricule_mere_org = "1456880";
			String f_localite_org = "PARIS";
			String f_mot_directeur_org = "ABBAYE";
			String f_cd_insee_org = "75116";
			String f_bur_distr_org= "BUR";
			String f_cd_postal_org= "75116";
			String f_libelle_voie_org= "PARIS";
			String f_matricule_voie_org = "1456880";	
			String f_voi_id_org = null;
			//String f_top_ts = null;
			String f_top_liste_2 = "M";
			getListeVoiesMultiple (
			nbrep,page,fonction,f_cd_insee,f_localite, f_mot_directeur,f_matricule_mere_org,f_localite_org,f_mot_directeur_org,f_cd_insee_org,f_bur_distr_org,
			f_cd_postal_org,f_libelle_voie_org,f_matricule_voie_org,f_voi_id_org, f_top_ts,f_top_liste_2,		
			groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);*/
			//--------------------Donnee test------------------
			JxweblogWeb.closeConnexion (jxweblog);
	   }
} // END Jwlwvol1Web