1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.module.tem.businessobject.lookup;
20
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.kuali.kfs.module.tem.businessobject.PerDiem;
26 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationController;
27 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
28 import org.kuali.rice.kns.lookup.LookupUtils;
29 import org.kuali.rice.krad.bo.BusinessObject;
30 import org.kuali.rice.krad.lookup.CollectionIncomplete;
31 import org.kuali.rice.krad.service.DocumentDictionaryService;
32
33
34 @SuppressWarnings("deprecation")
35 public class PerDiemLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
36 protected DocumentDictionaryService documentDictionaryService;
37
38
39
40
41 @SuppressWarnings("rawtypes")
42 @Override
43 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
44 List<PerDiem> results = (List<PerDiem>) super.getSearchResultsHelper(fieldValues, true);
45
46
47 CollectionIncomplete collection = null;
48 Integer limit = LookupUtils.getSearchResultsLimit(PerDiem.class);
49 if (results.size() > limit.intValue()){
50 collection = new CollectionIncomplete(results.subList(0, limit), (long) results.size());
51 }
52 else{
53 collection = new CollectionIncomplete(results, (long) 0);
54 }
55 return collection;
56 }
57
58 @Override
59 protected boolean allowsMaintenanceEditAction(BusinessObject businessObject) {
60 String maintDocTypeName = getMaintenanceDocumentTypeName();
61
62 if (StringUtils.isNotBlank(maintDocTypeName)) {
63 final MaintenanceDocumentPresentationController docPresentationController = (MaintenanceDocumentPresentationController)getDocumentDictionaryService().getDocumentPresentationController(maintDocTypeName);
64 final boolean allowsEdit = docPresentationController.canMaintain(businessObject);
65 if (!allowsEdit) {
66 return false;
67 }
68 }
69 return super.allowsMaintenanceEditAction(businessObject);
70 }
71
72 public DocumentDictionaryService getDocumentDictionaryService() {
73 return documentDictionaryService;
74 }
75
76 public void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService) {
77 this.documentDictionaryService = documentDictionaryService;
78 }
79 }