Coverage Report - org.kuali.rice.edl.impl.components.InstructionsEDLComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
InstructionsEDLComponent
0%
0/19
0%
0/8
7
 
 1  
 /**
 2  
  * Copyright 2005-2011 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  0
 public class InstructionsEDLComponent implements EDLModelComponent {
 36  
 
 37  
         public void updateDOM(Document dom, Element configElement, EDLContext edlContext) {
 38  
                 
 39  0
                 Element edlElement = EDLXmlUtils.getEDLContent(dom, false);
 40  0
                 Element edlSubElement = EDLXmlUtils.getOrCreateChildElement(edlElement, "edl", true);
 41  0
                 WorkflowDocument document = (WorkflowDocument)edlContext.getRequestParser().getAttribute(RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY);
 42  0
                 edlSubElement.setAttribute("title", document.getTitle());
 43  
                 
 44  0
                 if(configElement.getTagName().equals("instructions")) {
 45  0
                         Node instTextNode = configElement.getChildNodes().item(0);
 46  0
                         if (instTextNode == null) {
 47  0
                                 return ;
 48  
                         }
 49  0
                         String instructions = instTextNode.getNodeValue(); 
 50  0
                         EDLXmlUtils.createTextElementOnParent(edlSubElement, "instructions", instructions);
 51  0
                         edlElement.setAttribute("title", instructions);        
 52  0
                 } else if (configElement.getTagName().equals("createInstructions")) {
 53  0
                         Node instTextNode = configElement.getChildNodes().item(0);
 54  0
                         if (instTextNode == null) {
 55  0
                                 return ;
 56  
                         }
 57  0
                         String instructions = instTextNode.getNodeValue();
 58  0
                         EDLXmlUtils.createTextElementOnParent(edlSubElement, "createInstructions", instructions);        
 59  
                 }
 60  0
         }
 61  
 
 62  
 }