View Javadoc
1   /*
2    * Copyright 2008 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.fp.document.validation.impl;
17  
18  import org.kuali.ole.sys.OLEKeyConstants;
19  import org.kuali.ole.sys.document.service.DebitDeterminerService;
20  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
21  import org.kuali.ole.sys.document.validation.impl.AccountingLineValueAllowedValidation;
22  import org.kuali.rice.krad.util.GlobalVariables;
23  
24  /**
25   * A validation for the transfer of funds document that makes sure that an object code in any accounting line represents either income or expense.
26   */
27  public class TransferOfFundsObjectCodeValueAllowedValidation extends AccountingLineValueAllowedValidation {
28      private DebitDeterminerService debitDeterminerService;
29  
30      /**
31       * Overrides the parent to make sure that the chosen object code's object code is Income/Expense.
32       * @see org.kuali.ole.sys.document.validation.impl.AccountingLineValueAllowedValidation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
33       */
34      @Override
35      public boolean validate(AttributedDocumentEvent event) {
36          // TODO JAMES DO WE NEED THIS YET?
37          boolean isObjectCodeAllowed = super.validate(event);
38  
39          if (!debitDeterminerService.isIncome(getAccountingLineForValidation()) && !debitDeterminerService.isExpense(getAccountingLineForValidation())) {
40              GlobalVariables.getMessageMap().putError("financialObjectCode", OLEKeyConstants.ERROR_DOCUMENT_TOF_INVALID_OBJECT_TYPE_CODES, new String[] { getAccountingLineForValidation().getObjectCode().getFinancialObjectTypeCode(), getAccountingLineForValidation().getObjectCode().getFinancialObjectSubTypeCode() });
41              isObjectCodeAllowed = false;
42          }
43  
44          return isObjectCodeAllowed;
45      }
46  
47      /**
48       * Gets the debitDeterminerService attribute. 
49       * @return Returns the debitDeterminerService.
50       */
51      public DebitDeterminerService getDebitDeterminerService() {
52          return debitDeterminerService;
53      }
54  
55      /**
56       * Sets the debitDeterminerService attribute value.
57       * @param debitDeterminerService The debitDeterminerService to set.
58       */
59      public void setDebitDeterminerService(DebitDeterminerService debitDeterminerService) {
60          this.debitDeterminerService = debitDeterminerService;
61      }
62  }