Examples of CityLocationInfo


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

    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

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

        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

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

  }

  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

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

      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
TOP
Copyright © 2018 www.massapi.com. 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.