1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.attribute;
17
18 import org.kuali.rice.core.api.uif.RemotableAttributeField;
19 import org.kuali.rice.core.api.uif.RemotableQuickFinder;
20 import org.kuali.rice.kns.web.ui.Field;
21 import org.w3c.dom.NamedNodeMap;
22 import org.w3c.dom.Node;
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27
28
29
30
31
32
33
34 public final class XMLAttributeUtils {
35
36 private XMLAttributeUtils() {
37 throw new UnsupportedOperationException("do not call");
38 }
39
40
41
42
43 public static void establishFieldLookup(Field field, Node lookupNode) {
44 NamedNodeMap quickfinderAttributes = lookupNode.getAttributes();
45 String businessObjectClass = quickfinderAttributes.getNamedItem("dataObjectClass").getNodeValue();
46 field.setQuickFinderClassNameImpl(businessObjectClass);
47 for (int lcIndex = 0; lcIndex < lookupNode.getChildNodes().getLength(); lcIndex++) {
48 Map<String, String> fieldConversionsMap = new HashMap<String, String>();
49 Node fieldConversionsChildNode = lookupNode.getChildNodes().item(lcIndex);
50 if ("fieldConversions".equals(fieldConversionsChildNode)) {
51 for (int fcIndex = 0; fcIndex < fieldConversionsChildNode.getChildNodes().getLength(); fcIndex++) {
52 Node fieldConversionChildNode = fieldConversionsChildNode.getChildNodes().item(fcIndex);
53 if ("fieldConversion".equals(fieldConversionChildNode)) {
54 NamedNodeMap fieldConversionAttributes = fieldConversionChildNode.getAttributes();
55 String lookupFieldName = fieldConversionAttributes.getNamedItem("lookupFieldName").getNodeValue();
56 String localFieldName = fieldConversionAttributes.getNamedItem("localFieldName").getNodeValue();
57 fieldConversionsMap.put(lookupFieldName, localFieldName);
58 }
59 }
60 }
61 field.setFieldConversions(fieldConversionsMap);
62 }
63 }
64
65 public static void establishFieldLookup(RemotableAttributeField.Builder fieldBuilder, Node lookupNode) {
66 NamedNodeMap quickfinderAttributes = lookupNode.getAttributes();
67 String businessObjectClass = quickfinderAttributes.getNamedItem("dataObjectClass").getNodeValue();
68
69 RemotableQuickFinder.Builder quickFinderBuilder = RemotableQuickFinder.Builder.create(null, businessObjectClass);
70 for (int lcIndex = 0; lcIndex < lookupNode.getChildNodes().getLength(); lcIndex++) {
71 Map<String, String> fieldConversionsMap = new HashMap<String, String>();
72 Node fieldConversionsChildNode = lookupNode.getChildNodes().item(lcIndex);
73 if ("fieldConversions".equals(fieldConversionsChildNode)) {
74 for (int fcIndex = 0; fcIndex < fieldConversionsChildNode.getChildNodes().getLength(); fcIndex++) {
75 Node fieldConversionChildNode = fieldConversionsChildNode.getChildNodes().item(fcIndex);
76 if ("fieldConversion".equals(fieldConversionChildNode)) {
77 NamedNodeMap fieldConversionAttributes = fieldConversionChildNode.getAttributes();
78 String lookupFieldName = fieldConversionAttributes.getNamedItem("lookupFieldName").getNodeValue();
79 String localFieldName = fieldConversionAttributes.getNamedItem("localFieldName").getNodeValue();
80 fieldConversionsMap.put(lookupFieldName, localFieldName);
81 }
82 }
83 }
84 quickFinderBuilder.setFieldConversions(fieldConversionsMap);
85 fieldBuilder.getWidgets().add(quickFinderBuilder);
86 }
87 }
88
89 }