View Javadoc

1   package org.kuali.ole.patron;
2   
3   import org.kuali.ole.ingest.FileUtil;
4   import org.kuali.ole.patron.bo.OlePatronDocument;
5   import org.kuali.ole.patron.bo.OlePatronIngestSummaryRecord;
6   import org.kuali.ole.service.OlePatronConverterService;
7   
8   import java.io.File;
9   import java.net.URL;
10  import java.util.List;
11  
12  /**
13   * Created with IntelliJ IDEA.
14   * User: peris
15   * Date: 10/31/12
16   * Time: 11:06 AM
17   * To change this template use File | Settings | File Templates.
18   */
19  public class LoadDefaultPatronsBean {
20      private String fileName;
21      private OlePatronConverterService olePatronIngestService;
22  
23      public List<OlePatronDocument> loadDefaultPatrons() throws Exception {
24          URL resource = getClass().getResource(fileName);
25          File file = new File(resource.toURI());
26          String fileContent = new FileUtil().readFile(file);
27          List<OlePatronDocument> olePatronDocuments =
28                  olePatronIngestService.persistPatronFromFileContent(fileContent,
29                          true,
30                          true,
31                          file.getName(),
32                          new OlePatronIngestSummaryRecord());
33          return olePatronDocuments;
34      }
35  
36      public String getFileName() {
37          return fileName;
38      }
39  
40      public void setFileName(String fileName) {
41          this.fileName = fileName;
42      }
43  
44      public OlePatronConverterService getOlePatronIngestService() {
45          return olePatronIngestService;
46      }
47  
48      public void setOlePatronIngestService(OlePatronConverterService olePatronIngestService) {
49          this.olePatronIngestService = olePatronIngestService;
50      }
51  }