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

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


          location = new CityLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

          for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
            if (rs1.absolute(intI)) {
              // definir city
              location[iCount] = new CityLocation();
              location[iCount].setCity(new City());
              location[iCount].getCity().setName(rs1.getString("MUNICY"));
              location[iCount].getCity().setState(rs1.getString("UF"));
              // definir point
              location[iCount].setPoint(new Point());
View Full Code Here


        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) + "");
      }
View Full Code Here

    return ri;
  }

  public CityLocationInfo findCity(City city, AddressOptions ao, int idLicenca) throws Exception {
    CityLocationInfo cityLocationInfo = new CityLocationInfo();
    CityLocation[] location;

    try {
      int iCount = 0;

      Pagination pg;

      // Se for diferente de 0,1,2 ou 3, seta o valor padr�o de 2 -
      // anywhere
      if ((ao.getSearchType() != AddressOptions.Exact) && (ao.getSearchType() != AddressOptions.BeginsWith)
          && (ao.getSearchType() != AddressOptions.Anywhere) && (ao.getSearchType() != AddressOptions.EndsWith))
        ao.setSearchType(AddressOptions.Anywhere);

      String country;

      if (!Functions.IsNullOrEmpty(city.getCountry()))
        country = city.getCountry();
      else
        country = "BRASIL";

      // transformar valores null em "" para n�o dar null pointer
      // exception
      if (city.getName() == null)
        city.setName("");
      if (city.getState() == null)
        city.setState("");

      Connection con = dataBase.getConnection(Functions.getDataBase(idLicenca, country).getSource());
      CallableStatement cst = null;

      cst = con.prepareCall("{call CP_WS_TB_CIDADES_SELECT_FONETICO(?,?,?,?,?)}");
      cst.setString(1, city.getName());
      cst.setString(2, city.getState());
      cst.setInt(3, (ao.isUsePhonetic()) ? 1 : 0);
      cst.setInt(4, ao.getSearchType());
      cst.setInt(5, 0);

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

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

      int TotalRecords = crs.size();

      if (TotalRecords > 0) {
        pg = Functions.definePage(TotalRecords, ao.getResultRange().getRecordsPerPage(), ao.getResultRange().getPageIndex());

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

          for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
            if (rs1.absolute(intI)) {
              // definir city
              location[iCount] = new CityLocation();
              location[iCount].setCity(new City());
              location[iCount].getCity().setName(rs1.getString("MUNICY"));
              location[iCount].getCity().setState(rs1.getString("UF"));
              // definir point
              location[iCount].setPoint(new Point());
              location[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
              location[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));
              // definir carAccess
              location[iCount].setCarAccess(true);
              // atribuir CEP
              location[iCount].setZipRangeStart(rs1.getString("CEP_INI"));
              location[iCount].setZipRangeEnd(rs1.getString("CEP_FIM"));
              location[iCount].setCapital(rs1.getBoolean("CAPITAL"));

              location[iCount].setAddressesAvailable(true);

              iCount++;
            }
          }
        } else {
          location = new CityLocation[0];
        }

        cityLocationInfo.setRecordCount((int) pg.getRecordCount());
        cityLocationInfo.setPageCount(pg.getPageCount());
        cityLocationInfo.setCityLocation(location);
      } else {
        location = new CityLocation[0];
        cityLocationInfo.setCityLocation(location);
      }

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

        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";
