@Test public void mapping() { assertThat(ExternalIdUtil.urlForExternalId("http: assertThat(ExternalIdUtil.urlForExternalId("https: assertThat(ExternalIdUtil.urlForExternalId("doi:10.some/DOI#12"), is("https: assertThat(ExternalIdUtil.urlForExternalId("DOI:10.some/DOI#12"), is("https: assertThat(ExternalIdUtil.urlForExternalId("https: assertThat(ExternalIdUtil.urlForExternalId("ENVO:00001995"), is("http: assertThat(ExternalIdUtil.urlForExternalId("bioinfo:ref:147884"), is("http: assertThat(ExternalIdUtil.urlForExternalId("IF:700605"), is("http: assertThat(ExternalIdUtil.urlForExternalId("NCBI:7215"), is("https: assertThat(ExternalIdUtil.urlForExternalId("OTT:563163"), is("https: assertThat(ExternalIdUtil.urlForExternalId("GBIF:2435035"), is("http: assertThat(ExternalIdUtil.urlForExternalId("NBN:NHMSYS0000080189"), is("https: assertThat(ExternalIdUtil.urlForExternalId("IRMNG:10201332"), is("http: assertThat(ExternalIdUtil.urlForExternalId("IRMNG:1012185"), is("http: assertThat(ExternalIdUtil.urlForExternalId("IRMNG:104889"), is("http: assertThat(ExternalIdUtil.urlForExternalId("ITIS:104889"), is("http: assertThat(ExternalIdUtil.urlForExternalId("urn:lsid:biodiversity.org.au:apni.taxon:168083"), is("http: assertThat(ExternalIdUtil.urlForExternalId("INAT:4493862"), is("https: assertThat(ExternalIdUtil.urlForExternalId("INAT_TAXON:406089"), is("https: assertThat(ExternalIdUtil.urlForExternalId("WD:Q140"), is("https: assertThat(ExternalIdUtil.urlForExternalId("GEONAMES:123"), is("http: assertThat(ExternalIdUtil.urlForExternalId("ALATaxon:NZOR-4-77345"), is("https: assertThat(ExternalIdUtil.urlForExternalId("BioGoMx:Spp-23-0494"), is("http: assertThat(ExternalIdUtil.urlForExternalId("EOL_V2:1234"), is("https: assertThat(ExternalIdUtil.urlForExternalId("PLAZI:99915444-EC70-3196-7F2D-637F418F0730"), is("http: }
public static String urlForExternalId(String externalId) { URI uri = null; String url = null; if (externalId != null) { for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) { String idPrefix = idPrefixToUrlPrefix.getKey(); if (StringUtils.startsWith(externalId, idPrefix)) { if (isIRMNG(idPrefix)) { url = urlForIRMNG(externalId, idPrefix); } else if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) { try { DOI doi = DOI.create(externalId); url = doi.toURI().toString(); } catch (MalformedDOIException e) { LOG.warn("found malformed doi [" + externalId + "]", e); } } else { url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, ""); } String suffix = getURLSuffixMap().get(idPrefix); if (StringUtils.isNotBlank(suffix)) { url = url + suffix; } } if (url != null) { try { URIBuilder uriBuilder = new URIBuilder(url); uri = uriBuilder.build(); } catch (URISyntaxException e) { } break; } } } return uri == null ? null : uri.toString(); }
ExternalIdUtil { public static String urlForExternalId(String externalId) { URI uri = null; String url = null; if (externalId != null) { for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) { String idPrefix = idPrefixToUrlPrefix.getKey(); if (StringUtils.startsWith(externalId, idPrefix)) { if (isIRMNG(idPrefix)) { url = urlForIRMNG(externalId, idPrefix); } else if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) { try { DOI doi = DOI.create(externalId); url = doi.toURI().toString(); } catch (MalformedDOIException e) { LOG.warn("found malformed doi [" + externalId + "]", e); } } else { url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, ""); } String suffix = getURLSuffixMap().get(idPrefix); if (StringUtils.isNotBlank(suffix)) { url = url + suffix; } } if (url != null) { try { URIBuilder uriBuilder = new URIBuilder(url); uri = uriBuilder.build(); } catch (URISyntaxException e) { } break; } } } return uri == null ? null : uri.toString(); } }
ExternalIdUtil { public static String urlForExternalId(String externalId) { URI uri = null; String url = null; if (externalId != null) { for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) { String idPrefix = idPrefixToUrlPrefix.getKey(); if (StringUtils.startsWith(externalId, idPrefix)) { if (isIRMNG(idPrefix)) { url = urlForIRMNG(externalId, idPrefix); } else if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) { try { DOI doi = DOI.create(externalId); url = doi.toURI().toString(); } catch (MalformedDOIException e) { LOG.warn("found malformed doi [" + externalId + "]", e); } } else { url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, ""); } String suffix = getURLSuffixMap().get(idPrefix); if (StringUtils.isNotBlank(suffix)) { url = url + suffix; } } if (url != null) { try { URIBuilder uriBuilder = new URIBuilder(url); uri = uriBuilder.build(); } catch (URISyntaxException e) { } break; } } } return uri == null ? null : uri.toString(); }  }
ExternalIdUtil { public static String urlForExternalId(String externalId) { URI uri = null; String url = null; if (externalId != null) { for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) { String idPrefix = idPrefixToUrlPrefix.getKey(); if (StringUtils.startsWith(externalId, idPrefix)) { if (isIRMNG(idPrefix)) { url = urlForIRMNG(externalId, idPrefix); } else if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) { try { DOI doi = DOI.create(externalId); url = doi.toURI().toString(); } catch (MalformedDOIException e) { LOG.warn("found malformed doi [" + externalId + "]", e); } } else { url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, ""); } String suffix = getURLSuffixMap().get(idPrefix); if (StringUtils.isNotBlank(suffix)) { url = url + suffix; } } if (url != null) { try { URIBuilder uriBuilder = new URIBuilder(url); uri = uriBuilder.build(); } catch (URISyntaxException e) { } break; } } } return uri == null ? null : uri.toString(); }  static String urlForExternalId(String externalId); static boolean isIRMNG(String idPrefix); static String urlForIRMNG(String externalId, String idPrefix); static Map<String, String> getURLPrefixMap(); static Map<String, String> getURLSuffixMap(); static boolean isSupported(String externalId); static TaxonomyProvider taxonomyProviderFor(String externalId); static String getUrlFromExternalId(String jsonString); static String buildJsonUrl(String url); static String toCitation(String contributor, String description, String publicationYear); static String selectValue(Map<String, String> link, String[] candidateIdsInIncreasingPreference); static boolean hasProperty(Map<String, String> link, String propertyName); static String stripPrefix(TaxonomyProvider provider, String externalId); static String prefixForUrl(String url); static boolean isLikelyId(String idCandidate); static boolean isUnlikelyId(String idCandidate); }
ExternalIdUtil { public static String urlForExternalId(String externalId) { URI uri = null; String url = null; if (externalId != null) { for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) { String idPrefix = idPrefixToUrlPrefix.getKey(); if (StringUtils.startsWith(externalId, idPrefix)) { if (isIRMNG(idPrefix)) { url = urlForIRMNG(externalId, idPrefix); } else if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) { try { DOI doi = DOI.create(externalId); url = doi.toURI().toString(); } catch (MalformedDOIException e) { LOG.warn("found malformed doi [" + externalId + "]", e); } } else { url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, ""); } String suffix = getURLSuffixMap().get(idPrefix); if (StringUtils.isNotBlank(suffix)) { url = url + suffix; } } if (url != null) { try { URIBuilder uriBuilder = new URIBuilder(url); uri = uriBuilder.build(); } catch (URISyntaxException e) { } break; } } } return uri == null ? null : uri.toString(); }  static String urlForExternalId(String externalId); static boolean isIRMNG(String idPrefix); static String urlForIRMNG(String externalId, String idPrefix); static Map<String, String> getURLPrefixMap(); static Map<String, String> getURLSuffixMap(); static boolean isSupported(String externalId); static TaxonomyProvider taxonomyProviderFor(String externalId); static String getUrlFromExternalId(String jsonString); static String buildJsonUrl(String url); static String toCitation(String contributor, String description, String publicationYear); static String selectValue(Map<String, String> link, String[] candidateIdsInIncreasingPreference); static boolean hasProperty(Map<String, String> link, String propertyName); static String stripPrefix(TaxonomyProvider provider, String externalId); static String prefixForUrl(String url); static boolean isLikelyId(String idCandidate); static boolean isUnlikelyId(String idCandidate);  }