Example #1
0
  /**
   * Returns the display string for the supplied uid
   *
   * @param uid
   * @return a user friendly display name for this UID
   */
  public String getUidDisplayString(String fieldName, String uid, boolean includeField) {

    uid = stripEscapedQuotes(uid);

    // get the information from the collections cache
    if (uid.startsWith("in") && collectionCache.getInstitutions().containsKey(uid)) {
      if (includeField) return "Institution: " + collectionCache.getInstitutions().get(uid);
      else return collectionCache.getInstitutions().get(uid);
    } else if (uid.startsWith("co") && collectionCache.getCollections().containsKey(uid)) {
      if (includeField) return "Collection: " + collectionCache.getCollections().get(uid);
      else return collectionCache.getCollections().get(uid);
    } else if (uid.startsWith("drt") && collectionCache.getTempDataResources().containsKey(uid)) {
      if (includeField)
        return "Temporary Data resource: " + collectionCache.getTempDataResources().get(uid);
      else return collectionCache.getTempDataResources().get(uid);
    } else if (uid.startsWith("dr") && collectionCache.getDataResources().containsKey(uid)) {
      if (includeField) return "Data resource: " + collectionCache.getDataResources().get(uid);
      else return collectionCache.getDataResources().get(uid);
    } else if (uid.startsWith("dp") && collectionCache.getDataProviders().containsKey(uid)) {
      if (includeField) return "Data provider: " + collectionCache.getDataProviders().get(uid);
      else return collectionCache.getDataProviders().get(uid);
    } else if (uid.startsWith("dh") && collectionCache.getDataHubs().containsKey(uid)) {
      if (includeField) return "Data hub: " + collectionCache.getDataHubs().get(uid);
      else return collectionCache.getDataHubs().get(uid);
    }
    return messageSource.getMessage(
        fieldName + "." + StringUtils.remove(uid, "\""), null, uid, null);
  }