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 java.util.ArrayList; |
19 |
|
import java.util.List; |
20 |
|
|
21 |
|
import org.apache.commons.lang.StringUtils; |
22 |
|
import org.kuali.rice.edl.impl.EDLContext; |
23 |
|
import org.kuali.rice.edl.impl.EDLModelComponent; |
24 |
|
import org.kuali.rice.edl.impl.RequestParser; |
25 |
|
import org.kuali.rice.edl.impl.UserAction; |
26 |
|
import org.w3c.dom.Document; |
27 |
|
import org.w3c.dom.Element; |
28 |
|
import org.w3c.dom.NodeList; |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.29 |
|
30 |
|
public class RefreshFromLookupComponent implements EDLModelComponent { |
31 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
32 |
0
|
public void updateDOM(Document dom, Element configElement, EDLContext edlContext) {... |
33 |
0
|
String command = edlContext.getUserAction().getAction(); |
34 |
0
|
if (UserAction.ACTION_REFRESH_FROM_LOOKUP.equals(command)) { |
35 |
0
|
RequestParser requestParser = edlContext.getRequestParser(); |
36 |
|
|
37 |
0
|
Element currentVersion = VersioningPreprocessor.findCurrentVersion(dom); |
38 |
|
|
39 |
0
|
List<Element> fieldsToDelete = new ArrayList<Element>(); |
40 |
0
|
NodeList fieldNodes = currentVersion.getElementsByTagName("field"); |
41 |
|
|
42 |
|
|
43 |
0
|
List<String> requestParameterNames = requestParser.getParameterNames(); |
44 |
|
|
45 |
0
|
for (int i = 0; i < fieldNodes.getLength(); i++) { |
46 |
0
|
Element fieldNode = (Element) fieldNodes.item(i); |
47 |
0
|
String fieldName = fieldNode.getAttribute("name"); |
48 |
0
|
if (requestParameterNames.contains(fieldName)) { |
49 |
0
|
fieldsToDelete.add(fieldNode); |
50 |
|
} |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
0
|
for (Element fieldToDelete : fieldsToDelete) { |
56 |
0
|
currentVersion.removeChild(fieldToDelete); |
57 |
|
} |
58 |
|
} |
59 |
|
} |
60 |
|
} |