001/*
002 * Copyright 2012 The Kuali Foundation.
003 * 
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 * http://www.opensource.org/licenses/ecl2.php
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.pdp.businessobject.lookup;
017
018import java.util.ArrayList;
019import java.util.List;
020
021import org.apache.commons.lang.StringUtils;
022import org.kuali.ole.fp.businessobject.lookup.AbstractPayeeLookupableHelperServiceImpl;
023import org.kuali.ole.pdp.PdpPropertyConstants;
024import org.kuali.rice.kns.lookup.HtmlData;
025import org.kuali.rice.krad.bo.BusinessObject;
026import org.kuali.rice.krad.util.KRADConstants;
027
028public class PayeeACHAccountLookupableHelperServiceImpl extends AbstractPayeeLookupableHelperServiceImpl {
029    
030    /**
031     * @see AbstractPayeeLookupableHelperServiceImpl#allowsMaintenanceNewOrCopyAction
032     * Allows copy on a PayeeACHAccount record only if edit is allowed on the record.
033     */
034    @Override
035    public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
036        List<HtmlData> htmlDataList = new ArrayList<HtmlData>();
037        if (allowsMaintenanceEditAction(businessObject)) {
038            htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames));
039        }
040        if (allowsMaintenanceNewOrCopyAction() && allowsMaintenanceEditAction(businessObject)) {
041            htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames));
042        }
043        if (allowsMaintenanceDeleteAction(businessObject)) {
044            htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_DELETE_METHOD_TO_CALL, pkNames));
045        }
046        return htmlDataList;
047    }
048
049    /**
050     * @see AbstractPayeeLookupableHelperServiceImpl#getInquiryUrl
051     * For payeeName, creates an inquiry link for the PayeeACHAccount record only if the user is allowed to inquire the record.
052     */
053    @Override
054    public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
055        // for properties other than payeeName, or if the user is allowed to inquire the record, return inquiry link as done in super
056        // NOTE: Since we don't have separate permission for inquiring PayeeACHAccount, we regard the permission for inquiry as equivalent to the permission for edit.
057        if (!StringUtils.equals(PdpPropertyConstants.PAYEE_NAME, propertyName) || allowsMaintenanceEditAction(bo)) 
058            return super.getInquiryUrl(bo, propertyName);
059
060        // otherwise return empty inquiry link 
061        return new HtmlData.AnchorHtmlData();
062    }
063}