1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
37
38
39 Map<String, String> fieldValues = new HashMap<String, String>();
40
41
42
43
44 valid = getPurchasingService().checkCapitalAssetLocation(getLocation());
45 valid &= getPurchasingService().checkValidRoomNumber(getLocation());
46
47
48
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 }