001 /*
002 * Copyright 2005-2007 The Kuali Foundation
003 *
004 *
005 * Licensed under the Educational Community License, Version 2.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/ecl2.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 org.kuali.rice.edl.impl.components;
018
019 import org.kuali.rice.edl.impl.EDLContext;
020 import org.kuali.rice.edl.impl.EDLModelComponent;
021 import org.kuali.rice.edl.impl.EDLXmlUtils;
022 import org.kuali.rice.edl.impl.RequestParser;
023 import org.kuali.rice.kew.api.WorkflowDocument;
024 import org.w3c.dom.Document;
025 import org.w3c.dom.Element;
026 import org.w3c.dom.Node;
027
028
029 /**
030 * This class makes xml for the instructions template of widgets. Processes config elements
031 * instructions and createInstructions.
032 *
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 *
035 */
036 public class InstructionsEDLComponent implements EDLModelComponent {
037
038 public void updateDOM(Document dom, Element configElement, EDLContext edlContext) {
039
040 Element edlElement = EDLXmlUtils.getEDLContent(dom, false);
041 Element edlSubElement = EDLXmlUtils.getOrCreateChildElement(edlElement, "edl", true);
042 WorkflowDocument document = (WorkflowDocument)edlContext.getRequestParser().getAttribute(RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY);
043 edlSubElement.setAttribute("title", document.getTitle());
044
045 if(configElement.getTagName().equals("instructions")) {
046 Node instTextNode = configElement.getChildNodes().item(0);
047 if (instTextNode == null) {
048 return ;
049 }
050 String instructions = instTextNode.getNodeValue();
051 EDLXmlUtils.createTextElementOnParent(edlSubElement, "instructions", instructions);
052 edlElement.setAttribute("title", instructions);
053 } else if (configElement.getTagName().equals("createInstructions")) {
054 Node instTextNode = configElement.getChildNodes().item(0);
055 if (instTextNode == null) {
056 return ;
057 }
058 String instructions = instTextNode.getNodeValue();
059 EDLXmlUtils.createTextElementOnParent(edlSubElement, "createInstructions", instructions);
060 }
061 }
062
063 }