1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.edl.impl.xml.export; |
17 | |
|
18 | |
import java.io.IOException; |
19 | |
import java.io.OutputStream; |
20 | |
import java.util.ArrayList; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import org.kuali.rice.core.api.impex.ExportDataSet; |
24 | |
import org.kuali.rice.core.api.services.CoreApiServiceLocator; |
25 | |
import org.kuali.rice.core.impl.style.StyleBo; |
26 | |
import org.kuali.rice.edl.impl.bo.EDocLiteAssociation; |
27 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
28 | |
import org.kuali.rice.kew.help.HelpEntry; |
29 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
30 | |
import org.kuali.rice.kew.rule.RuleDelegation; |
31 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
32 | |
import org.kuali.rice.kew.rule.bo.RuleTemplate; |
33 | |
import org.kuali.rice.kim.bo.impl.GroupImpl; |
34 | |
import org.kuali.rice.kns.bo.BusinessObject; |
35 | |
import org.kuali.rice.kns.bo.Exporter; |
36 | |
import org.kuali.rice.kns.exception.ExportNotSupportedException; |
37 | |
import org.kuali.rice.kns.util.KNSConstants; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public class EdlDataExporter implements Exporter { |
48 | |
|
49 | 0 | private List<String> supportedFormats = new ArrayList<String>(); |
50 | |
|
51 | 0 | public EdlDataExporter() { |
52 | 0 | supportedFormats.add(KNSConstants.XML_FORMAT); |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public List<String> getSupportedFormats(Class<?> dataObjectClass) { |
57 | 0 | return supportedFormats; |
58 | |
} |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
protected ExportDataSet buildExportDataSet(Class<?> dataObjectClass, List<? extends Object> dataObjects) { |
64 | 0 | EdlExportDataSet dataSet = new EdlExportDataSet(); |
65 | 0 | for (Object dataObject : dataObjects) { |
66 | 0 | if (dataObjectClass.equals(EDocLiteAssociation.class)) { |
67 | 0 | dataSet.getEdocLites().add((EDocLiteAssociation)dataObject); |
68 | |
} |
69 | |
} |
70 | |
|
71 | 0 | return dataSet.createExportDataSet(); |
72 | |
} |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
@Override |
80 | |
public void export(Class<?> dataObjectClass, List<? extends Object> dataObjects, String exportFormat, OutputStream outputStream) throws IOException, |
81 | |
ExportNotSupportedException { |
82 | 0 | if (!KNSConstants.XML_FORMAT.equals(exportFormat)) { |
83 | 0 | throw new ExportNotSupportedException("The given export format of " + exportFormat + " is not supported by the EDocLite XML Exporter!"); |
84 | |
} |
85 | 0 | ExportDataSet dataSet = buildExportDataSet(dataObjectClass, dataObjects); |
86 | 0 | outputStream.write(CoreApiServiceLocator.getXmlExporterService().export(dataSet)); |
87 | 0 | outputStream.flush(); |
88 | |
|
89 | 0 | } |
90 | |
} |