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.module.purap.PurapConstants;
19 import org.kuali.ole.module.purap.document.BulkReceivingDocument;
20 import org.kuali.ole.module.purap.document.service.BulkReceivingService;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
23 import org.kuali.rice.krad.document.Document;
24
25 import java.util.HashMap;
26 import java.util.Iterator;
27
28 public class BulkReceivingDocumentPreRules extends PromptBeforeValidationBase {
29
30 public boolean doPrompts(Document document) {
31
32 BulkReceivingDocument bulkReceivingDocument = (BulkReceivingDocument) document;
33
34 HashMap<String, String> duplicateMessages = SpringContext.getBean(BulkReceivingService.class).bulkReceivingDuplicateMessages(bulkReceivingDocument);
35
36 if (duplicateMessages != null && !duplicateMessages.isEmpty()) {
37 Iterator iterator = duplicateMessages.values().iterator();
38 StringBuffer msg = new StringBuffer();
39 while (iterator.hasNext()) {
40 msg.append(iterator.next());
41 }
42 boolean proceed = super.askOrAnalyzeYesNoQuestion(PurapConstants.BulkReceivingDocumentStrings.DUPLICATE_BULK_RECEIVING_DOCUMENT_QUESTION, msg.toString());
43 if (!proceed) {
44 abortRulesCheck();
45 }
46 }
47
48 return true;
49 }
50
51
52 }