1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.edl.impl;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.util.xml.XmlJotter;
20 import org.kuali.rice.edl.impl.bo.EDocLiteAssociation;
21 import org.kuali.rice.kew.api.WorkflowRuntimeException;
22 import org.w3c.dom.Document;
23 import org.w3c.dom.Element;
24
25 import javax.xml.transform.Templates;
26 import java.util.Iterator;
27 import java.util.Map;
28
29
30
31
32
33
34
35 public class EDLController {
36
37 private static final Logger LOG = Logger.getLogger(EDLController.class);
38
39 private EDocLiteAssociation edocLiteAssociation;
40 private Templates style;
41 private Map configProcessors;
42 private Map preProcessors;
43 private Map postProcessors;
44 private Map stateComponents;
45 private EDLGlobalConfig edlGlobalConfig;
46 private Document defaultDOM;
47 private EDLContext edlContext;
48
49 public Document notifyComponents() {
50
51 try {
52 updateDOMWithProcessors(defaultDOM, preProcessors);
53 updateDOMWithProcessors(defaultDOM, stateComponents);
54 updateDOMWithProcessors(defaultDOM, configProcessors);
55 updateDOMWithProcessors(defaultDOM, stateComponents);
56 updateDOMWithProcessors(defaultDOM, postProcessors);
57 } catch (Exception e) {
58 throw new WorkflowRuntimeException(e);
59 }
60
61
62 return defaultDOM;
63 }
64
65 private void updateDOMWithProcessors(Document dom, Map processors) throws Exception {
66
67 for (Iterator iter = processors.entrySet().iterator(); iter.hasNext();) {
68 Map.Entry processorEntry = (Map.Entry) iter.next();
69 Element configElement = (Element)processorEntry.getKey();
70 EDLModelComponent eldModelComp = (EDLModelComponent)((Class)processorEntry.getValue()).newInstance();
71 eldModelComp.updateDOM(dom, configElement, edlContext);
72 if (LOG.isDebugEnabled()) {
73 LOG.debug("Just completed notification to component " + eldModelComp + " doc content looks like. " + XmlJotter.jotNode(dom));
74 }
75
76 }
77 }
78
79 public Map getConfigProcessors() {
80 return configProcessors;
81 }
82 public void setConfigProcessors(Map configProcessors) {
83 this.configProcessors = configProcessors;
84 }
85 public EDLGlobalConfig getEdlGlobalConfig() {
86 return edlGlobalConfig;
87 }
88 public void setEdlGlobalConfig(EDLGlobalConfig edlConfig) {
89 this.edlGlobalConfig = edlConfig;
90 }
91 public Templates getStyle() {
92 return style;
93 }
94 public void setStyle(Templates style) {
95 this.style = style;
96 }
97 public EDocLiteAssociation getEdocLiteAssociation() {
98 return edocLiteAssociation;
99 }
100 public void setEdocLiteAssociation(EDocLiteAssociation edocLiteAssociation) {
101 this.edocLiteAssociation = edocLiteAssociation;
102 }
103 public Document getDefaultDOM() {
104 return defaultDOM;
105 }
106 public void setDefaultDOM(Document defaultDOM) {
107 this.defaultDOM = defaultDOM;
108 }
109 public EDLContext getEdlContext() {
110 return edlContext;
111 }
112 public void setEdlContext(EDLContext edlContext) {
113 this.edlContext = edlContext;
114 }
115
116 public Map getPostProcessors() {
117 return postProcessors;
118 }
119
120 public void setPostProcessors(Map postProcessors) {
121 this.postProcessors = postProcessors;
122 }
123
124 public Map getPreProcessors() {
125 return preProcessors;
126 }
127
128 public void setPreProcessors(Map preProcessors) {
129 this.preProcessors = preProcessors;
130 }
131
132 public Map getStateComponents() {
133 return stateComponents;
134 }
135
136 public void setStateComponents(Map stateComponents) {
137 this.stateComponents = stateComponents;
138 }
139 }