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.module.purap.document.validation.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.module.purap.PurapConstants;
20  import org.kuali.ole.module.purap.PurapKeyConstants;
21  import org.kuali.ole.module.purap.PurapPropertyConstants;
22  import org.kuali.ole.module.purap.document.PurchasingDocument;
23  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  import org.kuali.rice.krad.util.MessageMap;
26  
27  /**
28   * Performs validations for the requestor's email address and phone number.
29   */
30  public class PurchasingProcessRequestorPhoneAndEmailAddressValidation extends PurchasingAccountsPayableProcessVendorValidation {
31  
32      @Override
33      public boolean validate(AttributedDocumentEvent event) {
34          boolean valid = true;
35          PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
36          MessageMap errorMap = GlobalVariables.getMessageMap();
37          errorMap.clearErrorPath();
38          errorMap.addToErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
39  
40          valid &= super.validate(event);
41  
42          /*//perform the validation against phone Number
43          if (StringUtils.isNotBlank(purDocument.getRequestorPersonPhoneNumber())) {
44              if (!validatePhoneNumber(purDocument.getRequestorPersonPhoneNumber())) {
45                  valid &= false;
46                  errorMap.putError(PurapPropertyConstants.REQUESTOR_PERSON_PHONE_NUMBER, PurapKeyConstants.ERROR_INVALID_PH0NE_NUMBER);
47              }
48          }*/
49  
50          //perform the validation against email address
51          if (StringUtils.isNotBlank(purDocument.getRequestorPersonEmailAddress())) {
52              if (!validateEmailAddress(purDocument.getRequestorPersonEmailAddress())) {
53                  valid &= false;
54                  errorMap.putError(PurapPropertyConstants.REQUESTOR_PERSON_EMAIL_ADDRESS, PurapKeyConstants.ERROR_INVALID_EMAIL_ADDRESS);
55              }
56          }
57  
58          errorMap.clearErrorPath();
59  
60          return valid;
61      }
62  }