1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
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 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
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 | |
} |