import java.math.BigDecimal;

import com.softwareag.entirex.aci.Broker;
import com.softwareag.entirex.aci.BrokerException;

/**
 * <p>Titre : Jwlwtnm1Web</p>
 * <p>Description : Modification des tournees.
	* </p>
 * <p>Copyright : Copyright (c) 2013</p>
 * <p>Societe : ENSOR</p>
 * @author AR & DR & PY <i>06/02/2013</i>
 * @version 1.0
 */
 
public class Jwlwtnm1Web {

	/**
	 * <p>Titre : createTournee</p>
	 * <p>Copyright : Copyright (c) 2013</p>
	 * <p>Societe : ENSOR</p>
	 * @author AR & DR & PY <i>19/02/2013</i>
	 * @version 1.0
	 */
	public static Jwlwtnm1 createTournee(
				String f_cd_zpo_creat,
				String f_type_portage_creat,
				String f_tpr_groupe_creat,
				String f_tpr_num_creat,
				String f_tpr_libelle_creat,
				String groupe_exploitant,
				String numero_session,
				String utilisateur,
				String cd_cible,
				String cd_stegrp,
				Broker broker) throws BrokerException {
		// Initialisation des variables en entrees
	    Jwlwtnm1 jwlwtnm1 = new Jwlwtnm1(broker, Constantes.SERVER_ADRESSE);
			
		// Initialisation de la vWebent depuis les informations de connexion
		Jwlwtnm1.Nwlwtnm1Axwebent vWebent = jwlwtnm1.new Nwlwtnm1Axwebent();
		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 	  = "WLWSTLST";
		vWebent.fonction 		  = "CREAT";
		vWebent.cd_cible 		  = cd_cible;
		vWebent.cd_stegrp 		  = cd_stegrp;
		vWebent.cd_application 	  = Constantes.CD_APPLICATION;
		jwlwtnm1.setNwlwtnm1Axwebent (vWebent);
		
		// Initialisation de la demande (tous a vide pour l instant)
		Jwlwtnm1.Nwlwtnm1Awlwtnm1 vLwtnm1 					= jwlwtnm1.new Nwlwtnm1Awlwtnm1();
		Jwlwtnm1.Nwlwtnm1Awlwtnm1Creation vLwtnm1Creation = jwlwtnm1.new Nwlwtnm1Awlwtnm1Creation();
		
		vLwtnm1Creation.f_cd_zpo_creat			= f_cd_zpo_creat;
		vLwtnm1Creation.f_type_portage_creat	= f_type_portage_creat;
		vLwtnm1Creation.f_tpr_groupe_creat		= f_tpr_groupe_creat;
		vLwtnm1Creation.f_tpr_num_creat			= f_tpr_num_creat;
		vLwtnm1Creation.f_tpr_libelle_creat		= f_tpr_libelle_creat;
	
		vLwtnm1.creation = vLwtnm1Creation;
		
		jwlwtnm1.setNwlwtnm1Awlwtnm1(vLwtnm1);
		
		// CALL SERVER
		jwlwtnm1.nwlwtnm1();
		
		// Verification du code retour
		vWebent = jwlwtnm1.getNwlwtnm1Axwebent();
		System.out.println("Code retour nwlwtnm1() = " + 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{
			System.out.println(vWebent.t_ano[0].lib_ano.trim());
			//affichage de reponse
			System.out.println("suite normal...");
		}
		return jwlwtnm1;
	   } // End createTournee
	   
	//FIN  CREATION
	
	
	   
	//FIN  COPIE
	
	
	   
	//FIN  TRANSFERT
	
	
	/**
	 * <p>Titre : setTournee</p>
	 * <p>Copyright : Copyright (c) 2013</p>
	 * <p>Societe : ENSOR</p>
	 * @author AR & DR & PY <i>08/02/2013</i>
	 * @version 1.0
	 */
	public static Jwlwtnm1 setTournee(
		String f_cd_zpo_org[],
		String f_type_portage_org[],
		String f_tpr_groupe_org[],
		String f_tpr_num_org[],
		String f_tpr_libelle_org[],
		String groupe_exploitant,
		String numero_session,
		String utilisateur,
		String cd_cible,
		String cd_stegrp,
		Broker broker) throws BrokerException {
		// Initialisation des variables en entrees
	    Jwlwtnm1 jwlwtnm1 		  = new Jwlwtnm1(broker, Constantes.SERVER_ADRESSE);	
		// Initialisation de la vWebent depuis les informations de connexion
		Jwlwtnm1.Nwlwtnm1Axwebent vWebent = jwlwtnm1.new Nwlwtnm1Axwebent();
		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 	  = "WLWSTLST";
		vWebent.fonction 		  = "MODIF";
		vWebent.cd_cible 		  = cd_cible;
		vWebent.cd_stegrp 		  = cd_stegrp;
		vWebent.cd_application 	  = Constantes.CD_APPLICATION;
		jwlwtnm1.setNwlwtnm1Axwebent (vWebent);
		
		// Initialisation de la demande (tous a vide pour l instant)
		Jwlwtnm1.Nwlwtnm1Awlwtnm1 vLwtnm1 				= jwlwtnm1.new Nwlwtnm1Awlwtnm1();
		Jwlwtnm1.Nwlwtnm1Awlwtnm1Demande vLwtnm1Demande = jwlwtnm1.new Nwlwtnm1Awlwtnm1Demande();
		
		int len = f_cd_zpo_org.length ;
		String[] tab_cd_zpo_org 	  = new String[50] ;
		String[] tab_type_portage_org = new String[50] ;
		String[] tab_tpr_groupe_org   = new String[50] ;
		String[] tab_tpr_num_org 	  = new String[50] ;
		String[] tab_tpr_libelle_org  = new String[50] ;
		for (int i = 0; i < len; i++) {
			tab_cd_zpo_org[i] = f_cd_zpo_org[i] ;
			tab_type_portage_org[i] = f_type_portage_org[i] ;
			tab_tpr_groupe_org[i] = f_tpr_groupe_org[i] ;
			tab_tpr_num_org[i] = f_tpr_num_org[i] ;
			tab_tpr_libelle_org[i] = f_tpr_libelle_org[i] ;
		}
		vLwtnm1Demande.f_cd_zpo_org			= tab_cd_zpo_org;
		vLwtnm1Demande.f_type_portage_org	= tab_type_portage_org;
		vLwtnm1Demande.f_tpr_groupe_org		= tab_tpr_groupe_org;
		vLwtnm1Demande.f_tpr_num_org		= tab_tpr_num_org;
		vLwtnm1Demande.f_tpr_libelle_org	= tab_tpr_libelle_org;
	
		vLwtnm1.demande = vLwtnm1Demande;
		
		jwlwtnm1.setNwlwtnm1Awlwtnm1(vLwtnm1);
		
		// CALL SERVER
		jwlwtnm1.nwlwtnm1();
		
		// Verification du code retour
		vWebent = jwlwtnm1.getNwlwtnm1Axwebent();
		System.out.println("Code retour nwlwtnm1() = " + 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{
			//affichage de reponse		
			System.out.println(vWebent.t_ano[0].lib_ano.trim());
			System.out.println ("Suite normale ...");
		}
		
		return jwlwtnm1;
	   } // End setTournee
	
	/**
	 * <p>Titre : deleteTournee</p>
	 * <p>Copyright : Copyright (c) 2013</p>
	 * <p>Societe : ENSOR</p>
	 * @author AR & DR & PY <i>19/02/2013</i>
	 * @version 1.0
	 */
	public static Jwlwtnm1 deleteTournee(
		String f_cd_zpo_org[],
		String f_type_portage_org[],
		String f_tpr_groupe_org[],
		String f_tpr_num_org[],
		String f_tpr_choix_supp,
		String f_top_purge,
		String groupe_exploitant,
		String numero_session,
		String utilisateur,
		String cd_cible,
		String cd_stegrp,
		Broker broker) throws BrokerException {
		// Initialisation des variables en entrees
	    Jwlwtnm1 jwlwtnm1 		  = new Jwlwtnm1(broker, Constantes.SERVER_ADRESSE);	
		// Initialisation de la vWebent depuis les informations de connexion
		Jwlwtnm1.Nwlwtnm1Axwebent vWebent = jwlwtnm1.new Nwlwtnm1Axwebent();
		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 	  = "WLWSTLST";
		vWebent.fonction 		  = "SUPP";
		vWebent.cd_cible 		  = cd_cible;
		vWebent.cd_stegrp 		  = cd_stegrp;
		vWebent.cd_application 	  = Constantes.CD_APPLICATION;
		jwlwtnm1.setNwlwtnm1Axwebent (vWebent);
		
		// Initialisation de la demande (tous a vide pour l instant)
		Jwlwtnm1.Nwlwtnm1Awlwtnm1 vLwtnm1 				= jwlwtnm1.new Nwlwtnm1Awlwtnm1();
		Jwlwtnm1.Nwlwtnm1Awlwtnm1Supp vLwtnm1Supp = jwlwtnm1.new Nwlwtnm1Awlwtnm1Supp();
		Jwlwtnm1.Nwlwtnm1Awlwtnm1Demande vLwtnm1Demande = jwlwtnm1.new Nwlwtnm1Awlwtnm1Demande();
		
		int len = f_cd_zpo_org.length ;
		String[] tab_cd_zpo_org 	  = new String[50] ;
		String[] tab_type_portage_org = new String[50] ;
		String[] tab_tpr_groupe_org   = new String[50] ;
		String[] tab_tpr_num_org      = new String[50] ;
		
		for (int i = 0; i < len; i++) {
			tab_cd_zpo_org[i] 	    = f_cd_zpo_org[i] ;
			tab_type_portage_org[i] = f_type_portage_org[i] ;
			tab_tpr_groupe_org[i] 	= f_tpr_groupe_org[i] ;
			tab_tpr_num_org[i] 	    = f_tpr_num_org[i] ;
		}
		
		vLwtnm1Demande.f_cd_zpo_org			= tab_cd_zpo_org;
		vLwtnm1Demande.f_type_portage_org	= tab_type_portage_org;
		vLwtnm1Demande.f_tpr_groupe_org		= tab_tpr_groupe_org;
		vLwtnm1Demande.f_tpr_num_org		= tab_tpr_num_org;
		vLwtnm1Supp.f_tpr_choix_supp 		= f_tpr_choix_supp;
		vLwtnm1Supp.f_top_purge 			= f_top_purge;
		
		vLwtnm1.supp    = vLwtnm1Supp;
		vLwtnm1.demande = vLwtnm1Demande;
		
		jwlwtnm1.setNwlwtnm1Awlwtnm1(vLwtnm1);
		
		// CALL SERVER
		jwlwtnm1.nwlwtnm1();
		
		// Verification du code retour
		vWebent = jwlwtnm1.getNwlwtnm1Axwebent();
		System.out.println("Code retour nwlwtnm1() = " + 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{
			//affichage de reponse		
			System.out.println(vWebent.t_ano[0].lib_ano.trim());
			System.out.println ("Suite normale ...");
		}
		
		return jwlwtnm1;
	   } // End deleteTournee
	
	
	
	/**
		 * <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>08/02/2013</i>
		 * @version 1.0
		 */
	   public static void main(String[] args) throws BrokerException {
			Constantes.loadProperties("LW") ;
			JxweblogWeb.setUtilisateur ("MADAA02");
			JxweblogWeb.setPassword ("MADAA82");
			Broker broker 				    	= JxweblogWeb.logonBroker();
			Jxweblog jxweblog 				    = JxweblogWeb.getConnexion(broker);
			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;
			
			//Test de CREATION
			//---------Donnee Test---------------
			/*String f_cd_zpo_creat          = "SB04"; 
            String f_type_portage_creat    = "N"; 
            String f_tpr_groupe_creat 	   = "1"; 
            String f_tpr_num_creat         = "001"; 
            String f_tpr_libelle_creat     = "TESTwwww";  
			//---------Donnee Test---------------
			createTournee(f_cd_zpo_creat, f_type_portage_creat, f_tpr_groupe_creat, f_tpr_num_creat, f_tpr_libelle_creat, groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			*/
			//Test de MODIFICATION
			//---------Donnee Test---------------
			String f_cd_zpo_org[]          = new String[50]; 
            String f_type_portage_org[]    = new String[50]; 
            String f_tpr_groupe_org[]      = new String[50]; 
            String f_tpr_num_org[]         = new String[50]; 
            String f_tpr_libelle_org[]     = new String[50];
            
            f_cd_zpo_org[0] = "AHAH";
            f_type_portage_org[0] = "N";
            f_tpr_groupe_org[0] = "5";
            f_tpr_num_org[0] = "105";
			f_tpr_libelle_org[0] ="wwwwxx";
            setTournee(f_cd_zpo_org, f_type_portage_org, f_tpr_groupe_org, f_tpr_num_org, f_tpr_libelle_org,groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			
			//Test de SUPPRESSION
			//---------Donnee Test---------------
			/*String f_cd_zpo_org[]        = new String[50];
            String f_type_portage_org[]  = new String[50]; 
            String f_tpr_groupe_org[]    = new String[50]; 
            String f_tpr_num_org[]       = new String[50]; 
			f_cd_zpo_org[0] = "AAA1" ;
			f_type_portage_org[0] = "N" ;
			f_tpr_groupe_org[0] = "1" ;
			f_tpr_num_org[0] = "001" ;
			String f_tpr_choix_supp      = "O";
			String f_top_purge = null;
            //---------Donnee Test---------------
			deleteTournee(f_cd_zpo_org, f_type_portage_org, f_tpr_groupe_org, f_tpr_num_org,
					f_tpr_choix_supp,f_top_purge,
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			*/
			
			//Test de COPIE
			//---------Donnee Test---------------
			/*String f_cd_zpo               = "SB03";
            String f_zpo_libelle          = null; 
            String f_type_portage         = "N"; 
            String f_lib_type_portage     = null; 
            String f_tpr_groupe  	      = "1"; 
            String f_tpr_num  		      = "001"; 
            String f_tpr_libelle  	  	  = null; 
            String f_cd_zpo_c  			  = "SB03"; 
            String f_zpo_libelle_c  	  = null; 
            String f_type_portage_c  	  = "N"; 
            String f_lib_type_portage_c   = null; 
            String f_tpr_groupe_c  		  = "5"; 
            String f_tpr_num_c  		  = "101"; 
            String f_tpr_libelle_c        = null; 
			//---------Donnee Test---------------
			copieTournee(f_cd_zpo, f_type_portage, 
					f_tpr_groupe, f_tpr_num, f_cd_zpo_c,
					f_type_portage_c, f_tpr_groupe_c, f_tpr_num_c, f_tpr_libelle_c,
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			*/
			//Test de TRANSFERT
			//---------Donnee Test---------------
			/*String f_cd_zpo               = "SB03";
            String f_zpo_libelle          = null; 
            String f_type_portage         = "N"; 
            String f_lib_type_portage     = null; 
            String f_tpr_groupe  	      = "5"; 
            String f_tpr_num  		      = "101"; 
            String f_tpr_libelle  	  	  = null; 
            String f_cd_zpo_t  			  = "0001"; 
            String f_zpo_libelle_t  	  = null; 
            String f_type_portage_t  	  = "N"; 
            String f_lib_type_portage_t   = null; 
            String f_tpr_groupe_t  		  = "5"; 
            String f_tpr_num_t  		  = "101"; 
            String f_tpr_libelle_t        = null; 
			//---------Donnee Test---------------
			transfertTournee(f_cd_zpo, f_type_portage, 
					f_tpr_groupe, f_tpr_num, f_cd_zpo_t, 
					f_type_portage_t, f_tpr_groupe_t, f_tpr_num_t, f_tpr_libelle_t,
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			*/
			
		}			
}