11/*
22 * Kuali Coeus, a comprehensive research administration system for higher education.
33 *
4- * Copyright 2005-2015 Kuali, Inc.
4+ * Copyright 2005-2016 Kuali, Inc.
55 *
66 * This program is free software: you can redistribute it and/or modify
77 * it under the terms of the GNU Affero General Public License as
1818 */
1919package org .kuali .kra .award .lookup ;
2020
21+ import org .apache .commons .collections4 .ListUtils ;
2122import org .apache .commons .lang3 .StringUtils ;
2223import org .kuali .coeus .common .framework .person .KcPerson ;
2324import org .kuali .coeus .common .framework .person .KcPersonService ;
@@ -82,25 +83,28 @@ public List<? extends BusinessObject> getSearchResults(Map<String, String> field
8283 }
8384
8485 boolean usePrimaryKeys = getLookupService ().allPrimaryKeyValuesPresentAndNotWildcard (Award .class , fieldValues );
85-
86+
8687 setBackLocation (fieldValues .get (KRADConstants .BACK_LOCATION ));
8788 setDocFormKey (fieldValues .get (KRADConstants .DOC_FORM_KEY ));
8889 setReferencesToRefresh (fieldValues .get (KRADConstants .REFERENCES_TO_REFRESH ));
8990
9091 if (StringUtils .isNotBlank (fieldValues .get (IP_NUMBER_FIELD ))) {
91- List < String > awardNumbers =
92+ String awardNumbers =
9293 getBusinessObjectService ().findMatching (AwardFundingProposal .class , Collections .singletonMap ("proposal.proposalNumber" , fieldValues .get (IP_NUMBER_FIELD )))
93- .stream ()
94- .map (afp -> afp .getAward ().getAwardNumber ())
95- .collect (Collectors .toList ());
96- fieldValues .put ("awardNumber" , StringUtils .join (awardNumbers , '|' ));
94+ .stream ()
95+ .map (afp -> afp .getAward ().getAwardNumber ())
96+ .collect (Collectors .joining ("|" ));
97+ if (StringUtils .isBlank (awardNumbers )) {
98+ return new ArrayList <>();
99+ }
100+ fieldValues .put ("awardNumber" , awardNumbers );
97101 fieldValues .remove (IP_NUMBER_FIELD );
98102 }
99103
100104 List <Award > unboundedResults = (List <Award >)getAwardLookupDao ().getAwardSearchResults (fieldValues , usePrimaryKeys );
101-
105+
102106 List <Award > filteredResults = new ArrayList <Award >();
103-
107+
104108 filteredResults = (List <Award >) filterForPermissions (unboundedResults );
105109 if (unboundedResults instanceof CollectionIncomplete ) {
106110 filteredResults = new CollectionIncomplete <Award >(
@@ -162,7 +166,7 @@ else if (field.getPropertyName().equals(OSP_ADMIN_USERNAME_PATH)) {
162166 }
163167 return rows ;
164168 }
165-
169+
166170 /**
167171 * Sets the KC Person Service.
168172 * @param kcPersonService the kc person service
@@ -183,7 +187,7 @@ public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
183187 if (propertyName .equals (UNIT_NUMBER )) {
184188 inquiryUrl = getUnitNumberInquiryUrl (award );
185189 } else if (propertyName .equals (PI_NAME )) {
186- inquiryUrl = getPrincipalInvestigatorNameInquiryUrl (award );
190+ inquiryUrl = getPrincipalInvestigatorNameInquiryUrl (award );
187191 } else if (propertyName .equals (OSP_ADMIN_NAME )) {
188192 inquiryUrl = getOspAdminNameInquiryUrl (award );
189193 }
@@ -210,7 +214,7 @@ protected AnchorHtmlData getOpenLink(Award award, Boolean viewOnly) {
210214 htmlData .setHref (href );
211215 return htmlData ;
212216 }
213-
217+
214218 protected AnchorHtmlData getMedusaLink (Award award , Boolean readOnly ) {
215219 AnchorHtmlData htmlData = new AnchorHtmlData ();
216220 htmlData .setDisplayText (MEDUSA );
@@ -223,11 +227,11 @@ protected AnchorHtmlData getMedusaLink(Award award, Boolean readOnly) {
223227 parameters .put ("docOpenedFromAwardSearch" , "true" );
224228 parameters .put ("placeHolderAwardId" , award .getAwardId ().toString ());
225229 String href = UrlFactory .parameterizeUrl ("../" +getHtmlAction (), parameters );
226-
230+
227231 htmlData .setHref (href );
228232 return htmlData ;
229- }
230-
233+ }
234+
231235 protected AnchorHtmlData getCopyLink (Award award , Boolean readOnly ) {
232236 AnchorHtmlData htmlData = new AnchorHtmlData ();
233237 htmlData .setDisplayText ("copy" );
@@ -240,11 +244,11 @@ protected AnchorHtmlData getCopyLink(Award award, Boolean readOnly) {
240244 parameters .put ("docOpenedFromAwardSearch" , "true" );
241245 parameters .put ("placeHolderAwardId" , award .getAwardId ().toString ());
242246 String href = UrlFactory .parameterizeUrl ("../" +getHtmlAction (), parameters );
243-
247+
244248 htmlData .setHref (href );
245249 return htmlData ;
246250 }
247-
251+
248252 protected HtmlData getOspAdminNameInquiryUrl (Award award ) {
249253 KcPerson ospAdministrator = award .getOspAdministrator ();
250254 if (ospAdministrator != null ) {
@@ -261,8 +265,8 @@ protected HtmlData getPrincipalInvestigatorNameInquiryUrl(Award award) {
261265 if (principalInvestigator != null ) {
262266 if (StringUtils .isNotBlank (principalInvestigator .getPersonId ())) {
263267 try {
264- final KcPerson inqBo = this .kcPersonService .getKcPersonByPersonId (principalInvestigator .getPersonId ());
265- inquiryUrl = super .getInquiryUrl (inqBo , PERSON_ID );
268+ final KcPerson inqBo = this .kcPersonService .getKcPersonByPersonId (principalInvestigator .getPersonId ());
269+ inquiryUrl = super .getInquiryUrl (inqBo , PERSON_ID );
266270 }
267271 catch (IllegalArgumentException e ) {
268272 LOG .info ("getPrincipalInvestigatorNameInquiryUrl(Award award): ignoring missing person/entity: "
@@ -275,7 +279,7 @@ protected HtmlData getPrincipalInvestigatorNameInquiryUrl(Award award) {
275279 inquiryUrl = super .getInquiryUrl (inqBo , ROLODEX_ID );
276280 }
277281 }
278-
282+
279283 }
280284 return inquiryUrl ;
281285 }
@@ -291,10 +295,10 @@ protected HtmlData getUnitNumberInquiryUrl(Award award) {
291295 protected String getHtmlAction () {
292296 return "awardHome.do" ;
293297 }
294-
298+
295299 /**
296300 * @see org.kuali.kra.lookup.KraLookupableHelperServiceImpl#createdEditHtmlData(org.kuali.rice.krad.bo.BusinessObject)
297- *
301+ *
298302 * Edit is not supported for Award lookup, so we'll just no-op
299303 */
300304 @ Override
@@ -306,7 +310,7 @@ protected void addEditHtmlData(List<HtmlData> htmlDataList, BusinessObject busin
306310 protected String getDocumentTypeName () {
307311 return "AwardDocument" ;
308312 }
309-
313+
310314 @ Override
311315 protected String getKeyFieldName () {
312316 return "awardId" ;
0 commit comments