View Javadoc

1   /*
2    * Copyright 2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.attribute;
17  
18  import org.kuali.rice.kns.web.ui.Field;
19  import org.w3c.dom.NamedNodeMap;
20  import org.w3c.dom.Node;
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  /**
26   * This class provides some common shared utility methods shared by the XML-based
27   * attribute implementations. 
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   *
31   */
32  public class XMLAttributeUtils {
33  
34  	public static void establishFieldLookup(Field field, Node lookupNode) {
35  		NamedNodeMap quickfinderAttributes = lookupNode.getAttributes();
36  		String businessObjectClass = quickfinderAttributes.getNamedItem("businessObjectClass").getNodeValue();
37  		field.setQuickFinderClassNameImpl(businessObjectClass);
38  		for (int lcIndex = 0; lcIndex < lookupNode.getChildNodes().getLength(); lcIndex++) {
39  			Map<String, String> fieldConversionsMap = new HashMap<String, String>();
40  			Node fieldConversionsChildNode = lookupNode.getChildNodes().item(lcIndex);
41  			if ("fieldConversions".equals(fieldConversionsChildNode)) {
42  				for (int fcIndex = 0; fcIndex < fieldConversionsChildNode.getChildNodes().getLength(); fcIndex++) {
43  					Node fieldConversionChildNode = fieldConversionsChildNode.getChildNodes().item(fcIndex);
44  					if ("fieldConversion".equals(fieldConversionChildNode)) {
45  						NamedNodeMap fieldConversionAttributes = fieldConversionChildNode.getAttributes();
46  						String lookupFieldName = fieldConversionAttributes.getNamedItem("lookupFieldName").getNodeValue();
47  						String localFieldName = fieldConversionAttributes.getNamedItem("localFieldName").getNodeValue();
48  						fieldConversionsMap.put(lookupFieldName, localFieldName);
49  					}
50  				}
51  			}
52  			field.setFieldConversions(fieldConversionsMap);
53  		}
54  	}
55  	
56  }