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.PurapConstants;
20 import org.kuali.ole.module.purap.PurapKeyConstants;
21 import org.kuali.ole.module.purap.businessobject.SensitiveData;
22 import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
23 import org.kuali.ole.sys.document.validation.GenericValidation;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27 import java.util.HashSet;
28 import java.util.List;
29
30
31
32
33 public class PurchaseOrderAssignSensitiveDataValidation extends GenericValidation {
34
35 private PurchaseOrderDocument accountingDocumentForValidation;
36 private String sensitiveDataAssignmentReason;
37 private List<SensitiveData> sensitiveDatasAssigned;
38
39
40
41
42
43
44
45
46
47 public boolean validate(AttributedDocumentEvent event) {
48 boolean valid = true;
49 GlobalVariables.getMessageMap().clearErrorPath();
50 HashSet<String> sdset = new HashSet<String>();
51
52 if (StringUtils.isEmpty(sensitiveDataAssignmentReason)) {
53 GlobalVariables.getMessageMap().putError(PurapConstants.ASSIGN_SENSITIVE_DATA_TAB_ERRORS, PurapKeyConstants.ERROR_ASSIGN_SENSITIVE_DATA_REASON_EMPTY);
54 valid = false;
55 }
56
57 for (Object sdobj : sensitiveDatasAssigned) {
58 SensitiveData sd = (SensitiveData) sdobj;
59 if (!sd.isActive()) {
60 GlobalVariables.getMessageMap().putError(PurapConstants.ASSIGN_SENSITIVE_DATA_TAB_ERRORS, PurapKeyConstants.ERROR_ASSIGN_SENSITIVE_DATA_INACTIVE, sd.getSensitiveDataDescription());
61 valid = false;
62 } else if (!sdset.add(sd.getSensitiveDataCode())) {
63 GlobalVariables.getMessageMap().putError(PurapConstants.ASSIGN_SENSITIVE_DATA_TAB_ERRORS, PurapKeyConstants.ERROR_ASSIGN_SENSITIVE_DATA_REDUNDANT, sd.getSensitiveDataDescription());
64 valid = false;
65 }
66 }
67
68 GlobalVariables.getMessageMap().clearErrorPath();
69 return valid;
70 }
71
72 public PurchaseOrderDocument getAccountingDocumentForValidation() {
73 return accountingDocumentForValidation;
74 }
75
76 public void setAccountingDocumentForValidation(PurchaseOrderDocument accountingDocumentForValidation) {
77 this.accountingDocumentForValidation = accountingDocumentForValidation;
78 }
79
80 public String getSensitiveDataAssignmentReason() {
81 return sensitiveDataAssignmentReason;
82 }
83
84 public void setSensitiveDataAssignmentReason(String sensitiveDataAssignmentReason) {
85 this.sensitiveDataAssignmentReason = sensitiveDataAssignmentReason;
86 }
87
88 public List<SensitiveData> getSensitiveDatasAssigned() {
89 return sensitiveDatasAssigned;
90 }
91
92 public void setSensitiveDatasAssigned(List<SensitiveData> sensitiveDatasAssigned) {
93 this.sensitiveDatasAssigned = sensitiveDatasAssigned;
94 }
95
96 }
97