<% /****************************************************************************** * Copyright (c) 2000-2004 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. * * ******************************************************************************/ %><%@page session="true" import="java.util.*,com.edeal.frontline.*,com.edeal.frontline.services.*,com.edeal.frontline.services.addressnormalisation.*"%><%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><%final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); String contextPath = (String)session.getAttribute("contextPath"); if(contextPath == null) { contextPath = request.getContextPath(); } FlContext context = Frontline.getContext(contextPath); DataDictionary dico = context.getDataDictionary(); String pTyp=Utils.getRequestParameter(context,request,"typ"); String pId=Utils.getRequestParameter(context,request,"id"); String pIdx=Utils.getRequestParameter(context,request,"idx"); String pCancel=Utils.getRequestParameter(context,request,"cancel"); String pGoBackUrl=Utils.getRequestParameter(context,request,"gobackto"); BasicBean bean=(BasicBean)request.getAttribute(pTyp); NormalisedAddresses altAddresses; String urlToForwardTo=pGoBackUrl.startsWith("/")?pGoBackUrl:"/"+pGoBackUrl; boolean fCancel=false; if (pCancel!=null && !"".equals(pCancel)) { bean=(BasicBean)session.getAttribute("__Address__"+pTyp); AddressNormalisationStatus.KO.setAddressStatusToBean(bean, "setAddressNormalisationStatus"); session.removeAttribute("__Address__"+pTyp); session.removeAttribute("__AltAddresses__"); request.setAttribute(pTyp,bean); //urlToForwardTo="/sales/enterprise/edit_body.jsp"; fCancel=true; } if (pIdx!=null && !"".equals(pIdx)) { altAddresses=(NormalisedAddresses)session.getAttribute("__AltAddresses__"); int index=(new Integer(pIdx)).intValue(); bean=(BasicBean)session.getAttribute("__Address__"+pTyp); request.setAttribute(pTyp,bean); NormalisedAddress adr = altAddresses.getAddress(index); adr.toBean(bean, "setAddress"); // AddressNormalisationStatus.OK.setAddressStatusToBean(bean); // adr.toBean(bean,AddressNormalisationStatus.OK); session.removeAttribute("__Address__"+pTyp); session.removeAttribute("__AltAddresses__"); } Address currentAddress=Address.fromBean(bean, "getAddress"); //FlServiceManager serviceManager=context.getServiceManager(); // String urlToForwardTo=null; AddressNormalisationStatus status=AddressNormalisationStatus.NULL; AddressNormalisationServiceResponse addNormServiceResponse=new AddressNormalisationServiceResponse(); AddressNormalisationCorrection correction=AddressNormalisationCorrection.NULL; AddressNormalisationServiceClient addNormServiceClient; if (!fCancel) { try { addNormServiceClient = (AddressNormalisationServiceClient)context.getServiceManager().getServiceClient(session, "AddressNormalisation"); addNormServiceClient.initialize(); addNormServiceClient.authenticate(); addNormServiceResponse = addNormServiceClient.getAddress(bean, "getAddressMethod"); status = addNormServiceResponse.getStatus(); correction = addNormServiceResponse.getCorrectionType(); if (status.equals(AddressNormalisationStatus.OK)) { addNormServiceClient.acceptAddress(bean,addNormServiceResponse.getMainAddress(),AddressNormalisationStatus.OK, "setAddressMethod", "setAddressNormalisationStatus"); // urlToForwardTo="/sales/enterprise/edit_body.jsp"; } else if (status.equals(AddressNormalisationStatus.KO)) { AddressNormalisationStatus.KO.setAddressStatusToBean(bean, "setAddressNormalisationStatus"); //urlToForwardTo="/sales/enterprise/edit_body.jsp"; } else if (status.equals(AddressNormalisationStatus.NULL)) { // erreur throw new FlServiceException("Une erreur est survenue avec l'appel RNVP"); } } catch (FlServiceException e) { request.setAttribute("errorMessage","Erreur Appel Service"); request.setAttribute("serviceexception",e); urlToForwardTo="/plugins/service_error.jsp"; } catch (Exception e) { request.setAttribute("errorMessage","Erreur Inconnue"); request.setAttribute("exception",e); urlToForwardTo="/plugins/service_error.jsp"; } } if (!status.equals(AddressNormalisationStatus.UNKNOWN)) { if (urlToForwardTo!=null) {%> <% } } altAddresses = addNormServiceResponse.getAlternateAddresses(); Enumeration enAddresses = altAddresses.elements(); session.setAttribute("__AltAddresses__",altAddresses); session.setAttribute("__Address__"+pTyp,bean); String url="/plugins/addressnormalisation/check_address.jsp?typ="+pTyp; %>
La normalisation détecte une ambiguité
Ambiguité <%= correction %>
Address saisie <%= currentAddress %>
<% int idx=0; while (enAddresses.hasMoreElements()) { Address address=(Address)enAddresses.nextElement(); if (!address.isEmpty()) { %> <% idx++; } } %>
Addresses Alternatives
<%= (address) %>
">Annuler