/*
   * We want to allow users to query on principal name instead of person id,
   * so we need to translate before performing the lookup.
   */
  @SuppressWarnings("unchecked")
  @Override
  public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded) {
    String userName = (String) lookupForm.getFieldsForLookup().get(USERNAME_FIELD);
    lookupForm.getFieldsForLookup().remove(FOR_INSTITUTIONAL_PROPOSAL);

    if (!StringUtils.isBlank(userName)) {
      KcPerson person = getKcPersonService().getKcPersonByUserName(userName);
      if (person != null) {
        lookupForm.getFieldsForLookup().put(PI_ID, person.getPersonId());
      }
      lookupForm.getFieldsForLookup().remove(USERNAME_FIELD);
    }
    List<ProposalLog> results =
        (List<ProposalLog>) super.performLookup(lookupForm, resultTable, bounded);
    if (StringUtils.containsIgnoreCase(lookupForm.getBackLocation(), NEGOTIATION_NEGOTIATION)) {
      return cleanSearchResultsForNegotiationLookup(results);
    } else {
      return results;
    }
  }