1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.sys.document.validation.impl;
17  
18  import org.kuali.ole.sys.OLEKeyConstants;
19  import org.kuali.ole.sys.document.validation.GenericValidation;
20  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
21  import org.kuali.rice.kns.service.DataDictionaryService;
22  import org.kuali.rice.kns.service.DictionaryValidationService;
23  import org.kuali.rice.krad.bo.PersistableBusinessObject;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  
27  
28  
29  public class ReferenceExistsValidation extends GenericValidation {
30      private PersistableBusinessObject businessObjectToValidate;
31      private DictionaryValidationService dictionaryValidationService;
32      private DataDictionaryService dataDictionaryService;
33      private String referenceName;
34      private String responsibleProperty;
35  
36      
37  
38  
39  
40      public boolean validate(AttributedDocumentEvent event) {
41          boolean result = true;
42          if (dictionaryValidationService.validateReferenceExists(businessObjectToValidate, referenceName)) {
43              GlobalVariables.getMessageMap().putError(responsibleProperty, OLEKeyConstants.ERROR_EXISTENCE, new String[] { dataDictionaryService.getAttributeLabel(businessObjectToValidate.getClass(), responsibleProperty) });
44              result = false;
45          }
46          return result;
47      }
48  
49      
50  
51  
52  
53      public PersistableBusinessObject getBusinessObjectToValidate() {
54          return businessObjectToValidate;
55      }
56  
57      
58  
59  
60  
61      public void setBusinessObjectToValidate(PersistableBusinessObject businessObjectToValidate) {
62          this.businessObjectToValidate = businessObjectToValidate;
63      }
64  
65      
66  
67  
68  
69      public String getReferenceName() {
70          return referenceName;
71      }
72  
73      
74  
75  
76  
77      public void setReferenceName(String referenceName) {
78          this.referenceName = referenceName;
79      }
80  
81      
82  
83  
84  
85      public String getResponsibleProperty() {
86          return responsibleProperty;
87      }
88  
89      
90  
91  
92  
93      public void setResponsibleProperty(String responsibleProperty) {
94          this.responsibleProperty = responsibleProperty;
95      }
96  
97      
98  
99  
100 
101     public void setDictionaryValidationService(DictionaryValidationService dictionaryValidationService) {
102         this.dictionaryValidationService = dictionaryValidationService;
103     }
104 
105     
106 
107 
108 
109     public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
110         this.dataDictionaryService = dataDictionaryService;
111     }
112 }