import java.math.BigDecimal;

import com.softwareag.entirex.aci.Broker;
import com.softwareag.entirex.aci.BrokerException;

/**
 * <p>Titre : Jwlwprm1Web</p>
 * <p>Description : Mise à jours prestataire </p>
 * <p>Copyright : Copyright (c) 2012</p>
 * <p>Societe : ENSOR</p>
 * @author  PY <i>18/05/2012</i>
 * @version 1.0
 */
public class Jwlwprm1Web {	
	/**
	 * <p>Titre : getPrestataire</p>
	 * <p>Description : sélection d'un prestataire </p>
	 * <p>Copyright : Copyright (c) 2012</p>
	 * <p>Societe : ENSOR</p>
	 * @author  PY <i>18/05/2012</i>
	 * @version 1.0
	 */
	public static Jwlwprm1 getPrestataire(
			String cd_prt,
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
		// Initialisation des variables en entrees
	    Jwlwprm1 jwlwprm1 = new Jwlwprm1(broker, Constantes.SERVER_ADRESSE);
		// Initialisation de la vWebent depuis les informations de connexion
		Jwlwprm1.Nwlwprm1Axwebent vWebent = jwlwprm1.new Nwlwprm1Axwebent();
		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          = "VISU";
		vWebent.cd_cible          = cd_cible;
		vWebent.cd_stegrp         = cd_stegrp;
		vWebent.cd_application    = Constantes.CD_APPLICATION;
		jwlwprm1.setNwlwprm1Axwebent (vWebent);
		// Initialisation de la demande (tous à vide pour l'instant)
		Jwlwprm1.Nwlwprm1Awlwprm1 vLwprm1 = jwlwprm1.new Nwlwprm1Awlwprm1();
		Jwlwprm1.Nwlwprm1Awlwprm1Demande demande = jwlwprm1.new Nwlwprm1Awlwprm1Demande();
		Jwlwprm1.Nwlwprm1Awlwprm1Reponse reponse = jwlwprm1.new Nwlwprm1Awlwprm1Reponse();
		
		demande.cd_prt = cd_prt;
		
		vLwprm1.demande		   = demande;
		vLwprm1.reponse 	   = reponse;
		jwlwprm1.setNwlwprm1Awlwprm1(vLwprm1);
		
		// CALL SERVER
		jwlwprm1.nwlwprm1();
		
		// Verification du code retour
		vWebent = jwlwprm1.getNwlwprm1Axwebent();
		System.out.println("Code retour nwlwprm1() = " + 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 ("... Affichage de Reponse ...");
			System.out.println(" isn_enr = "			+ reponse.isn_enr);
			System.out.println(" cd_tpe = "				+ reponse.cd_tpe);
			System.out.println(" nom = "				+ reponse.nom);
			System.out.println(" prenom = "				+ reponse.prenom);
			System.out.println(" raison_sociale = "		+ reponse.raison_sociale);
			System.out.println(" numero_voie = "		+ reponse.numero_voie);
			System.out.println(" voie = "				+ reponse.voie);
			System.out.println(" cpl_voie = "			+ reponse.cpl_voie);
			System.out.println(" commune = "			+ reponse.commune);
			System.out.println(" cd_postal = "			+ reponse.cd_postal);
			System.out.println(" localite = "			+ reponse.localite);
			System.out.println(" no_tel_bur = "			+ reponse.no_tel_bur);
			System.out.println(" no_tel_dom = "			+ reponse.no_tel_dom);
			System.out.println(" no_fax = "				+ reponse.no_fax);
			System.out.println(" dt_creat = "			+ reponse.dt_creat);
			System.out.println(" dt_fin = "				+ reponse.dt_fin);
			System.out.println(" email = "				+ reponse.email);
			System.out.println(" email_cc = "			+ reponse.email_cc);
			System.out.println(" type_portage = "		+ reponse.type_portage);
			System.out.println(" cpt_ftp = "			+ reponse.cpt_ftp);
			System.out.println(" type_carnet = "		+ reponse.type_carnet);
			System.out.println(" top_carnet_nuit = "	+ reponse.top_carnet_nuit);
			System.out.println(" top_carnet_fictif = "	+ reponse.top_carnet_fictif);
			System.out.println(" top_carnet_reperage = "+ reponse.top_carnet_reperage);
			System.out.println(" type_etiq = "			+ reponse.type_etiq);
			System.out.println(" type_gardien = "		+ reponse.type_gardien);
			System.out.println(" type_stat = "			+ reponse.type_stat);
			System.out.println(" type_reclam = "		+ reponse.type_reclam);
			System.out.println(" type_tqg = "			+ reponse.type_tqg);
		}
		return jwlwprm1;
	}
	/**
	 * <p>Titre : deletePrestataire</p>
	 * <p>Description : Suppression d'un prestataire </p>
	 * <p>Copyright : Copyright (c) 2012</p>
	 * <p>Societe : ENSOR</p>
	 * @author  PY <i>18/05/2012</i>
	 * @version 1.0
	 */
	public static Jwlwprm1 deletePrestataire(
			String cd_prt,
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
			// Initialisation des variables en entrees
		    Jwlwprm1 jwlwprm1 = new Jwlwprm1(broker, Constantes.SERVER_ADRESSE);
				
			// Initialisation de la vWebent depuis les informations de connexion
			Jwlwprm1.Nwlwprm1Axwebent vWebent = jwlwprm1.new Nwlwprm1Axwebent();
			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          = "SUPPR";
			vWebent.cd_cible          = cd_cible;
			vWebent.cd_stegrp         = cd_stegrp;
			vWebent.cd_application    = Constantes.CD_APPLICATION;
			jwlwprm1.setNwlwprm1Axwebent (vWebent);
			
			// Initialisation de la demande (tous à vide pour l'instant)
			Jwlwprm1.Nwlwprm1Awlwprm1 vLwprm1 = jwlwprm1.new Nwlwprm1Awlwprm1();
			Jwlwprm1.Nwlwprm1Awlwprm1Demande demande = jwlwprm1.new Nwlwprm1Awlwprm1Demande();
			demande.cd_prt 		   = cd_prt;
			vLwprm1.demande 	   = demande;
			jwlwprm1.setNwlwprm1Awlwprm1(vLwprm1);

			// CALL SERVER
			jwlwprm1.nwlwprm1();
			
			// Verification du code retour
			vWebent = jwlwprm1.getNwlwprm1Axwebent();
			System.out.println("Code retour nwlwprm1() = " + 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 ("Suite normale");
			}
			return jwlwprm1;
		   } // End setTypesPrestataire

