View Javadoc
1   package org.kuali.ole.converters;
2   
3   import com.thoughtworks.xstream.XStream;
4   import com.thoughtworks.xstream.converters.Converter;
5   import com.thoughtworks.xstream.converters.MarshallingContext;
6   import com.thoughtworks.xstream.converters.UnmarshallingContext;
7   import com.thoughtworks.xstream.io.HierarchicalStreamReader;
8   import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
9   import org.kuali.ole.bo.explain.OleSRUExplainDatabaseTitle;
10  import org.kuali.ole.bo.serachRetrieve.OleSRUCirculationDocument;
11  
12  /**
13   * Created with IntelliJ IDEA.
14   * User: maheswarang
15   * Date: 9/13/13
16   * Time: 4:48 PM
17   * To change this template use File | Settings | File Templates.
18   */
19  public class OleSRUCirculationDocumentConverter implements Converter {
20  
21      @Override
22      public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
23          OleSRUCirculationDocument oleSRUCirculationDocument = (OleSRUCirculationDocument) o;
24          if(oleSRUCirculationDocument.getAvailableNow()!=null){
25              hierarchicalStreamWriter.startNode("availableNow");
26              hierarchicalStreamWriter.addAttribute("value",oleSRUCirculationDocument.getAvailableNow());
27              hierarchicalStreamWriter.endNode();
28          }
29          if(oleSRUCirculationDocument.getAvailabilityDate()!=null){
30              hierarchicalStreamWriter.startNode("availabilityDate");
31              hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getAvailabilityDate());
32              hierarchicalStreamWriter.endNode();
33          }
34          if(oleSRUCirculationDocument.getAvailableThru()!=null) {
35              hierarchicalStreamWriter.startNode("availableThru");
36              hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getAvailableThru());
37              hierarchicalStreamWriter.endNode();
38          }
39          if(oleSRUCirculationDocument.getRestrictions()!=null){
40              hierarchicalStreamWriter.startNode("restrictions");
41              hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getRestrictions());
42              hierarchicalStreamWriter.endNode();
43          }
44          if(oleSRUCirculationDocument.getItemId()!=null){
45          hierarchicalStreamWriter.startNode("itemId");
46          hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getItemId());
47          hierarchicalStreamWriter.endNode();
48          }
49  
50          if(oleSRUCirculationDocument.getRenewable()!=null){
51          hierarchicalStreamWriter.startNode("renewable");
52          hierarchicalStreamWriter.addAttribute("value",oleSRUCirculationDocument.getRenewable());
53          hierarchicalStreamWriter.endNode();
54          }if(oleSRUCirculationDocument.getOnHold()!=null){
55          hierarchicalStreamWriter.startNode("onHold");
56          hierarchicalStreamWriter.addAttribute("value",oleSRUCirculationDocument.getOnHold());
57          hierarchicalStreamWriter.endNode();
58          }
59          if(oleSRUCirculationDocument.getEnumAndChron()!=null){
60          hierarchicalStreamWriter.startNode("enumAndChron");
61          hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getEnumAndChron());
62          hierarchicalStreamWriter.endNode();
63          }if(oleSRUCirculationDocument.getMidspine()!=null){
64          hierarchicalStreamWriter.startNode("midspine");
65          hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getMidspine());
66          hierarchicalStreamWriter.endNode();
67          }
68          if(oleSRUCirculationDocument.getTemporaryLocation()!=null){
69          hierarchicalStreamWriter.startNode("temporaryLocation");
70          hierarchicalStreamWriter.setValue(oleSRUCirculationDocument.getTemporaryLocation());
71          hierarchicalStreamWriter.endNode();
72          }
73      }
74  
75      @Override
76      public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
77          OleSRUCirculationDocument oleSRUCirculationDocument = new OleSRUCirculationDocument();
78        //  oleSRUCirculationDocument.setAvailableNow(hierarchicalStreamReader.getAttribute("value"));
79          return oleSRUCirculationDocument;
80      }
81  
82      @Override
83      public boolean canConvert(Class aClass) {
84          return aClass.equals(OleSRUCirculationDocument.class);
85      }
86  
87  }