View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.cam.document.validation.impl;
20  
21  import org.kuali.kfs.module.cam.CamsKeyConstants;
22  import org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail;
23  import org.kuali.kfs.module.cam.document.service.AssetPaymentService;
24  import org.kuali.kfs.sys.document.validation.GenericValidation;
25  import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  import org.kuali.rice.krad.util.ObjectUtils;
28  
29  /**
30   * 
31   * This class validates if asset# typed in the asset textbox isn't blank, and validate its wasn't already added in the collection
32   *  
33   */
34  public class AssetPaymentAddAssetValidation extends GenericValidation {
35      private AssetPaymentService assetPaymentService;
36      private AssetPaymentAssetDetail assetPaymentAssetDetailForValidation;
37      
38      /**
39       *  
40       * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
41       */
42      public boolean validate(AttributedDocumentEvent event) {
43          String errorPath = event.getErrorPathPrefix();
44          
45          //Validating the asset exists in the asset table.
46          if (ObjectUtils.isNull(this.getAssetPaymentAssetDetailForValidation().getAsset())) {
47              GlobalVariables.getMessageMap().putError(errorPath, CamsKeyConstants.AssetLocationGlobal.ERROR_INVALID_CAPITAL_ASSET_NUMBER, this.getAssetPaymentAssetDetailForValidation().getCapitalAssetNumber().toString());
48              return false;
49          }
50          return this.getAssetPaymentService().validateAssets(errorPath, this.getAssetPaymentAssetDetailForValidation().getAsset());
51      }
52  
53      public AssetPaymentAssetDetail getAssetPaymentAssetDetailForValidation() {
54          return assetPaymentAssetDetailForValidation;
55      }
56  
57      public void setAssetPaymentAssetDetailForValidation(AssetPaymentAssetDetail assetPaymentAssetDetailForValidation) {
58          this.assetPaymentAssetDetailForValidation = assetPaymentAssetDetailForValidation;
59      }
60      
61      public AssetPaymentService getAssetPaymentService() {
62          return assetPaymentService;
63      }
64  
65      public void setAssetPaymentService(AssetPaymentService assetPaymentService) {
66          this.assetPaymentService = assetPaymentService;
67      }    
68  }