1 package org.kuali.ole;
2
3 import com.thoughtworks.xstream.XStream;
4 import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord;
5 import org.kuali.ole.pojo.OleBibRecord;
6 import org.kuali.ole.pojo.OleOrderRecord;
7 import org.kuali.ole.pojo.OleTxRecord;
8 import org.kuali.ole.pojo.edi.EDIOrder;
9
10
11
12
13
14
15
16
17 public class OleOrderRecordHandler {
18
19 public OleOrderRecords fromXML(String marcXMLContent) {
20 XStream xStream = new XStream();
21 xStream.alias("records", OleOrderRecords.class);
22 xStream.alias("record", OleOrderRecord.class);
23 xStream.alias("oleBibRecord", OleBibRecord.class);
24 xStream.aliasField("bibRecord", OleOrderRecord.class, "oleBibRecord");
25 xStream.aliasField("bibFileName", OleOrderRecord.class, "oleOriginalBibRecordFileName");
26 xStream.aliasField("ediFileName", OleOrderRecord.class, "originalEDIFileName");
27 xStream.alias("oleTxRecord", OleTxRecord.class);
28 xStream.aliasField("transactionRecord", OleOrderRecord.class, "oleTxRecord");
29 xStream.alias("originalRecord", BibMarcRecord.class);
30 xStream.aliasField("bibMarcRecord", OleOrderRecord.class, "originalRecord");
31 xStream.alias("originalEdi", EDIOrder.class);
32 xStream.aliasField("ediOrder", OleOrderRecord.class, "originalEdi");
33 xStream.addImplicitCollection(OleOrderRecords.class, "records");
34 return (OleOrderRecords) xStream.fromXML(marcXMLContent);
35 }
36
37
38 public String toXML(OleOrderRecords oleOrderRecords) {
39 StringBuffer stringBuffer = new StringBuffer();
40 stringBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
41 stringBuffer.append("\n");
42 XStream xStream = new XStream();
43 xStream.alias("records", OleOrderRecords.class);
44 xStream.alias("record", OleOrderRecord.class);
45 xStream.alias("oleBibRecord", OleBibRecord.class);
46 xStream.aliasField("bibRecord", OleOrderRecord.class, "oleBibRecord");
47 xStream.aliasField("bibFileName", OleOrderRecord.class, "oleOriginalBibRecordFileName");
48 xStream.aliasField("ediFileName", OleOrderRecord.class, "originalEDIFileName");
49 xStream.alias("oleTxRecord", OleTxRecord.class);
50 xStream.aliasField("transactionRecord", OleOrderRecord.class, "oleTxRecord");
51 xStream.alias("originalRecord", BibMarcRecord.class);
52 xStream.aliasField("bibMarcRecord", OleOrderRecord.class, "originalRecord");
53 xStream.alias("originalEdi", EDIOrder.class);
54 xStream.aliasField("ediOrder", OleOrderRecord.class, "originalEdi");
55 xStream.addImplicitCollection(OleOrderRecords.class, "records");
56 String xml = xStream.toXML(oleOrderRecords);
57 stringBuffer.append(xml);
58 stringBuffer.append("\n");
59 return stringBuffer.toString();
60 }
61 }