View Javadoc
1   package org.kuali.ole.circ;
2   
3   import net.sf.json.JSONObject;
4   import org.apache.commons.io.FileUtils;
5   import org.kuali.ole.circ.pojos.CircReportData;
6   
7   import java.io.File;
8   import java.io.IOException;
9   import java.util.ArrayList;
10  import java.util.Iterator;
11  import java.util.List;
12  
13  public class CircReport {
14  
15  	public List<CircReportData> getReportData() throws IOException{
16  		
17  		List<CircReportData> reportDataList = new ArrayList<CircReportData>();
18  		
19  		List<String> lines = FileUtils.readLines(new File(System
20  				.getProperty("user.home")
21  				+ "/kuali/main/local/reports/circ-report.txt"));
22  		for (Iterator<String> itr = lines.iterator(); itr.hasNext();) {
23  			CircReportData circReportData = new CircReportData();
24  			
25  			String line = (String) itr.next();
26  			JSONObject jo = JSONObject.fromObject(line);
27  			String firstName = (String) jo.get("firstName");
28  			circReportData.setFirstName(firstName);
29  			
30  			String lastName = (String) jo.get("lastName");
31  			circReportData.setLastName(lastName);
32  
33  			String patronType = (String) jo.get("patronType");
34  			circReportData.setPatronType(patronType);
35  
36  			String checkoutDate = (String) jo.get("checkoutDate");
37  			circReportData.setCheckoutDate(checkoutDate);
38  
39  			JSONObject ja = (JSONObject) jo.get("item");
40  
41  			String itemId = (String) ja.get("itemId");
42  			circReportData.setItemId(itemId);
43  			
44  			String itemType = (String) ja.get("itemType");
45  			circReportData.setItemType(itemType);
46  			
47  			String itemLocation = (String) ja.get("itemLocation");
48  			circReportData.setItemLocation(itemLocation);
49  
50  			String itemBarcode = (String) ja.get("itemBarcode");
51  			circReportData.setItemBarcode(itemBarcode);
52  			
53  			reportDataList.add(circReportData);
54  		}
55  		
56  		return reportDataList;
57  	}
58  
59      public String userName = "root";
60  
61      public String getUserName() {
62          return userName;
63      }
64  
65      public void setUserName(String userName) {
66          this.userName = userName;
67      }
68  }