Package com.lbslocal.cc.objects.v4.addressFinder

Examples of com.lbslocal.cc.objects.v4.addressFinder.AddressInfo


        }

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new POILocation();
        dependencyObjects[0].alias = "POILocation";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new POIInfo();
        dependencyObjects[1].alias = "POIInfo";
View Full Code Here


    try {
      AddressOptions ao = new AddressOptions();
      ao.setUsePhonetic(true);
      ao.setSearchType(2);
      ao.setResultRange(new ResultRange());
      ao.getResultRange().setPageIndex(1);
      ao.getResultRange().setRecordsPerPage(1);

      AddressInfo ai = new AddressInfo();
      ai = findAddress(address, ao, idLicenca);
View Full Code Here

        addressDependencyObjects[0].alias = "city";

        ObjectsHelper[] addressOptionsDependencyObjects = new ObjectsHelper[1];

        addressOptionsDependencyObjects[0] = cr.new ObjectsHelper();
        addressOptionsDependencyObjects[0].object = new ResultRange();
        addressOptionsDependencyObjects[0].alias = "resultRange";

        Address address = (Address) cr.getObjectFromXML(ph.XMLFile, "address", Address.class, addressDependencyObjects);
        AddressOptions ao = (AddressOptions) cr.getObjectFromXML(ph.XMLFile, "ao", AddressOptions.class, addressOptionsDependencyObjects);

        try {
          ai = cAf.findAddress(address, ao, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
        }

        response.setContentType("text/xml");
        response.setCharacterEncoding("UTF-8");

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new AddressInfo();
        dependencyObjects[0].alias = "AddressInfo";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new AddressLocation();
        dependencyObjects[1].alias = "AddressLocation";

        response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(ai, dependencyObjects) + "");
      }

      if (ph.fields[0].equals("findCity")) {
        CityLocationInfo ci = new CityLocationInfo();

        ObjectsHelper[] addressOptionsDependencyObjects = new ObjectsHelper[1];

        addressOptionsDependencyObjects[0] = cr.new ObjectsHelper();
        addressOptionsDependencyObjects[0].object = new ResultRange();
        addressOptionsDependencyObjects[0].alias = "resultRange";

        City city = (City) cr.getObjectFromXML(ph.XMLFile, "cidade", City.class, null);
        AddressOptions ao = (AddressOptions) cr.getObjectFromXML(ph.XMLFile, "ao", AddressOptions.class, addressOptionsDependencyObjects);

        try {
          ci = cAf.findCity(city, ao, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
        }
       
        response.setContentType("text/xml");
        response.setCharacterEncoding("UTF-8");

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new CityLocationInfo();
        dependencyObjects[0].alias = "CityLocationInfo";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new CityLocation();
        dependencyObjects[1].alias = "CityLocation";

        response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(ci, dependencyObjects) + "");
      }

      if (ph.fields[0].equals("findPOI")) {
        POIInfo pi = new POIInfo();

        String name = cr.getFieldFromXML(ph.XMLFile, "name");
        City city = (City) cr.getObjectFromXML(ph.XMLFile, "city", City.class, null);
        ResultRange resultRange = (ResultRange) cr.getObjectFromXML(ph.XMLFile, "resultRange", ResultRange.class, null);

        try {
          pi = cAf.findPOI(name, city, resultRange, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
View Full Code Here

      Point point = new Point();

      if (Functions.IsNullOrEmpty(ad.getStreet()) && Functions.IsNullOrEmpty(ad.getHouseNumber()) && Functions.IsNullOrEmpty(ad.getZip())
          && (!Functions.IsNullOrEmpty(ad.getCity().getName()) && !Functions.IsNullOrEmpty(ad.getCity().getState()))) {
        try {
          point = af.findCity(ad.getCity(), new AddressOptions(true, 10, new ResultRange(1, 1)), idLicenca).getCityLocation()[0].getPoint();
        } catch (Exception ex) {
          throw (new Exception("Nao foi possivel geocodificar o endereco."));
        }
      } else {
        point = af.getXY(ad, idLicenca);
View Full Code Here

      Point point = new Point();

      if (Functions.IsNullOrEmpty(ad.getStreet()) && Functions.IsNullOrEmpty(ad.getHouseNumber()) && Functions.IsNullOrEmpty(ad.getZip())
          && (!Functions.IsNullOrEmpty(ad.getCity().getName()) && !Functions.IsNullOrEmpty(ad.getCity().getState()))) {
        try {
          point = af.findCity(ad.getCity(), new AddressOptions(true, 0, new ResultRange(1, 1)), idLicenca).getCityLocation()[0].getPoint();
        } catch (Exception ex) {
          throw (new Exception("Nao foi possivel geocodificar o endereco."));
        }
      } else {
        point = af.getXY(ad, idLicenca);
View Full Code Here

      respostaWs = Common.SerializeJSObject(al);
      break;
    case findCitiesByState:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class });
      City city = new City("", (String) o[0]);
      AddressOptions ao = new AddressOptions(false, 1, new ResultRange(0, 1500));

      CityLocationInfo clii = addressFinder.findCity(city, ao, tk.getId());

      StringBuilder sb = new StringBuilder("[");
      for (int i = 0; i < clii.getCityLocation().length; i++) {
View Full Code Here

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              if (rs1.absolute(intI)) {
                // classe road
                rl[iCount] = new RoadLocation();
                rl[iCount].setRoad(new Road());
                rl[iCount].getRoad().setName(rs1.getString("ENDERECO"));
                rl[iCount].getRoad().setRoadNumber(rs1.getString("NUMERO"));

                rl[iCount].getRoad().setCity(new City());
                rl[iCount].getRoad().getCity().setName(rs1.getString("MUNICIPIO"));
View Full Code Here

                rl[iCount].getRoad().setCity(new City());
                rl[iCount].getRoad().getCity().setName(rs1.getString("MUNICIPIO"));
                rl[iCount].getRoad().getCity().setState(rs1.getString("UF"));
                rl[iCount].getRoad().setZip(rs1.getString("CEP"));

                rl[iCount].setRoadDetail(new RoadDetail());
                rl[iCount].getRoadDetail().setAlterName(rs1.getString("ENDERECOALT"));
                rl[iCount].getRoadDetail().setComplement(rs1.getString("COMPLEMENTO"));
                rl[iCount].getRoadDetail().setDirection(rs1.getString("SENTIDO"));
                rl[iCount].getRoadDetail().setDistrict(rs1.getString("BAIRRO"));
View Full Code Here

  }

  public RoadInfo findRoad(Road road, int idLicenca) throws Exception {
    int iCount = 0, roadNumber = 0;

    RoadInfo ri = new RoadInfo();
    Pagination pg;

    boolean hasState = (road.getCity().getState() != null && road.getCity().getState().compareTo("") != 0);

    if (!hasState) {
      throw (new Exception("O estado deve ser informado."));
    }

    if (Functions.IsNullOrEmpty(road.getCity().getCountry()))
      road.getCity().setCountry("Brasil");

    try {
      // transformar valores null em "" para n�o dar null pointer
      // exception
      if (road.getName() == null)
        road.setName("");
      if (road.getRoadNumber() == null)
        road.setRoadNumber("");
      if (road.getCity().getName() == null)
        road.getCity().setName("");
      if (road.getCity().getState() == null)
        road.getCity().setState("");
      if (road.getZip() == null)
        road.setZip("");

      // validando n�mero
      if (!road.getRoadNumber().equals("")) {
        if (Functions.isNumeric(road.getRoadNumber().replace(".", "").replace(",", "").replace("-", "").replace("e", "")))
          roadNumber = Integer.parseInt(road.getRoadNumber());
      }
      if (roadNumber == 0)
        road.setRoadNumber("");
      else
        road.setRoadNumber(String.valueOf(roadNumber));

      // se o valor de endere�o, cidade e estado for em branco erro
      // se cepe o cep forem em brancos da a mensagem de erro
      if (road.getZip() == "")
        if ((road.getName() == "") && ((road.getCity().getName() == "") || (road.getCity().getState() == "")))
          throw (new Exception(
              "Os atributos address.street, city.name e city.state devem ser informados quando o atributo address.zip nao e informado."));

      if (road.getZip().length() == 8)
        road.setZip(road.getZip().substring(0, 5) + "-" + road.getZip().substring(5, 8));

      Connection con = dataBase.getConnection(Functions.getDataBase(idLicenca, "Brasil").getSource());

      CallableStatement cst = con.prepareCall("{call cp_WS_KM(?,?,?,?,?)}");
      cst.setString(1, road.getRoadNumber());
      cst.setString(2, road.getName());
      cst.setString(3, road.getCity().getName());
      cst.setString(4, road.getCity().getState());
      cst.setString(5, road.getZip());

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

      CachedRowSetImpl crs = new CachedRowSetImpl();
      crs.populate(rs1);

      int TotalRecords = crs.size();

      if (TotalRecords > 0) {
        try {
          pg = Functions.definePage(TotalRecords, 1, 0);
          RoadLocation[] rl;

          if (pg.getRecordsInitial() <= TotalRecords) {
            rl = new RoadLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              if (rs1.absolute(intI)) {
                // classe road
                rl[iCount] = new RoadLocation();
                rl[iCount].setRoad(new Road());
                rl[iCount].getRoad().setName(rs1.getString("ENDERECO"));
                rl[iCount].getRoad().setRoadNumber(rs1.getString("NUMERO"));

                rl[iCount].getRoad().setCity(new City());
                rl[iCount].getRoad().getCity().setName(rs1.getString("MUNICIPIO"));
                rl[iCount].getRoad().getCity().setState(rs1.getString("UF"));
                rl[iCount].getRoad().setZip(rs1.getString("CEP"));

                rl[iCount].setRoadDetail(new RoadDetail());
                rl[iCount].getRoadDetail().setAlterName(rs1.getString("ENDERECOALT"));
                rl[iCount].getRoadDetail().setComplement(rs1.getString("COMPLEMENTO"));
                rl[iCount].getRoadDetail().setDirection(rs1.getString("SENTIDO"));
                rl[iCount].getRoadDetail().setDistrict(rs1.getString("BAIRRO"));

                iCount++;
              }
            }
            ri.setRecordCount((int) pg.getRecordCount());
            ri.setPageCount(pg.getPageCount());
          } else {
            rl = new RoadLocation[0];
          }

          ri.setRoadLocation(rl);
        } catch (Exception ex) {
          throw (new Exception("Registro n�o encontrado."));
        }
      } else {
        RoadLocation[] rl = new RoadLocation[0];
        ri.setRoadLocation(rl);
      }

      con.close();
      rs1.close();
      crs.close();
View Full Code Here

  }

  public RoadInfo findRoad(Road road, int idLicenca) throws Exception {
    iniDate = System.currentTimeMillis();

    RoadInfo ri = new RoadInfo();

    try {
      ri = ca.findRoad(road, idLicenca);
      Functions.gravarLogUnique(idLicenca, CommonAddress._findPOI, 0, iniDate, 0);
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.lbslocal.cc.objects.v4.addressFinder.AddressInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.