View Javadoc
1   /*
2    * Copyright 2012 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.pdp.businessobject.lookup;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.ole.fp.businessobject.lookup.AbstractPayeeLookupableHelperServiceImpl;
23  import org.kuali.ole.pdp.PdpPropertyConstants;
24  import org.kuali.rice.kns.lookup.HtmlData;
25  import org.kuali.rice.krad.bo.BusinessObject;
26  import org.kuali.rice.krad.util.KRADConstants;
27  
28  public class PayeeACHAccountLookupableHelperServiceImpl extends AbstractPayeeLookupableHelperServiceImpl {
29      
30      /**
31       * @see AbstractPayeeLookupableHelperServiceImpl#allowsMaintenanceNewOrCopyAction
32       * Allows copy on a PayeeACHAccount record only if edit is allowed on the record.
33       */
34      @Override
35      public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
36          List<HtmlData> htmlDataList = new ArrayList<HtmlData>();
37          if (allowsMaintenanceEditAction(businessObject)) {
38              htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames));
39          }
40          if (allowsMaintenanceNewOrCopyAction() && allowsMaintenanceEditAction(businessObject)) {
41              htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames));
42          }
43          if (allowsMaintenanceDeleteAction(businessObject)) {
44              htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_DELETE_METHOD_TO_CALL, pkNames));
45          }
46          return htmlDataList;
47      }
48  
49      /**
50       * @see AbstractPayeeLookupableHelperServiceImpl#getInquiryUrl
51       * For payeeName, creates an inquiry link for the PayeeACHAccount record only if the user is allowed to inquire the record.
52       */
53      @Override
54      public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
55          // for properties other than payeeName, or if the user is allowed to inquire the record, return inquiry link as done in super
56          // NOTE: Since we don't have separate permission for inquiring PayeeACHAccount, we regard the permission for inquiry as equivalent to the permission for edit.
57          if (!StringUtils.equals(PdpPropertyConstants.PAYEE_NAME, propertyName) || allowsMaintenanceEditAction(bo)) 
58              return super.getInquiryUrl(bo, propertyName);
59  
60          // otherwise return empty inquiry link 
61          return new HtmlData.AnchorHtmlData();
62      }
63  }