View Full Code Here

  }

  public CityLocationInfo findCity(City city, AddressOptions ao, int idLicenca) throws Exception {
    iniDate = System.currentTimeMillis();

    CityLocationInfo cityLocationInfo = new CityLocationInfo();

    try {
      cityLocationInfo = ca.findCity(city, ao, idLicenca);
      Functions.gravarLogUnique(idLicenca, CommonAddress._findCity, 0, iniDate, 0);
    } catch (Exception e) {
View Full Code Here

      AddressInfo ai = addressFinder.findAddress((Address) o[0], (AddressOptions) o[1], tk.getId());
      respostaWs = Common.SerializeJSObject(ai);
      break;
    case findCity:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { City.class, AddressOptions.class });
      CityLocationInfo cli = addressFinder.findCity((City) o[0], (AddressOptions) o[1], tk.getId());
      respostaWs = Common.SerializeJSObject(cli);
      break;
    case findPOI:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class, City.class, ResultRange.class });
      POIInfo pi = addressFinder.findPOI((String) o[0], (City) o[1], (ResultRange) o[2], tk.getId());
      respostaWs = Common.SerializeJSObject(pi);
      break;
    case getAddress:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { Point.class });
      AddressLocation al = addressFinder.getAddress((Point) o[0], 100, tk.getId());
      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++) {

        sb.append("{\"nm\":\"");
        sb.append(clii.getCityLocation()[i].getCity().getName());
        sb.append("\",\"isC\":");
        sb.append((clii.getCityLocation()[i].isCapital()) ? 1 : 0);
        sb.append("},");

      }
      sb.deleteCharAt(sb.length() - 1);
      sb.append("]");
View Full Code Here

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              // classe district
              if (rs1.absolute(intI)) {
                dl[iCount] = new DistrictLocation();

                dl[iCount].setDistrict(new District());
                dl[iCount].getDistrict().setName(rs1.getString("NOME"));

                dl[iCount].getDistrict().setCity(new City());
                dl[iCount].getDistrict().getCity().setName(rs1.getString("CIDADE"));
                dl[iCount].getDistrict().getCity().setState(rs1.getString("UF"));
View Full Code Here

    _dataSourceRevGeo = dataSourceRevGeo;
    _outputLinux = outputLinux;
  }

  public DistrictInfo findDistrict(District district, ResultRange rr, int idLicenca) throws Exception {
    DistrictInfo ri = new DistrictInfo();

    try {
      int iCount = 0;

      Pagination pg;

      Boolean hasState = (district.getCity().getState() != null && !district.getCity().getState().equals(""));
      Boolean hasCity = (district.getCity().getName() != null && !district.getCity().getName().equals(""));

      if (!hasCity || !hasState) {
        throw (new Exception("Cidade e estado devem ser informados."));
      }

      if (district.getName() == null)
        district.setName("");

      if (district.getCity().getName() == null)
        district.getCity().setName("");

      if (district.getCity().getState() == null)
        district.getCity().setState("");

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

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

      CallableStatement cst = con.prepareCall("{call CP_WS_DISTRICT(?,?,?)}");
      cst.setString(1, district.getName());
      cst.setString(2, district.getCity().getName());
      cst.setString(3, district.getCity().getState());

      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, rr.getRecordsPerPage(), rr.getPageIndex());
          DistrictLocation[] dl;

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

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              // classe district
              if (rs1.absolute(intI)) {
                dl[iCount] = new DistrictLocation();

                dl[iCount].setDistrict(new District());
                dl[iCount].getDistrict().setName(rs1.getString("NOME"));

                dl[iCount].getDistrict().setCity(new City());
                dl[iCount].getDistrict().getCity().setName(rs1.getString("CIDADE"));
                dl[iCount].getDistrict().getCity().setState(rs1.getString("UF"));

                dl[iCount].setPoint(new Point());
                dl[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
                dl[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));

                dl[iCount].getDistrict().setZone(rs1.getString("REGIAO"));

                iCount++;
              }
            }

            ri.setRecordCount((int) pg.getRecordCount());
            ri.setPageCount(pg.getPageCount());
          } else {
            dl = new DistrictLocation[0];
          }

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

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

  }

  public DistrictInfo findDistrict(District district, ResultRange rr, int idLicenca) throws Exception {
    iniDate = System.currentTimeMillis();

    DistrictInfo dii = new DistrictInfo();

    try {
      dii = ca.findDistrict(district, rr, idLicenca);
      Functions.gravarLogUnique(idLicenca, CommonAddress._findPOI, 0, iniDate, 0);
    } catch (Exception e) {
View Full Code Here

            dl = new DistrictLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              // classe district
              if (rs1.absolute(intI)) {
                dl[iCount] = new DistrictLocation();

                dl[iCount].setDistrict(new District());
                dl[iCount].getDistrict().setName(rs1.getString("NOME"));

                dl[iCount].getDistrict().setCity(new City());
View Full Code Here

TOP

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

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.