View Javadoc

1   package org.kuali.ole.patron.merge.controller;
2   
3   import com.thoughtworks.xstream.XStream;
4   import org.kuali.ole.deliver.loan.bo.OleLoanDocument;
5   import org.kuali.ole.patron.merge.bo.OleConfigDocument;
6   import org.kuali.ole.patron.merge.bo.OlePatronConfig;
7   
8   import java.io.IOException;
9   import java.net.URISyntaxException;
10  import java.util.HashMap;
11  
12  /**
13   * Created with IntelliJ IDEA.
14   * User: vivekb
15   * Date: 8/22/12
16   * Time: 3:04 PM
17   * To change this template use File | Settings | File Templates.
18   */
19  public class OlePatronConfigObjectGeneratorFromXML {
20      /**
21       *  This method returns PatronConfig object from fileContent.
22       *  The xStream will convert the fileContent into PatronConfig Object.
23       * @param fileContent
24       * @return PatronConfig object
25       * @throws java.net.URISyntaxException
26       * @throws java.io.IOException
27       */
28  
29      private HashMap<String,Object> patronConfigDocuments = new HashMap<String, Object>();
30  
31      public OlePatronConfig buildKrmsFromFileContent(String fileContent) throws URISyntaxException, IOException {
32          XStream xStream = new XStream();
33          xStream.alias("patronConfig", OlePatronConfig.class);
34          xStream.alias("document", OleConfigDocument.class);
35          Object object = xStream.fromXML(fileContent);
36          return (OlePatronConfig) object;
37      }
38  
39      public OlePatronConfigObjectGeneratorFromXML() {
40          patronConfigDocuments.put("loanDocument",OleLoanDocument.class);
41      }
42  
43      public HashMap<String, Object> getPatronConfigDocuments() {
44          return patronConfigDocuments;
45      }
46  
47      public void setPatronConfigDocuments(HashMap<String, Object> patronConfigDocuments) {
48          this.patronConfigDocuments = patronConfigDocuments;
49      }
50  }