View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.document.authorization;
17  
18  import java.util.Set;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.ole.pdp.PdpPropertyConstants;
22  import org.kuali.ole.pdp.PdpConstants.PayeeIdTypeCodes;
23  import org.kuali.ole.pdp.businessobject.PayeeACHAccount;
24  import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
25  import org.kuali.rice.kns.document.MaintenanceDocument;
26  
27  public class PayeeACHAccountMaintenanceDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase {
28      /**
29       * Adds the payeeEmailAddress field as readOnly if payee type is Employee or Entity.
30       * @see org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.rice.kns.document.MaintenanceDocument)
31       */
32      @Override
33      public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
34          Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
35          
36          PayeeACHAccount payeeAccount = (PayeeACHAccount)document.getNewMaintainableObject().getBusinessObject();
37          String payeeIdTypeCode = payeeAccount.getPayeeIdentifierTypeCode();
38  
39          // make name and email address readOnly if payee type is Employee or Entity
40          if (StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.EMPLOYEE) ||
41                  StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.ENTITY)) {
42              readOnlyPropertyNames.add(PdpPropertyConstants.PAYEE_NAME);
43              readOnlyPropertyNames.add(PdpPropertyConstants.PAYEE_EMAIL_ADDRESS);
44          }
45          // make name readOnly if payee type is Vendor
46          else if (StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.VENDOR_ID)) {
47              readOnlyPropertyNames.add(PdpPropertyConstants.PAYEE_NAME);
48          }
49          
50          return readOnlyPropertyNames;                
51      }
52  
53  }