1
1
/*
2
2
* Kuali Coeus, a comprehensive research administration system for higher education.
3
3
*
4
- * Copyright 2005-2015 Kuali, Inc.
4
+ * Copyright 2005-2016 Kuali, Inc.
5
5
*
6
6
* This program is free software: you can redistribute it and/or modify
7
7
* it under the terms of the GNU Affero General Public License as
18
18
*/
19
19
package org .kuali .kra .award .lookup ;
20
20
21
+ import org .apache .commons .collections4 .ListUtils ;
21
22
import org .apache .commons .lang3 .StringUtils ;
22
23
import org .kuali .coeus .common .framework .person .KcPerson ;
23
24
import org .kuali .coeus .common .framework .person .KcPersonService ;
@@ -82,25 +83,28 @@ public List<? extends BusinessObject> getSearchResults(Map<String, String> field
82
83
}
83
84
84
85
boolean usePrimaryKeys = getLookupService ().allPrimaryKeyValuesPresentAndNotWildcard (Award .class , fieldValues );
85
-
86
+
86
87
setBackLocation (fieldValues .get (KRADConstants .BACK_LOCATION ));
87
88
setDocFormKey (fieldValues .get (KRADConstants .DOC_FORM_KEY ));
88
89
setReferencesToRefresh (fieldValues .get (KRADConstants .REFERENCES_TO_REFRESH ));
89
90
90
91
if (StringUtils .isNotBlank (fieldValues .get (IP_NUMBER_FIELD ))) {
91
- List < String > awardNumbers =
92
+ String awardNumbers =
92
93
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 );
97
101
fieldValues .remove (IP_NUMBER_FIELD );
98
102
}
99
103
100
104
List <Award > unboundedResults = (List <Award >)getAwardLookupDao ().getAwardSearchResults (fieldValues , usePrimaryKeys );
101
-
105
+
102
106
List <Award > filteredResults = new ArrayList <Award >();
103
-
107
+
104
108
filteredResults = (List <Award >) filterForPermissions (unboundedResults );
105
109
if (unboundedResults instanceof CollectionIncomplete ) {
106
110
filteredResults = new CollectionIncomplete <Award >(
@@ -162,7 +166,7 @@ else if (field.getPropertyName().equals(OSP_ADMIN_USERNAME_PATH)) {
162
166
}
163
167
return rows ;
164
168
}
165
-
169
+
166
170
/**
167
171
* Sets the KC Person Service.
168
172
* @param kcPersonService the kc person service
@@ -183,7 +187,7 @@ public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
183
187
if (propertyName .equals (UNIT_NUMBER )) {
184
188
inquiryUrl = getUnitNumberInquiryUrl (award );
185
189
} else if (propertyName .equals (PI_NAME )) {
186
- inquiryUrl = getPrincipalInvestigatorNameInquiryUrl (award );
190
+ inquiryUrl = getPrincipalInvestigatorNameInquiryUrl (award );
187
191
} else if (propertyName .equals (OSP_ADMIN_NAME )) {
188
192
inquiryUrl = getOspAdminNameInquiryUrl (award );
189
193
}
@@ -210,7 +214,7 @@ protected AnchorHtmlData getOpenLink(Award award, Boolean viewOnly) {
210
214
htmlData .setHref (href );
211
215
return htmlData ;
212
216
}
213
-
217
+
214
218
protected AnchorHtmlData getMedusaLink (Award award , Boolean readOnly ) {
215
219
AnchorHtmlData htmlData = new AnchorHtmlData ();
216
220
htmlData .setDisplayText (MEDUSA );
@@ -223,11 +227,11 @@ protected AnchorHtmlData getMedusaLink(Award award, Boolean readOnly) {
223
227
parameters .put ("docOpenedFromAwardSearch" , "true" );
224
228
parameters .put ("placeHolderAwardId" , award .getAwardId ().toString ());
225
229
String href = UrlFactory .parameterizeUrl ("../" +getHtmlAction (), parameters );
226
-
230
+
227
231
htmlData .setHref (href );
228
232
return htmlData ;
229
- }
230
-
233
+ }
234
+
231
235
protected AnchorHtmlData getCopyLink (Award award , Boolean readOnly ) {
232
236
AnchorHtmlData htmlData = new AnchorHtmlData ();
233
237
htmlData .setDisplayText ("copy" );
@@ -240,11 +244,11 @@ protected AnchorHtmlData getCopyLink(Award award, Boolean readOnly) {
240
244
parameters .put ("docOpenedFromAwardSearch" , "true" );
241
245
parameters .put ("placeHolderAwardId" , award .getAwardId ().toString ());
242
246
String href = UrlFactory .parameterizeUrl ("../" +getHtmlAction (), parameters );
243
-
247
+
244
248
htmlData .setHref (href );
245
249
return htmlData ;
246
250
}
247
-
251
+
248
252
protected HtmlData getOspAdminNameInquiryUrl (Award award ) {
249
253
KcPerson ospAdministrator = award .getOspAdministrator ();
250
254
if (ospAdministrator != null ) {
@@ -261,8 +265,8 @@ protected HtmlData getPrincipalInvestigatorNameInquiryUrl(Award award) {
261
265
if (principalInvestigator != null ) {
262
266
if (StringUtils .isNotBlank (principalInvestigator .getPersonId ())) {
263
267
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 );
266
270
}
267
271
catch (IllegalArgumentException e ) {
268
272
LOG .info ("getPrincipalInvestigatorNameInquiryUrl(Award award): ignoring missing person/entity: "
@@ -275,7 +279,7 @@ protected HtmlData getPrincipalInvestigatorNameInquiryUrl(Award award) {
275
279
inquiryUrl = super .getInquiryUrl (inqBo , ROLODEX_ID );
276
280
}
277
281
}
278
-
282
+
279
283
}
280
284
return inquiryUrl ;
281
285
}
@@ -291,10 +295,10 @@ protected HtmlData getUnitNumberInquiryUrl(Award award) {
291
295
protected String getHtmlAction () {
292
296
return "awardHome.do" ;
293
297
}
294
-
298
+
295
299
/**
296
300
* @see org.kuali.kra.lookup.KraLookupableHelperServiceImpl#createdEditHtmlData(org.kuali.rice.krad.bo.BusinessObject)
297
- *
301
+ *
298
302
* Edit is not supported for Award lookup, so we'll just no-op
299
303
*/
300
304
@ Override
@@ -306,7 +310,7 @@ protected void addEditHtmlData(List<HtmlData> htmlDataList, BusinessObject busin
306
310
protected String getDocumentTypeName () {
307
311
return "AwardDocument" ;
308
312
}
309
-
313
+
310
314
@ Override
311
315
protected String getKeyFieldName () {
312
316
return "awardId" ;
0 commit comments