View Javadoc
1   /*
2    * Copyright 2008 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.ole.sys.spring.datadictionary;
17  
18  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
19  import org.springframework.beans.factory.xml.ParserContext;
20  import org.springframework.util.StringUtils;
21  import org.w3c.dom.Element;
22  
23  public class MaintenanceFieldBeanDefinitionParser extends KualiBeanDefinitionParserBase {
24  
25      @Override
26      protected String getBaseBeanTypeParent(Element element) {
27          return "MaintainableFieldDefinition";
28      }
29      
30      @Override
31      protected void doParse(Element element, ParserContext context, BeanDefinitionBuilder bean) {
32          // get all attributes
33          String attributeName = element.getAttribute("attributeName");
34          String required = element.getAttribute("required");
35          String unconditionallyReadOnly = element.getAttribute("unconditionallyReadOnly");
36          String defaultValue = element.getAttribute("defaultValue");
37          String defaultValueFinderClass = element.getAttribute("defaultValueFinderClass");
38          String javascriptLeaveFieldFunction = element.getAttribute("javascriptLeaveFieldFunction");
39          String javascriptLeaveFieldCallbackFunction = element.getAttribute("javascriptLeaveFieldCallbackFunction");
40  
41          // now, set on the bean definition
42          if ( StringUtils.hasText(attributeName) ) {
43              bean.addPropertyValue("name", attributeName);
44          }
45          if ( StringUtils.hasText(required) ) {
46              bean.addPropertyValue("required", Boolean.parseBoolean(required));
47          }
48          if ( StringUtils.hasText(unconditionallyReadOnly) ) {
49              bean.addPropertyValue("unconditionallyReadOnly", Boolean.parseBoolean(unconditionallyReadOnly));
50          }
51          if ( StringUtils.hasText(defaultValue) ) {
52              bean.addPropertyValue("defaultValue", defaultValue);
53          } else if ( StringUtils.hasText(defaultValueFinderClass) ) {
54              bean.addPropertyValue("defaultValueFinderClass", defaultValueFinderClass);
55          }
56          if ( StringUtils.hasText(javascriptLeaveFieldFunction) ) {
57              bean.addPropertyValue("webUILeaveFieldFunction", javascriptLeaveFieldFunction);
58          }
59          if ( StringUtils.hasText(javascriptLeaveFieldCallbackFunction) ) {
60              bean.addPropertyValue("webUILeaveFieldCallbackFunction", javascriptLeaveFieldCallbackFunction);
61          }
62          
63          // handle any other simple child properties
64          parseEmbeddedPropertyElements(element, bean);
65      }
66  
67      
68  }