001/** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.edl.impl.components; 017 018import org.kuali.rice.edl.impl.EDLContext; 019import org.kuali.rice.edl.impl.EDLModelComponent; 020import org.kuali.rice.edl.impl.EDLXmlUtils; 021import org.kuali.rice.edl.impl.RequestParser; 022import org.kuali.rice.kew.api.WorkflowDocument; 023import org.w3c.dom.Document; 024import org.w3c.dom.Element; 025import org.w3c.dom.Node; 026 027 028/** 029 * This class makes xml for the instructions template of widgets. Processes config elements 030 * instructions and createInstructions. 031 * 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 * 034 */ 035public class InstructionsEDLComponent implements EDLModelComponent { 036 037 public void updateDOM(Document dom, Element configElement, EDLContext edlContext) { 038 039 Element edlElement = EDLXmlUtils.getEDLContent(dom, false); 040 Element edlSubElement = EDLXmlUtils.getOrCreateChildElement(edlElement, "edl", true); 041 WorkflowDocument document = (WorkflowDocument)edlContext.getRequestParser().getAttribute(RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY); 042 edlSubElement.setAttribute("title", document.getTitle()); 043 044 if(configElement.getTagName().equals("instructions")) { 045 Node instTextNode = configElement.getChildNodes().item(0); 046 if (instTextNode == null) { 047 return ; 048 } 049 String instructions = instTextNode.getNodeValue(); 050 EDLXmlUtils.createTextElementOnParent(edlSubElement, "instructions", instructions); 051 edlElement.setAttribute("title", instructions); 052 } else if (configElement.getTagName().equals("createInstructions")) { 053 Node instTextNode = configElement.getChildNodes().item(0); 054 if (instTextNode == null) { 055 return ; 056 } 057 String instructions = instTextNode.getNodeValue(); 058 EDLXmlUtils.createTextElementOnParent(edlSubElement, "createInstructions", instructions); 059 } 060 } 061 062}