- /**
- * Formats and returns a list of dynamic href links
- *
- * @param seq
- * @param urlLink
- * @param uniques
- */
- List<String[]> createDynamicLinks(SequenceI seq, UrlLink urlLink,
- List<String> uniques)
- {
- List<String[]> result = new ArrayList<String[]>();
- final String target = urlLink.getTarget();
- final String label = urlLink.getLabel();
-
- // collect matching db-refs
- DBRefEntry[] dbr = DBRefUtils.selectRefs(seq.getDBRefs(),
- new String[] { target });
- // collect id string too
- String id = seq.getName();
- String descr = seq.getDescription();
- if (descr != null && descr.length() < 1)
- {
- descr = null;
- }
- if (dbr != null)
- {
- for (int r = 0; r < dbr.length; r++)
- {
- if (id != null && dbr[r].getAccessionId().equals(id))
- {
- // suppress duplicate link creation for the bare sequence ID
- // string with this link
- id = null;
- }
- // create Bare ID link for this URL
- String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(), true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- String unq = urls[u] + "|" + urls[u + 1];
- if (!uniques.contains(unq))
- {
- result.add(new String[] { target, label, urls[u],
- urls[u + 1] });
- uniques.add(unq);
- }
- }
- }
- }
- }
- if (id != null)
- {
- // create Bare ID link for this URL
- String[] urls = urlLink.makeUrls(id, true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- String unq = urls[u] + "|" + urls[u + 1];
- if (!uniques.contains(unq))
- {
- result.add(new String[] { target, label, urls[u],
- urls[u + 1] });
- uniques.add(unq);
- }
- }
- }
- }
- if (descr != null && urlLink.getRegexReplace() != null)
- {
- // create link for this URL from description only if regex matches
- String[] urls = urlLink.makeUrls(descr, true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- String unq = urls[u] + "|" + urls[u + 1];
- if (!uniques.contains(unq))
- {
- result.add(new String[] { target, label, urls[u],
- urls[u + 1] });
- uniques.add(unq);
- }
- }
- }
- }
- return result;