View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.edl.impl.components;
17  
18  import org.kuali.rice.edl.impl.EDLContext;
19  import org.kuali.rice.edl.impl.EDLModelComponent;
20  import org.kuali.rice.edl.impl.EDLXmlUtils;
21  import org.kuali.rice.edl.impl.RequestParser;
22  import org.kuali.rice.kew.api.WorkflowDocument;
23  import org.w3c.dom.Document;
24  import org.w3c.dom.Element;
25  import org.w3c.dom.Node;
26  
27  
28  /**
29   * This class makes xml for the instructions template of widgets.  Processes config elements
30   * instructions and createInstructions.
31   * 
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   *
34   */
35  public class InstructionsEDLComponent implements EDLModelComponent {
36  
37  	public void updateDOM(Document dom, Element configElement, EDLContext edlContext) {
38  		
39  		Element edlElement = EDLXmlUtils.getEDLContent(dom, false);
40  		Element edlSubElement = EDLXmlUtils.getOrCreateChildElement(edlElement, "edl", true);
41  		WorkflowDocument document = (WorkflowDocument)edlContext.getRequestParser().getAttribute(RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY);
42  		edlSubElement.setAttribute("title", document.getTitle());
43  		
44  		if(configElement.getTagName().equals("instructions")) {
45  			Node instTextNode = configElement.getChildNodes().item(0);
46  			if (instTextNode == null) {
47  				return ;
48  			}
49  			String instructions = instTextNode.getNodeValue(); 
50  			EDLXmlUtils.createTextElementOnParent(edlSubElement, "instructions", instructions);
51  			edlElement.setAttribute("title", instructions);	
52  		} else if (configElement.getTagName().equals("createInstructions")) {
53  			Node instTextNode = configElement.getChildNodes().item(0);
54  			if (instTextNode == null) {
55  				return ;
56  			}
57  			String instructions = instTextNode.getNodeValue();
58  			EDLXmlUtils.createTextElementOnParent(edlSubElement, "createInstructions", instructions);	
59  		}
60  	}
61  
62  }