View Javadoc
1   /*
2    * Copyright 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.kuali.ole.integration.purap.CapitalAssetLocation;
19  import org.kuali.ole.module.purap.document.service.PurchasingService;
20  import org.kuali.ole.sys.context.SpringContext;
21  import org.kuali.ole.sys.document.validation.GenericValidation;
22  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
24  
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  public class PurchasingAddCapitalAssetLocationValidation extends GenericValidation {
29  
30      protected CapitalAssetLocation location;
31      protected ParameterService parameterService;
32      protected PurchasingService purchasingService;
33  
34      public boolean validate(AttributedDocumentEvent event) {
35          boolean valid = true;
36          // TODO: Move this into CABModuleService?
37          // Retrieve and evaluate the parameter which determines whether location's address is required.
38          // CHARTS_REQUIRING_LOCATIONS_ADDRESS_ON_(REQUISITION/PURCHASE_ORDER)
39          Map<String, String> fieldValues = new HashMap<String, String>();
40  
41          //List<Parameter> results = getParameterService().retrieveParametersGivenLookupCriteria(fieldValues);
42          // If the location's address is required, enforce the validation of the individual fields of the address.
43  
44          valid = getPurchasingService().checkCapitalAssetLocation(getLocation());
45          valid &= getPurchasingService().checkValidRoomNumber(getLocation());
46  
47          //valid = purchasingService.checkCapitalAssetLocation(getLocation());
48          //valid &= purchasingService.checkValidRoomNumber(getLocation());
49          return valid;
50      }
51  
52      public CapitalAssetLocation getLocation() {
53          return location;
54      }
55  
56      public void setLocation(CapitalAssetLocation location) {
57          this.location = location;
58      }
59  
60      protected ParameterService getParameterService() {
61          if (parameterService == null) {
62              parameterService = SpringContext.getBean(ParameterService.class);
63          }
64          return parameterService;
65      }
66  
67      protected PurchasingService getPurchasingService() {
68          if (parameterService == null) {
69              purchasingService = SpringContext.getBean(PurchasingService.class);
70          }
71          return purchasingService;
72      }
73  
74  }