	/**
	 * <p>Titre : setPrestataire</p>
	 * <p>Description : Modification d'un prestataire </p>
	 * <p>Copyright : Copyright (c) 2012</p>
	 * <p>Societe : ENSOR</p>
	 * @author  PY <i>18/05/2012</i>
	 * @version 1.0
	 */
	public static Jwlwprm1 setPrestataire(
			String cd_prt,
			String isn_enr,
			String cd_tpe,
			String nom,
			String prenom,
			String raison_sociale,
			String numero_voie,
			String voie,
			String cpl_voie,
			String commune,
			String cd_postal,
			String localite,
			String no_tel_dom,
			String no_tel_bur,
			String no_fax,
			String dt_creat,
			String dt_fin,
			String email,
			String email_cc,
			String type_portage,
			String cpt_ftp,
			String type_carnet,
			String top_carnet_nuit,
			String top_carnet_fictif,
			String top_carnet_reperage,
			String type_etiq,
			String type_gardien,
			String type_stat,
			String type_reclam,
			String type_tqg,
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
		// Initialisation des variables en entrees
	    Jwlwprm1 jwlwprm1 = new Jwlwprm1(broker, Constantes.SERVER_ADRESSE);
		// Initialisation de la vWebent depuis les informations de connexion
		Jwlwprm1.Nwlwprm1Axwebent vWebent = jwlwprm1.new Nwlwprm1Axwebent();
		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          = "MODIF";
		vWebent.cd_cible          = cd_cible;
		vWebent.cd_stegrp         = cd_stegrp;
		vWebent.cd_application    = Constantes.CD_APPLICATION;
		jwlwprm1.setNwlwprm1Axwebent (vWebent);
		// Initialisation de la demande (tous à vide pour l'instant)
		Jwlwprm1.Nwlwprm1Awlwprm1 vLwprm1 = jwlwprm1.new Nwlwprm1Awlwprm1();
		
		Jwlwprm1.Nwlwprm1Awlwprm1Demande demande = jwlwprm1.new Nwlwprm1Awlwprm1Demande();
		Jwlwprm1.Nwlwprm1Awlwprm1Reponse reponse = jwlwprm1.new Nwlwprm1Awlwprm1Reponse();
		demande.cd_prt 	= cd_prt;
		if(!"".equals(isn_enr) && isn_enr!=null){
			reponse.isn_enr	   = new BigDecimal(isn_enr);
		}
		reponse.cd_tpe 			= cd_tpe;
		reponse.nom 			= nom;
		reponse.prenom 			= prenom;
		reponse.raison_sociale 	= raison_sociale;
		reponse.numero_voie 	= numero_voie;
		reponse.voie 			= voie;
		reponse.cpl_voie 		= cpl_voie;
		reponse.commune 		= commune;
		reponse.cd_postal 		= cd_postal;
		reponse.localite 		= localite;
		reponse.no_tel_bur 		= no_tel_bur;
		reponse.no_tel_dom 		= no_tel_dom;
		reponse.no_fax 			= no_fax;
		if(!"".equals(dt_creat) && dt_creat!=null){
			reponse.dt_creat = new BigDecimal(dt_creat);
		}
		if(!"".equals(dt_fin) && dt_fin!=null){
			reponse.dt_fin 	   = new BigDecimal(dt_fin);
		}
		reponse.email 				= email;
		reponse.email_cc 			= email_cc;
		reponse.type_portage 		= type_portage;
		reponse.cpt_ftp 			= cpt_ftp;
		reponse.type_carnet 		= type_carnet;
		reponse.top_carnet_nuit 	= top_carnet_nuit;
		reponse.top_carnet_fictif 	= top_carnet_fictif;
		reponse.top_carnet_reperage = top_carnet_reperage;
		reponse.type_etiq 			= type_etiq;
		reponse.type_gardien 		= type_gardien;
		reponse.type_stat 			= type_stat;
		reponse.type_reclam 		= type_reclam;
		reponse.type_tqg 			= type_tqg;
		
		vLwprm1.demande		   = demande;
		vLwprm1.reponse 	   = reponse;
		jwlwprm1.setNwlwprm1Awlwprm1(vLwprm1);
		
		// CALL SERVER
		jwlwprm1.nwlwprm1();
		
		// Verification du code retour
		vWebent = jwlwprm1.getNwlwprm1Axwebent();
		System.out.println("Code retour nwlwprm1() = " + 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 ("Suite normale");
		}
		return jwlwprm1;
	}
	/**
	 * <p>Titre : createPrestataire</p>
	 * <p>Description : création d'un prestataire </p>
	 * <p>Copyright : Copyright (c) 2012</p>
	 * <p>Societe : ENSOR</p>
	 * @author  PY <i>18/05/2012</i>
	 * @version 1.0
	 */
	public static Jwlwprm1 createPrestataire(
			String cd_prt,
			String isn_enr,
			String cd_tpe,
			String nom,
			String prenom,
			String raison_sociale,
			String numero_voie,
			String voie,
			String cpl_voie,
			String commune,
			String cd_postal,
			String localite,
			String no_tel_dom,
			String no_tel_bur,
			String no_fax,
			String dt_creat,
			String dt_fin,
			String email,
			String email_cc,
			String type_portage,
			String cpt_ftp,
			String type_carnet,
			String top_carnet_nuit,
			String top_carnet_fictif,
			String top_carnet_reperage,
			String type_etiq,
			String type_gardien,
			String type_stat,
			String type_reclam,
			String type_tqg,
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
		// Initialisation des variables en entrees
	    Jwlwprm1 jwlwprm1 = new Jwlwprm1(broker, Constantes.SERVER_ADRESSE);
		// Initialisation de la vWebent depuis les informations de connexion
		Jwlwprm1.Nwlwprm1Axwebent vWebent = jwlwprm1.new Nwlwprm1Axwebent();
		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          = "CREAT";
		vWebent.cd_cible          = cd_cible;
		vWebent.cd_stegrp         = cd_stegrp;
		vWebent.cd_application    = Constantes.CD_APPLICATION;
		jwlwprm1.setNwlwprm1Axwebent (vWebent);
		// Initialisation de la demande (tous à vide pour l'instant)
		Jwlwprm1.Nwlwprm1Awlwprm1 vLwprm1 = jwlwprm1.new Nwlwprm1Awlwprm1();
		
		Jwlwprm1.Nwlwprm1Awlwprm1Demande demande = jwlwprm1.new Nwlwprm1Awlwprm1Demande();
		Jwlwprm1.Nwlwprm1Awlwprm1Reponse reponse = jwlwprm1.new Nwlwprm1Awlwprm1Reponse();
		demande.cd_prt 	= cd_prt;
		if(!"".equals(isn_enr) && isn_enr!=null){
			reponse.isn_enr	   = new BigDecimal(isn_enr);
		}
		reponse.cd_tpe 			= cd_tpe;
		reponse.nom 			= nom;
		reponse.prenom 			= prenom;
		reponse.raison_sociale 	= raison_sociale;
		reponse.numero_voie 	= numero_voie;
		reponse.voie 			= voie;
		reponse.cpl_voie 		= cpl_voie;
		reponse.commune 		= commune;
		reponse.cd_postal 		= cd_postal;
		reponse.localite 		= localite;
		reponse.no_tel_bur 		= no_tel_bur;
		reponse.no_tel_dom 		= no_tel_dom;
		reponse.no_fax 			= no_fax;
		if(!"".equals(dt_creat) && dt_creat!=null){
			reponse.dt_creat = new BigDecimal(dt_creat);
		}
		if(!"".equals(dt_fin) && dt_fin!=null){
			reponse.dt_fin 	   = new BigDecimal(dt_fin);
		}
		reponse.email 				= email;
		reponse.email_cc 			= email_cc;
		reponse.type_portage 		= type_portage;
		reponse.cpt_ftp 			= cpt_ftp;
		reponse.type_carnet 		= type_carnet;
		reponse.top_carnet_nuit 	= top_carnet_nuit;
		reponse.top_carnet_fictif 	= top_carnet_fictif;
		reponse.top_carnet_reperage = top_carnet_reperage;
		reponse.type_etiq 			= type_etiq;
		reponse.type_gardien 		= type_gardien;
		reponse.type_stat 			= type_stat;
		reponse.type_reclam 		= type_reclam;
		reponse.type_tqg 			= type_tqg;
		
		vLwprm1.demande		   = demande;
		vLwprm1.reponse 	   = reponse;
		jwlwprm1.setNwlwprm1Awlwprm1(vLwprm1);
		
		// CALL SERVER
		jwlwprm1.nwlwprm1();
		
		// Verification du code retour
		vWebent = jwlwprm1.getNwlwprm1Axwebent();
		System.out.println("Code retour nwlwprm1() = " + 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 ("Suite normale");
		}
		return jwlwprm1;
	}
	   
