Coverage Report - org.kuali.rice.kew.xml.export.HelpEntryXmlExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpEntryXmlExporter
0%
0/19
0%
0/4
2
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.xml.export;
 18  
 
 19  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_ENTRIES;
 20  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_ENTRY;
 21  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_KEY;
 22  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_NAME;
 23  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_NAMESPACE;
 24  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_SCHEMA_LOCATION;
 25  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.HELP_TEXT;
 26  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.SCHEMA_LOCATION_ATTR;
 27  
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.SCHEMA_NAMESPACE;
 28  
 
 29  
 import java.util.Iterator;
 30  
 
 31  
 import org.jdom.Element;
 32  
 import org.kuali.rice.core.api.impex.ExportDataSet;
 33  
 import org.kuali.rice.core.framework.impex.xml.XmlExporter;
 34  
 import org.kuali.rice.core.util.xml.XmlRenderer;
 35  
 import org.kuali.rice.kew.export.KewExportDataSet;
 36  
 import org.kuali.rice.kew.help.HelpEntry;
 37  
 /**
 38  
  * Exports {@link HelpEntry}s to XML.
 39  
  *
 40  
  * @see HelpEntry
 41  
  *
 42  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 43  
  */
 44  0
 public class HelpEntryXmlExporter implements XmlExporter {
 45  
 
 46  0
     protected final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(getClass());
 47  
     
 48  0
     private XmlRenderer renderer = new XmlRenderer(HELP_NAMESPACE);
 49  
     
 50  
         @Override
 51  
         public boolean supportPrettyPrint() {
 52  0
                 return true;
 53  
         }
 54  
     
 55  
     public Element export(ExportDataSet exportDataSet) {
 56  0
             KewExportDataSet dataSet = KewExportDataSet.fromExportDataSet(exportDataSet);
 57  0
         if (!dataSet.getHelp().isEmpty()) {
 58  0
             Element rootElement = renderer.renderElement(null, HELP_ENTRIES);
 59  0
             rootElement.setAttribute(SCHEMA_LOCATION_ATTR, HELP_SCHEMA_LOCATION, SCHEMA_NAMESPACE);
 60  0
             for (Iterator iterator = dataSet.getHelp().iterator(); iterator.hasNext();) {
 61  0
                 HelpEntry helpEntry = (HelpEntry)iterator.next();
 62  0
                 exportHelpEntry(rootElement, helpEntry);
 63  0
             }
 64  0
             return rootElement;
 65  
         }
 66  0
         return null;
 67  
     }
 68  
     
 69  
     private void exportHelpEntry(Element parent, HelpEntry helpEntry) {
 70  0
         Element helpElement = renderer.renderElement(parent, HELP_ENTRY);
 71  0
         renderer.renderTextElement(helpElement, HELP_NAME, helpEntry.getHelpName());
 72  0
         renderer.renderTextElement(helpElement, HELP_KEY, helpEntry.getHelpKey());
 73  0
         renderer.renderCDATAElement(helpElement, HELP_TEXT, helpEntry.getHelpText());
 74  0
     }
 75  
     
 76  
 }