1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document.validation.impl;
17
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.ole.module.purap.PurapPropertyConstants;
21 import org.kuali.ole.select.businessobject.OleRequisitionItem;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.OLEKeyConstants;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.kns.service.DataDictionaryService;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27 import org.kuali.rice.krad.util.GlobalVariables;
28
29 public class PurchasingAddBibInfoValidation extends PurchasingBibInfoAddItemValidation {
30
31 private BusinessObjectService businessObjectService;
32 private DataDictionaryService dataDictionaryService;
33
34 public boolean validate(AttributedDocumentEvent event) {
35 boolean valid = true;
36 GlobalVariables.getMessageMap().addToErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
37 OleRequisitionItem refreshedItem = getItemForValidation();
38 refreshedItem.refreshReferenceObject("itemType");
39 super.setItemForValidation(refreshedItem);
40
41 valid &= super.validate(event);
42
43
44 GlobalVariables.getMessageMap().removeFromErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
45
46 return valid;
47 }
48
49 public boolean validateItemTitle(OleRequisitionItem item) {
50 boolean valid = true;
51 if (StringUtils.isEmpty(item.getBibInfoBean().getTitle())) {
52 valid = false;
53 String attributeLabel = dataDictionaryService.
54 getDataDictionary().getBusinessObjectEntry(item.getBibInfoBean().getClass().getName()).
55 getAttributeDefinition(OLEConstants.BibInfoBean.ITEM_TITLE).getLabel();
56 GlobalVariables.getMessageMap().putError(OLEConstants.BibInfoBean.ITEM_TITLE, OLEKeyConstants.ERROR_REQUIRED, attributeLabel + " in " + item.getItemIdentifierString());
57 }
58 return valid;
59 }
60
61 public BusinessObjectService getBusinessObjectService() {
62 return businessObjectService;
63 }
64
65 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
66 this.businessObjectService = businessObjectService;
67 }
68
69 public DataDictionaryService getDataDictionaryService() {
70 return dataDictionaryService;
71 }
72
73 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
74 this.dataDictionaryService = dataDictionaryService;
75 }
76
77 }
78