	   /**
		 * <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>25/03/2012</i>
		 * @version 1.0
		 */
	   public static void main(String[] args) throws BrokerException {
			Constantes.loadProperties("LW") ;
			JxweblogWeb.setUtilisateur ("MADAA02");
			JxweblogWeb.setPassword ("MADAA32");
			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;
			
			
			//Constructeur TEST CREATION
			/*System.out.println("DEBUT TEST CREATION : type prestataire .................") ;
			//---------------Debut données test--------------------------
			String cd_prt 				= null;
			String isn_enr 				= null;
			String cd_tpe 				= null;
			String nom 					= null;
			String prenom 				= null;
			String raison_sociale 		= null;
			String numero_voie 			= null;
			String voie 				= null;
			String cpl_voie 			= null;
			String commune 				= null;
			String cd_postal 			= null;
			String localite 			= null;
			String no_tel_bur 			= null;
			String no_tel_dom 			= null;
			String no_fax 				= null;
			String dt_creat 			= null;
			String dt_fin 				= null;
			String email 				= null;
			String email_cc 			= null;
			String type_portage 		= null;
			String cpt_ftp 				= null;
			String type_carnet 			= null;
			String top_carnet_nuit 		= null;
			String top_carnet_fictif 	= null;
			String top_carnet_reperage 	= null;
			String type_etiq 			= null;
			String type_gardien 		= null;
			String type_stat 			= null;
			String type_reclam 			= null;
			String type_tqg 			= null;
			//---------------Fin données test--------------------------
			createPrestataire(cd_prt, isn_enr, cd_tpe, nom, prenom, 
					raison_sociale, numero_voie, voie, cpl_voie, commune, 
					cd_postal, localite, no_tel_dom, no_tel_bur, no_fax, dt_creat, dt_fin, 
					email, email_cc, type_portage, cpt_ftp, type_carnet, top_carnet_nuit, 
					top_carnet_fictif, top_carnet_reperage, type_etiq, type_gardien, 
					type_stat, type_reclam, type_tqg, 
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);*/
			
			
			//Constructeur TEST MODIFICATION
			/*System.out.println("DEBUT TEST MODIFICATION : type prestataire .................") ;
			//---------------Debut données test--------------------------
			String cd_prt 				= null;
			String isn_enr 				= null;
			String cd_tpe 				= null;
			String nom 					= null;
			String prenom 				= null;
			String raison_sociale 		= null;
			String numero_voie 			= null;
			String voie 				= null;
			String cpl_voie 			= null;
			String commune 				= null;
			String cd_postal 			= null;
			String localite 			= null;
			String no_tel_bur 			= null;
			String no_tel_dom 			= null;
			String no_fax 				= null;
			String dt_creat 			= null;
			String dt_fin 				= null;
			String email 				= null;
			String email_cc 			= null;
			String type_portage 		= null;
			String cpt_ftp 				= null;
			String type_carnet 			= null;
			String top_carnet_nuit 		= null;
			String top_carnet_fictif 	= null;
			String top_carnet_reperage 	= null;
			String type_etiq 			= null;
			String type_gardien 		= null;
			String type_stat 			= null;
			String type_reclam 			= null;
			String type_tqg 			= null;
			//---------------Fin données test--------------------------
			setPrestataire(cd_prt, isn_enr, cd_tpe, nom, prenom, raison_sociale, numero_voie, 
					voie, cpl_voie, commune, cd_postal, localite, no_tel_dom, no_tel_bur, 
					no_fax, dt_creat, dt_fin, email, email_cc, type_portage, cpt_ftp, 
					type_carnet, top_carnet_nuit, top_carnet_fictif, top_carnet_reperage, 
					type_etiq, type_gardien, type_stat, type_reclam, type_tqg, 
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);*/
			
			
			//Constructeur TEST INTERROGATION
			System.out.println("DEBUT TEST INTERROGATION : type prestataire .................") ;
			//---------------Debut données test--------------------------
			String cd_prt_verif		 = "0028";
			//---------------Fin données test--------------------------
			getPrestataire(cd_prt_verif, groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);
			
			
			//Constructeur TEST SUPPRESSION
			/*System.out.println("DEBUT TEST SUPPRESSION : type prestataire .................") ;
			//---------------Debut données test--------------------------
			String cd_prt		 = "80";
			//---------------Fin données test--------------------------
			deletePrestataire(cd_prt, 
					groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp, broker);*/
			
			System.out.println("...Fin de test ...");
		}
			
}