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