1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.spring.datadictionary;
17
18 import java.util.ArrayList;
19
20 import org.kuali.rice.krad.datadictionary.WorkflowProperty;
21 import org.kuali.rice.krad.datadictionary.WorkflowPropertyGroup;
22 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
23 import org.springframework.beans.factory.xml.ParserContext;
24 import org.springframework.util.StringUtils;
25 import org.w3c.dom.Element;
26 import org.w3c.dom.Node;
27 import org.w3c.dom.NodeList;
28
29 public class WorkflowPropertiesBeanDefinitionParser extends KualiBeanDefinitionParserBase {
30
31 @Override
32 protected String getBaseBeanTypeParent(Element element) {
33 return "WorkflowProperties";
34 }
35
36 @Override
37 protected void doParse(Element element, ParserContext context, BeanDefinitionBuilder bean) {
38
39 handleAbstractAttribute(element, bean);
40
41
42 NodeList children = element.getChildNodes();
43 ArrayList<WorkflowPropertyGroup> groups = new ArrayList<WorkflowPropertyGroup>();
44 for ( int i = 0; i < children.getLength(); i++ ) {
45 Node child = children.item(i);
46 if ( child.getLocalName() != null && child.getLocalName().equals("group") ) {
47 WorkflowPropertyGroup group = new WorkflowPropertyGroup();
48 Element groupElement = (Element)child;
49 String basePath = groupElement.getAttribute("basePath");
50 if ( StringUtils.hasText(basePath) ) {
51 group.setBasePath(basePath);
52 }
53 groups.add( group );
54
55 NodeList groupChildren = groupElement.getChildNodes();
56 for ( int j = 0 ; j < groupChildren.getLength(); j++ ) {
57 Node groupChild = groupChildren.item(j);
58 if ( groupChild.getLocalName() != null && groupChild.getLocalName().equals("path") ) {
59 Element pathElement = (Element)groupChild;
60 String path = pathElement.getAttribute("path");
61 if ( StringUtils.hasText( path ) ) {
62 WorkflowProperty prop = new WorkflowProperty();
63 prop.setPath(path);
64 group.getWorkflowProperties().add( prop );
65 }
66 }
67
68 }
69 }
70 }
71 bean.addPropertyValue("workflowPropertyGroups", groups);
72 }
73
74
75 }