View Javadoc
1   /*
2    * Copyright 2008-2009 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.module.purap.document.validation.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.module.purap.PurapKeyConstants;
20  import org.kuali.ole.module.purap.PurapPropertyConstants;
21  import org.kuali.ole.module.purap.businessobject.PurchaseOrderVendorStipulation;
22  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
23  import org.kuali.ole.sys.OLEConstants;
24  import org.kuali.ole.sys.document.validation.GenericValidation;
25  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  
28  import java.util.List;
29  
30  public class PurchaseOrderProcessVendorStipulationValidation extends GenericValidation {
31  
32      /**
33       * Validation for the Stipulation tab.
34       *
35       * @param poDocument the purchase order document to be validated
36       * @return boolean false if the vendor stipulation description is blank.
37       */
38      public boolean validate(AttributedDocumentEvent event) {
39          boolean valid = true;
40          List<PurchaseOrderVendorStipulation> stipulations = ((PurchaseOrderDocument) event.getDocument()).getPurchaseOrderVendorStipulations();
41          for (int i = 0; i < stipulations.size(); i++) {
42              PurchaseOrderVendorStipulation stipulation = stipulations.get(i);
43              if (StringUtils.isBlank(stipulation.getVendorStipulationDescription())) {
44                  GlobalVariables.getMessageMap().putError(OLEConstants.DOCUMENT_PROPERTY_NAME + "." + PurapPropertyConstants.VENDOR_STIPULATION + "[" + i + "]." + PurapPropertyConstants.VENDOR_STIPULATION_DESCRIPTION, PurapKeyConstants.ERROR_STIPULATION_DESCRIPTION);
45                  valid = false;
46              }
47          }
48  
49          return valid;
50      }
51  
52  }