Exemplo n.º 1
0
 public void setPreparer(KcPerson preparer) {
   this.preparer = preparer;
   if (preparer != null) {
     preparerId = preparer.getPersonId();
     preparerName = preparer.getFullName();
   } else {
     preparerId = null;
     preparerName = null;
   }
 }
  /*
   * 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;
    }
  }
 private boolean hasPermission(String nameSpace, String permissionName) {
   KcPerson person = getKcPersonService().getKcPersonByUserName(getUserName());
   return getUnitAuthorizationService()
       .hasPermission(person.getPersonId(), nameSpace, permissionName);
 }