Issue 12413

Make country names links in the geographic coverage

12413
Reporter: trobertson
Assignee: mdoering
Type: Improvement
Summary: Make country names links in the geographic coverage
Priority: Minor
Resolution: Fixed
Status: Resolved
Created: 2012-11-27 12:43:15.177
Updated: 2014-01-06 19:05:54.826
Resolved: 2014-01-06 19:05:07.797
        
Description: The geographic descriptions often have various country names.  It would be nice to make these links to the country pages.

However, we have no URL that accepts a country iso code and redirects.  With a target URL like /country/US something like the following in the dataset action would help, which is shown in the attached screenshot.

{code}
  // allows reg ex replacement of names in geographic descriptions (reuse the pattern for performance)
  private static final Pattern COUNTRY_REG_EX = Pattern.compile(countryTitleRegEx());

  /**
   * Builds a regular expression from all the country names, to allow replacement as links.
   */
  private static String countryTitleRegEx() {
    ImmutableList.Builder b = ImmutableList.builder();
    for (Country c : Country.values()) {
      b.add("\\b" + c.getTitle() + "\\b");
    }
    return "(" + Joiner.on("|").join(b.build()) + ")";
  }

    for (GeospatialCoverage gc : dataset.getGeographicCoverages()) {
      // There are not yet any links to the actual countries
      String replacement = COUNTRY_REG_EX.matcher(gc.getDescription()).replaceAll("$1");
      gc.setDescription(replacement);
    }
{code}]]>
    

Attachment Resolved links.png


Attachment Screen Shot 2012-11-27 at 12.34.59 PM.png



Author: kbraak@gbif.org
Comment: We could enhance the /member service, to also resolve /member/countrycode or /member/countryname
Created: 2014-01-06 16:36:31.638
Updated: 2014-01-06 16:36:31.638


Author: mdoering@gbif.org
Created: 2014-01-06 18:04:21.303
Updated: 2014-01-06 18:04:21.303
        
[~kbraak@gbif.org] what do you mean by member service? We should simply link to the country pages we already have:
http://www.gbif.org/country/DE

    


Author: mdoering@gbif.org
Comment: https://code.google.com/p/gbif-portal/source/detail?r=2605
Created: 2014-01-06 19:05:07.848
Updated: 2014-01-06 19:05:07.848