Esempio n. 1
0
  /**
   * This method finds all the countries which contains a given region.
   *
   * @param regionCode Region code. Note: If you specify 'any' as the regions string, it will return
   *     all of the countries available.
   * @return A non-null List object containing the list of countries.
   */
  public Iterator findCountriesForRegion(String regionCode) {
    List _countryCodes = null;

    if (regionCode.equals("any")) { // Do the find for any region -> this means return all countries
      _countryCodes = findAllCountriesCodes();
    } else {
      try {
        _countryCodes =
            new Chm62edtCountryBiogeoregionDomain()
                .findWhere("CODE_BIOGEOREGION='" + regionCode + "'");
      } catch (Exception e) {
        e.printStackTrace();
        _countryCodes = new ArrayList();
      }
    }
    Vector _countries = new Vector();
    Iterator _it = _countryCodes.iterator();

    try {
      while (_it.hasNext()) {
        Chm62edtCountryBiogeoregionPersist _aRegion =
            (Chm62edtCountryBiogeoregionPersist) _it.next();

        _countries.addElement(
            new CountryWrapper(
                countryCode2Name(_aRegion.getCodeCountry()), _aRegion.getCodeCountry(), ""));
      }
    } catch (ClassCastException ex) {
      ex.printStackTrace();
      return _it;
    }
    new SortList().sort(_countries, SortList.SORT_ASCENDING);
    return _countries.iterator();
  }
Esempio n. 2
0
  /**
   * This method finds the bioregions located within a country.
   *
   * @param countryCode Country area code. Note: If you specify 'any' as the country string, it will
   *     return all of the biogeographic regions available.
   * @return An non-null List object containing the regions as Country.
   */
  public static Vector findRegionsFromCountry(String countryCode) {
    List _regionsCodes = new Vector();

    if (countryCode.equals("any")) {
      // Do the find for any country -> this means return all bioregions
      _regionsCodes = findAllRegionsCodes();
    } else { // or for a specified country
      try {
        _regionsCodes =
            new Chm62edtCountryBiogeoregionDomain()
                .findWhere("CODE_COUNTRY='" + countryCode + "' AND CODE_BIOGEOREGION<>'nd'");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    Vector _regions = new Vector();

    for (Object _regionsCode : _regionsCodes) {
      Chm62edtCountryBiogeoregionPersist _aRegion =
          (Chm62edtCountryBiogeoregionPersist) _regionsCode;

      _regions.addElement(
          new RegionWrapper(
              regionCode2Name(_aRegion.getCodeBiogeoregion()),
              _aRegion.getCodeBiogeoregion(),
              "idGeoscope",
              _aRegion.getPercentage()));
    }
    new SortList().sort(_regions, SortList.SORT_ASCENDING);
    return _regions;
  }