1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.edl.components;
18
19 import org.kuali.rice.kew.edl.EDLXmlUtils;
20 import org.kuali.rice.kew.edl.RequestParser;
21 import org.kuali.rice.kim.bo.entity.KimPrincipal;
22 import org.kuali.rice.kim.service.KIMServiceLocator;
23 import org.w3c.dom.Element;
24 import org.w3c.dom.NodeList;
25
26
27
28
29
30
31
32
33 public class UniversityIdWorkflowEDLConfigComponent extends SimpleWorkflowEDLConfigComponent {
34
35 private boolean required;
36
37 @Override
38 public Element getReplacementConfigElement(Element element) {
39 Element replacementEl = (Element)element.cloneNode(true);
40 Element type = (Element)((NodeList)replacementEl.getElementsByTagName(EDLXmlUtils.TYPE_E)).item(0);
41 type.setTextContent("text");
42
43
44
45 Element validation = (Element)((NodeList)replacementEl.getElementsByTagName(EDLXmlUtils.VALIDATION_E)).item(0);
46 if (validation != null && validation.getAttribute("required").equals("true")) {
47 required = true;
48 }
49 return replacementEl;
50 }
51
52 @Override
53 public String getErrorMessage(Element originalConfigElement, RequestParser requestParser, MatchingParam param) {
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 if (param.getParamValue().length() == 0 && required == true) {
73
74 return ("University ID is a required field");
75 } else if (param.getParamValue().length() == 0 && required == false) {
76
77 return null;
78 } else {
79
80 String employeeId = param.getParamValue();
81
82 KimPrincipal principal = KIMServiceLocator.getIdentityManagementService().getPrincipal(employeeId);
83 if (principal == null) {
84 return ("The value " + employeeId + " is an invalid University ID");
85 }
86
87
88 }
89 return null;
90 }
91
92 public boolean isRequired() {
93 return required;
94 }
95
96 public void setRequired(boolean required) {
97 this.required = required;
98 }
99
100
101 }
102