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.fp.document.ProcurementCardDocument;
19  import org.kuali.ole.sys.OLEPropertyConstants;
20  import org.kuali.ole.sys.businessobject.AccountingLine;
21  import org.kuali.ole.sys.document.validation.GenericValidation;
22  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23  import org.kuali.rice.krad.util.GlobalVariables;
24  import org.kuali.rice.krad.util.MessageMap;
25  import org.kuali.rice.krad.util.ObjectUtils;
26  
27  /**
28   * Validates that an accounting line does not have a capital object object code 
29   */
30  public class ProcurementCardAccountNumberValidation extends GenericValidation {
31      private AccountingLine accountingLineForValidation;
32  
33      /**
34       * Validates that an accounting line does not have a capital object object code
35       * <strong>Expects an accounting line as the first a parameter</strong>
36       * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
37       */
38      public boolean validate(AttributedDocumentEvent event) {
39          ProcurementCardDocument pcDocument = (ProcurementCardDocument) event.getDocument();
40          AccountingLine accountingLine = getAccountingLineForValidation();
41          MessageMap errors = GlobalVariables.getMessageMap();
42  
43          String errorKey = OLEPropertyConstants.ACCOUNT_NUMBER;
44          boolean accountNumberAllowed = true;
45  
46          /* account exist and object exist done in super, check we have a valid object */
47          if (ObjectUtils.isNull(accountingLine.getAccount()) || ObjectUtils.isNull(accountingLine.getObjectCode())) {
48              return false;
49          }
50  
51          return accountNumberAllowed;
52      }
53  
54  
55      /**
56       * Gets the accountingLineForValidation attribute. 
57       * @return Returns the accountingLineForValidation.
58       */
59      public AccountingLine getAccountingLineForValidation() {
60          return accountingLineForValidation;
61      }
62  
63      /**
64       * Sets the accountingLineForValidation attribute value.
65       * @param accountingLineForValidation The accountingLineForValidation to set.
66       */
67      public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
68          this.accountingLineForValidation = accountingLineForValidation;
69      }
70  }