001/*
002 * Copyright 2011 The Kuali Foundation.
003 * 
004 * Licensed under the Educational Community License, Version 1.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/ecl1.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.document.authorization;
017
018import java.util.Set;
019
020import org.apache.commons.lang.StringUtils;
021import org.kuali.ole.pdp.PdpPropertyConstants;
022import org.kuali.ole.pdp.PdpConstants.PayeeIdTypeCodes;
023import org.kuali.ole.pdp.businessobject.PayeeACHAccount;
024import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
025import org.kuali.rice.kns.document.MaintenanceDocument;
026
027public class PayeeACHAccountMaintenanceDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase {
028    /**
029     * Adds the payeeEmailAddress field as readOnly if payee type is Employee or Entity.
030     * @see org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.rice.kns.document.MaintenanceDocument)
031     */
032    @Override
033    public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
034        Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
035        
036        PayeeACHAccount payeeAccount = (PayeeACHAccount)document.getNewMaintainableObject().getBusinessObject();
037        String payeeIdTypeCode = payeeAccount.getPayeeIdentifierTypeCode();
038
039        // make name and email address readOnly if payee type is Employee or Entity
040        if (StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.EMPLOYEE) ||
041                StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.ENTITY)) {
042            readOnlyPropertyNames.add(PdpPropertyConstants.PAYEE_NAME);
043            readOnlyPropertyNames.add(PdpPropertyConstants.PAYEE_EMAIL_ADDRESS);
044        }
045        // make name readOnly if payee type is Vendor
046        else if (StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.VENDOR_ID)) {
047            readOnlyPropertyNames.add(PdpPropertyConstants.PAYEE_NAME);
048        }
049        
050        return readOnlyPropertyNames;                
051    }
052
053}