001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.edl;
018:
019: import java.util.Iterator;
020: import java.util.Map;
021:
022: import javax.xml.transform.Templates;
023:
024: import org.apache.log4j.Logger;
025: import org.w3c.dom.Document;
026: import org.w3c.dom.Element;
027:
028: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
029: import edu.iu.uis.eden.util.XmlHelper;
030:
031: /**
032: * Responsible for notifying components associated with a particular EDL definition.
033: *
034: * @author rkirkend
035: */
036: public class EDLController {
037:
038: private static final Logger LOG = Logger
039: .getLogger(EDLController.class);
040:
041: private EDocLiteAssociation edocLiteAssociation;
042: private Templates style;
043: private Map configProcessors;
044: private Map preProcessors;
045: private Map postProcessors;
046: private Map stateComponents;
047: private EDLGlobalConfig edlGlobalConfig;
048: private Document defaultDOM;
049: private EDLContext edlContext;
050:
051: public Document notifyComponents() {
052:
053: try {
054: updateDOMWithProcessors(defaultDOM, preProcessors);
055: updateDOMWithProcessors(defaultDOM, stateComponents);
056: updateDOMWithProcessors(defaultDOM, configProcessors);
057: updateDOMWithProcessors(defaultDOM, stateComponents);
058: updateDOMWithProcessors(defaultDOM, postProcessors);
059: } catch (Exception e) {
060: throw new WorkflowRuntimeException(e);
061: }
062:
063: return defaultDOM;
064: }
065:
066: private void updateDOMWithProcessors(Document dom, Map processors)
067: throws Exception {
068:
069: for (Iterator iter = processors.entrySet().iterator(); iter
070: .hasNext();) {
071: Map.Entry processorEntry = (Map.Entry) iter.next();
072: Element configElement = (Element) processorEntry.getKey();
073: EDLModelComponent eldModelComp = (EDLModelComponent) ((Class) processorEntry
074: .getValue()).newInstance();
075: eldModelComp.updateDOM(dom, configElement, edlContext);
076: if (LOG.isDebugEnabled()) {
077: LOG.debug("Just completed notification to component "
078: + eldModelComp + " doc content looks like. "
079: + XmlHelper.jotNode(dom));
080: }
081:
082: }
083: }
084:
085: public Map getConfigProcessors() {
086: return configProcessors;
087: }
088:
089: public void setConfigProcessors(Map configProcessors) {
090: this .configProcessors = configProcessors;
091: }
092:
093: public EDLGlobalConfig getEdlGlobalConfig() {
094: return edlGlobalConfig;
095: }
096:
097: public void setEdlGlobalConfig(EDLGlobalConfig edlConfig) {
098: this .edlGlobalConfig = edlConfig;
099: }
100:
101: public Templates getStyle() {
102: return style;
103: }
104:
105: public void setStyle(Templates style) {
106: this .style = style;
107: }
108:
109: public EDocLiteAssociation getEdocLiteAssociation() {
110: return edocLiteAssociation;
111: }
112:
113: public void setEdocLiteAssociation(
114: EDocLiteAssociation edocLiteAssociation) {
115: this .edocLiteAssociation = edocLiteAssociation;
116: }
117:
118: public Document getDefaultDOM() {
119: return defaultDOM;
120: }
121:
122: public void setDefaultDOM(Document defaultDOM) {
123: this .defaultDOM = defaultDOM;
124: }
125:
126: public EDLContext getEdlContext() {
127: return edlContext;
128: }
129:
130: public void setEdlContext(EDLContext edlContext) {
131: this .edlContext = edlContext;
132: }
133:
134: public Map getPostProcessors() {
135: return postProcessors;
136: }
137:
138: public void setPostProcessors(Map postProcessors) {
139: this .postProcessors = postProcessors;
140: }
141:
142: public Map getPreProcessors() {
143: return preProcessors;
144: }
145:
146: public void setPreProcessors(Map preProcessors) {
147: this .preProcessors = preProcessors;
148: }
149:
150: public Map getStateComponents() {
151: return stateComponents;
152: }
153:
154: public void setStateComponents(Map stateComponents) {
155: this.stateComponents = stateComponents;
156: }
157: }
|