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.apache.commons.lang.StringUtils;
19 import org.kuali.ole.module.purap.PurapPropertyConstants;
20 import org.kuali.ole.module.purap.businessobject.PurApItem;
21 import org.kuali.ole.sys.OLEKeyConstants;
22 import org.kuali.ole.sys.document.validation.GenericValidation;
23 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24 import org.kuali.rice.kns.service.DataDictionaryService;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27 public class PurchasingItemDescriptionValidation extends GenericValidation {
28
29 private PurApItem itemForValidation;
30 private DataDictionaryService dataDictionaryService;
31
32
33
34
35 public boolean validate(AttributedDocumentEvent event) {
36 boolean valid = true;
37 if (StringUtils.isEmpty(itemForValidation.getItemDescription())) {
38 valid = false;
39 String attributeLabel = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(itemForValidation.getClass().getName()).
40 getAttributeDefinition(PurapPropertyConstants.ITEM_DESCRIPTION).getLabel();
41 GlobalVariables.getMessageMap().putError(PurapPropertyConstants.ITEM_DESCRIPTION, OLEKeyConstants.ERROR_REQUIRED, attributeLabel + " in " + itemForValidation.getItemIdentifierString());
42 }
43 return valid;
44 }
45
46 public PurApItem getItemForValidation() {
47 return itemForValidation;
48 }
49
50 public void setItemForValidation(PurApItem itemForValidation) {
51 this.itemForValidation = itemForValidation;
52 }
53
54 public DataDictionaryService getDataDictionaryService() {
55 return dataDictionaryService;
56 }
57
58 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
59 this.dataDictionaryService = dataDictionaryService;
60 }
61
62 }