Checkout Items list done need UI dev on it
authordrizea <danielrizea27@gmail.com>
Fri, 22 Jun 2012 10:43:47 +0000 (13:43 +0300)
committerdrizea <danielrizea27@gmail.com>
Fri, 22 Jun 2012 10:43:47 +0000 (13:43 +0300)
27 files changed:
Open-ILS/src/Android/AndroidManifest.xml
Open-ILS/src/Android/bin/EvergreenApp.apk
Open-ILS/src/Android/bin/classes.dex
Open-ILS/src/Android/bin/classes/org/evergreen/android/R$id.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/R$layout.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/R$string.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/R$style.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/accountAccess/AccountAccess.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/GlobalConfigs.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/Utils.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/RecordDetails_Info.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/RecordDetails_Simple.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/SearchCatalogListView$SearchArrayAdapter.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/SearchCatalogListView.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/views/AccountScreenDashboard.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/views/MainScreenDashboard.class
Open-ILS/src/Android/bin/resources.ap_
Open-ILS/src/Android/gen/org/evergreen/android/R.java
Open-ILS/src/Android/res/layout/checkout_list.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/checkout_list_item.xml [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/CircRecord.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/ItemsCheckOutListView.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java
Open-ILS/src/Android/src/org/evergreen/android/views/AccountScreenDashboard.java
Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java

index 62dd77e..f7e108d 100644 (file)
             >
             
         </activity>
+        <!-- Checkout Activities -->
+        <activity android:name=".accountAccess.ItemsCheckOutListView"></activity>
+        
+        
         <activity android:name=".searchCatalog.RecordDetails_Info"></activity>
                <activity android:name=".searchCatalog.RecordDetails_Content"></activity>
         <activity android:name=".searchCatalog.RecordDetails_Details"></activity>
index a509b91..5da62bd 100644 (file)
Binary files a/Open-ILS/src/Android/bin/EvergreenApp.apk and b/Open-ILS/src/Android/bin/EvergreenApp.apk differ
index f5b3829..e581937 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes.dex and b/Open-ILS/src/Android/bin/classes.dex differ
index ec62a43..ad2bdbf 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$id.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$id.class differ
index 6902809..a3691bd 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$layout.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$layout.class differ
index a89ce8d..41838a3 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$string.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$string.class differ
index 691ff58..ec88073 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$style.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$style.class differ
index 54541b0..e5aa7a2 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/accountAccess/AccountAccess.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/accountAccess/AccountAccess.class differ
index a5c9166..11a444f 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/GlobalConfigs.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/GlobalConfigs.class differ
index 4bafd67..cf77100 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/Utils.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/Utils.class differ
index 87c03f0..1508826 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/RecordDetails_Info.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/RecordDetails_Info.class differ
index f7108d9..91afbd0 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/RecordDetails_Simple.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/RecordDetails_Simple.class differ
index 059da9d..6c41859 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/SearchCatalogListView$SearchArrayAdapter.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/SearchCatalogListView$SearchArrayAdapter.class differ
index 645b13f..210f902 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/SearchCatalogListView.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/searchCatalog/SearchCatalogListView.class differ
index b0692a3..7843c35 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/views/AccountScreenDashboard.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/views/AccountScreenDashboard.class differ
index 6d79b61..32fcbeb 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/views/MainScreenDashboard.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/views/MainScreenDashboard.class differ
index 55306db..622e538 100644 (file)
Binary files a/Open-ILS/src/Android/bin/resources.ap_ and b/Open-ILS/src/Android/bin/resources.ap_ differ
index dd086d2..df2f635 100644 (file)
@@ -48,43 +48,50 @@ public final class R {
         public static final int settings=0x7f02000a;
     }
     public static final class id {
-        public static final int account_btn_book_bags=0x7f090003;
-        public static final int account_btn_check_out=0x7f090000;
-        public static final int account_btn_fines=0x7f090002;
-        public static final int account_btn_holds=0x7f090001;
-        public static final int chose_organisation=0x7f09001a;
-        public static final int main_btn_account=0x7f090005;
-        public static final int main_btn_app_settings=0x7f090006;
-        public static final int main_btn_search=0x7f090004;
-        public static final int record_details_info_author=0x7f090008;
-        public static final int record_details_info_publisher=0x7f090009;
-        public static final int record_details_info_title=0x7f090007;
-        public static final int record_details_simple_author=0x7f09000b;
-        public static final int record_details_simple_isbn=0x7f090010;
-        public static final int record_details_simple_publisher=0x7f09000c;
-        public static final int record_details_simple_series=0x7f09000e;
-        public static final int record_details_simple_subject=0x7f09000d;
-        public static final int record_details_simple_synopsis=0x7f09000f;
-        public static final int record_details_simple_title=0x7f09000a;
-        public static final int searchButton=0x7f090017;
-        public static final int searchText=0x7f090016;
-        public static final int search_more_items_button=0x7f090011;
-        public static final int search_record_author=0x7f090014;
-        public static final int search_record_img=0x7f090012;
-        public static final int search_record_publishing=0x7f090015;
-        public static final int search_record_title=0x7f090013;
-        public static final int search_result_number=0x7f090018;
-        public static final int search_results_list=0x7f090019;
+        public static final int account_btn_book_bags=0x7f090009;
+        public static final int account_btn_check_out=0x7f090006;
+        public static final int account_btn_fines=0x7f090008;
+        public static final int account_btn_holds=0x7f090007;
+        public static final int checkout_due_date=0x7f090005;
+        public static final int checkout_items_list=0x7f090001;
+        public static final int checkout_record_author=0x7f090003;
+        public static final int checkout_record_title=0x7f090002;
+        public static final int checkout_renewals_remaining=0x7f090004;
+        public static final int chose_organisation=0x7f09001f;
+        public static final int main_btn_account=0x7f09000b;
+        public static final int main_btn_app_settings=0x7f09000c;
+        public static final int main_btn_search=0x7f09000a;
+        public static final int record_details_info_author=0x7f09000e;
+        public static final int record_details_info_publisher=0x7f09000f;
+        public static final int record_details_info_title=0x7f09000d;
+        public static final int record_details_simple_author=0x7f090011;
+        public static final int record_details_simple_isbn=0x7f090016;
+        public static final int record_details_simple_publisher=0x7f090012;
+        public static final int record_details_simple_series=0x7f090014;
+        public static final int record_details_simple_subject=0x7f090013;
+        public static final int record_details_simple_synopsis=0x7f090015;
+        public static final int record_details_simple_title=0x7f090010;
+        public static final int searchButton=0x7f09001d;
+        public static final int searchText=0x7f09001c;
+        public static final int search_more_items_button=0x7f090017;
+        public static final int search_record_author=0x7f09001a;
+        public static final int search_record_img=0x7f090018;
+        public static final int search_record_publishing=0x7f09001b;
+        public static final int search_record_title=0x7f090019;
+        public static final int search_result_number=0x7f090000;
+        public static final int search_results_list=0x7f09001e;
     }
     public static final class layout {
-        public static final int dashbord_account=0x7f030000;
-        public static final int dashbord_main=0x7f030001;
-        public static final int main=0x7f030002;
-        public static final int record_details_info=0x7f030003;
-        public static final int record_details_simple=0x7f030004;
-        public static final int search_result_footer_view=0x7f030005;
-        public static final int search_result_item=0x7f030006;
-        public static final int search_result_list=0x7f030007;
+        public static final int checkout_list=0x7f030000;
+        public static final int checkout_list_item=0x7f030001;
+        public static final int dashbord_account=0x7f030002;
+        public static final int dashbord_main=0x7f030003;
+        public static final int main=0x7f030004;
+        public static final int record_details_info=0x7f030005;
+        public static final int record_details_simple=0x7f030006;
+        public static final int search_result_footer_view=0x7f030007;
+        public static final int search_result_item=0x7f030008;
+        public static final int search_result_list=0x7f030009;
     }
     public static final class string {
         public static final int app_name=0x7f070001;
diff --git a/Open-ILS/src/Android/res/layout/checkout_list.xml b/Open-ILS/src/Android/res/layout/checkout_list.xml
new file mode 100644 (file)
index 0000000..392ff2a
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+    
+    
+     <LinearLayout android:layout_width="fill_parent"
+         android:layout_height="wrap_content">
+         <TextView 
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:text="@string/search_result_text"
+             />
+         
+         <TextView 
+             android:id="@+id/search_result_number"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:textStyle="bold"
+             />
+         
+     </LinearLayout>
+     
+       <ListView 
+         android:id="@+id/checkout_items_list"
+         android:layout_width="fill_parent"
+         android:layout_height="wrap_content"  
+         ></ListView>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/res/layout/checkout_list_item.xml b/Open-ILS/src/Android/res/layout/checkout_list_item.xml
new file mode 100644 (file)
index 0000000..5c28453
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="left|center"
+       android:paddingBottom="3px"
+       android:paddingTop="3px" 
+       android:paddingLeft="3px" 
+    android:orientation="horizontal" >
+
+       <LinearLayout 
+       android:layout_width="wrap_content"
+    android:layout_height="fill_parent"
+    android:orientation="vertical"
+    android:gravity="center_vertical" 
+       android:paddingLeft="4dip"
+       >
+               <TextView
+               android:id="@+id/checkout_record_title"
+               style="@style/TitleSearchStyleList"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"/>   
+           
+               <TextView
+               android:id="@+id/checkout_record_author"
+               style="@style/AuthorSearchStyleList"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"/>
+                   
+               <TextView
+               android:id="@+id/checkout_renewals_remaining"
+               style="@style/PubSearchStyleList"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"/>
+               
+               <TextView
+               android:id="@+id/checkout_due_date"
+               style="@style/PubSearchStyleList"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"/>
+
+       </LinearLayout>
+</LinearLayout>
\ No newline at end of file
index 0241111..1985ae1 100644 (file)
@@ -17,6 +17,7 @@ import org.opensrf.util.OSRFObject;
 
 /**
  * The Class AuthenticateUser.
+ * Singleton class
  */
 public class AccountAccess {
 
@@ -221,12 +222,13 @@ public class AccountAccess {
        /** The password. */
        public static String password = "demo123";
        
+       private static AccountAccess accountAccess = null;
        /**
         * Instantiates a new authenticate user.
         *
         * @param httpAddress the http address
         */
-       public AccountAccess(String httpAddress) {
+       private AccountAccess(String httpAddress) {
 
                this.httpAddress = httpAddress;
 
@@ -243,6 +245,42 @@ public class AccountAccess {
 
        }
 
+       public static AccountAccess getAccountAccess(String httpAddress){
+               
+               if(accountAccess == null){
+                       accountAccess = new AccountAccess(httpAddress);
+               }
+               if(!httpAddress.equals(accountAccess.httpAddress))
+                       accountAccess.updateHttpAddress(httpAddress);
+                       
+               return accountAccess;
+       }
+       
+       // the object must be initialized before 
+       public static AccountAccess getAccountAccess(){
+               
+               if(accountAccess != null){
+                       return accountAccess;
+               }
+               
+               return null;
+       }
+       /*
+        * Change the Http conn to a new library address
+        */
+       public void updateHttpAddress(String httpAddress){
+               
+               try {
+                       // configure the connection
+                       
+                       System.out.println("Connection with " + httpAddress);
+                       conn = new HttpConnection(httpAddress + "/osrf-gateway-v1");
+
+               } catch (Exception e) {
+                       System.err.println("Exception in establishing connection "
+                                       + e.getMessage());
+               }
+       }
        /**
         * Md5.
         *
@@ -374,6 +412,8 @@ public class AccountAccess {
                                        System.err.println("Error in parsing authtime " + e.getMessage());
                                }
                                
+                               //get user ID
+                               accountAccess.getAccountSummary();
                                return true;
                        }
                
@@ -384,34 +424,60 @@ public class AccountAccess {
        
        //------------------------Checked Out Items Section -------------------------//
        
-       public void getItemsCheckedOut(){
+       public ArrayList<CircRecord> getItemsCheckedOut(){
 
+               
+               ArrayList<CircRecord> circRecords = new ArrayList<CircRecord>();
+               /*
                ArrayList<OSRFObject> long_overdue = new ArrayList<OSRFObject>();
                ArrayList<OSRFObject> claims_returned = new ArrayList<OSRFObject>();
                ArrayList<OSRFObject> lost = new ArrayList<OSRFObject>();
                ArrayList<OSRFObject> out = new ArrayList<OSRFObject>();
+               ArrayList<OSRFObject> overdue = new ArrayList<OSRFObject>();
+               */
                
+               //fetch ids
                List<String> long_overdue_id;
+               List<String> overdue_id;
                List<String> claims_returned_id;
                List<String> lost_id;
                List<String> out_id;
                
+               
                Object resp  =  Utils.doRequest(conn, SERVICE_ACTOR, METHOD_FETCH_CHECKED_OUT_SUM, new Object[]{authToken, userID});
 
                        long_overdue_id = (List<String>)((Map<String,?>)resp).get("long_overdue");
                        claims_returned_id = (List<String>)((Map<String,?>)resp).get("claims_returned");
                        lost_id = (List<String>)((Map<String,?>)resp).get("lost");
                        out_id = (List<String>)((Map<String,?>)resp).get("out");
+                       overdue_id = (List<String>)((Map<String,?>)resp).get("overdue");
                        
                        //get all the record circ info
-                       for(int i=0;i<out_id.size();i++){
-                               //System.out.println(out.get(i));
-                               out.add(retrieveCircRecord(out_id.get(i)));
-
-                               System.out.println(out.get(i).get("target_copy"));
-                               fetchInfoForCheckedOutItem(out.get(i).get("target_copy")+"");
-                               
-                       }
+                       if(out_id != null)
+                               for(int i=0;i<out_id.size();i++){
+                                       //get circ 
+                                       OSRFObject circ = retrieveCircRecord(out_id.get(i));
+                                       CircRecord circRecord = new CircRecord(circ, CircRecord.OUT,Integer.parseInt(out_id.get(i)));
+                                       //get info
+                                       fetchInfoForCheckedOutItem(circ.getInt("target_copy"), circRecord);
+                                       circRecords.add(circRecord);
+                                       
+                                       //System.out.println(out.get(i).get("target_copy"));
+                                       //fetchInfoForCheckedOutItem(out.get(i).get("target_copy")+""); 
+                               }
+                       
+                       if(overdue_id != null)
+                               for(int i=0;i<overdue_id.size();i++){
+                                       //get circ 
+                                       OSRFObject circ = retrieveCircRecord(overdue_id.get(i));
+                                       CircRecord circRecord = new CircRecord(circ, CircRecord.OVERDUE, Integer.parseInt(overdue_id.get(i)));
+                                       //fetch info
+                                       fetchInfoForCheckedOutItem(circ.getInt("target_copy"), circRecord);
+                                       circRecords.add(circRecord);
+                                       
+                               }
+                       //TODO are we using this too? In the opac they are not used
+                       /*
                        for(int i=0;i<lost_id.size();i++){
                                //System.out.println(out.get(i));
                                lost.add(retrieveCircRecord(lost_id.get(i)));
@@ -424,41 +490,54 @@ public class AccountAccess {
                                //System.out.println(out.get(i));
                                long_overdue.add(retrieveCircRecord(long_overdue_id.get(i)));
                        }
-               
+                        */
+                       
+                       return circRecords;
+       }
+       /* Retrieves the Circ record
+        * @param : target_copy from circ
+        * @returns : "circ" OSRFObject 
+        */
+       private OSRFObject retrieveCircRecord(String id){
+
+               OSRFObject circ  = (OSRFObject) Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_CIRC_BY_ID, new Object[]{authToken,id});
+               return circ;
        }
+       
        /* Fetch info for Checked Out Items
         * It uses two methods  : open-ils.search.biblio.mods_from_copy or in case
         * of pre-cataloged records it uses open-ils.search.asset.copy.retriev
         * Usefull info : title and author 
         *  (for acp : dummy_title, dummy_author)
         */
-       private OSRFObject fetchInfoForCheckedOutItem(String target_copy){
+       private OSRFObject fetchInfoForCheckedOutItem(Integer target_copy, CircRecord circRecord){
+               
+               if(target_copy == null)
+                       return null;
                
                OSRFObject result;
+               System.out.println("Mods from copy");
                OSRFObject info_mvr = fetchModsFromCopy(target_copy);
                //if title or author not inserted, request acp with copy_target
                result = info_mvr;
                OSRFObject info_acp = null;
-               
-               if(info_mvr.get("title") == null || info_mvr.get("author") == null){
+
+               //the logic to establish mvr or acp is copied from the opac
+               if(info_mvr.getString("title") == null || info_mvr.getString("author") == null){
+                       System.out.println("Asset");
                        info_acp = fetchAssetCopy(target_copy);
                        result = info_acp;
+                       circRecord.acp = info_acp;
+                       circRecord.circ_info_type = CircRecord.ACP_OBJ_TYPE;
+               }
+               else{
+                       circRecord.mvr = info_mvr;
+                       circRecord.circ_info_type = CircRecord.MVR_OBJ_TYPE;
                }
-               
                return result;
        }
        
-       /* Retreives the Circ record
-        * @param : target_copy from circ
-        * @returns : "circ" OSRFObject 
-        */
-       private OSRFObject retrieveCircRecord(String id){
-
-               OSRFObject circ  = (OSRFObject) Utils.doRequest(conn, SERVICE_CIRC, METHOD_FETCH_CIRC_BY_ID, new Object[]{authToken,id});
-               return circ;
-       }
-       
-       private OSRFObject fetchModsFromCopy(String target_copy){
+       private OSRFObject fetchModsFromCopy(Integer target_copy){
 
                //sync request          
                OSRFObject mvr  = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_MODS_FROM_COPY, new Object[]{target_copy});
@@ -466,12 +545,15 @@ public class AccountAccess {
                return mvr;
        }
        
-       private OSRFObject fetchAssetCopy(String target_copy){
+       private OSRFObject fetchAssetCopy(Integer target_copy){
                
                OSRFObject acp  = (OSRFObject) Utils.doRequest(conn, SERVICE_SEARCH, METHOD_FETCH_COPY, new Object[]{target_copy});
                
                return acp;
        }
+
+       
+
        /* Method used to renew a circulation record based on target_copy_id
         * Returns many objects, don't think they are needed
         */
@@ -558,7 +640,7 @@ public class AccountAccess {
                
                if(type.equals("C")){
                        //fetch_copy
-                       OSRFObject copyObject = fetchAssetCopy(hold.getString("target"));       
+                       OSRFObject copyObject = fetchAssetCopy(hold.getInt("target"));  
                        //fetch_volume from copyObject.call_number field
                        Integer call_number = copyObject.getInt("call_number");
                        
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/CircRecord.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/CircRecord.java
new file mode 100644 (file)
index 0000000..d36693a
--- /dev/null
@@ -0,0 +1,124 @@
+package org.evergreen.android.accountAccess;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.opensrf.util.OSRFObject;
+
+/**
+ * This is a wrapper class that get the information out for a circ object 
+ * @author daniel
+ *
+ */
+public class CircRecord {
+
+       public static final int MVR_OBJ_TYPE = 1;
+       public static final int ACP_OBJ_TYPE = 2;
+       public static final int UNDEF_OBJ_TYPE = 0;
+       
+       public OSRFObject mvr = null;
+       
+       public OSRFObject acp = null;
+       
+       public OSRFObject circ = null;
+       
+       public int circ_info_type = UNDEF_OBJ_TYPE;
+       
+       public int circ_type;
+       
+       public static final int OUT = 0;
+       public static final int CLAIMS_RETURNED = 1;
+       public static final int LONG_OVERDUE = 2;
+       public static final int OVERDUE = 3;
+       public static final int LOST = 4;
+       
+       public int circ_id = -1;
+       
+       private static final String datePattern = "yyyy-MM-dd'T'hh:mm:ssZ";
+       
+       private Date circ_due_date = null;
+       
+       public CircRecord(OSRFObject circ, OSRFObject mvr, OSRFObject acp, int circ_type, int circ_id) {
+               
+               this.circ = circ;
+               
+               //one of the acp or mvr will be null this will determine the circ OSRFObject type
+               this.acp = acp;
+               this.mvr = mvr;
+               
+               if(this.acp != null)
+                       this.circ_info_type  = ACP_OBJ_TYPE;
+               
+               if(this.mvr != null)
+                       this.circ_info_type = MVR_OBJ_TYPE;
+               
+               this.circ_type = circ_type;
+               this.circ_id = circ_id;
+               //parse due date
+               parseDate(circ);
+       }
+       
+       public CircRecord(OSRFObject circ,int circ_type, int circ_id){
+               this.circ = circ;
+               this.circ_type = circ_type;
+               this.circ_id = circ_id;
+               //parse due date
+               parseDate(circ);
+       }
+       
+       public String getAuthor(){
+               
+               String author = null;
+               
+               if(this.circ_info_type == MVR_OBJ_TYPE)
+                       author = mvr.getString("author");
+               if(this.circ_info_type == ACP_OBJ_TYPE)
+                       author = acp.getString("dummy_author");
+                       
+               return author;
+       }
+       
+       
+       public String getDueDate(){
+               
+               return circ_due_date.toLocaleString();
+       }
+       
+       public String getTitle(){
+               
+               String title = null;
+               
+               if(this.circ_info_type == MVR_OBJ_TYPE)
+                       title = mvr.getString("title");
+               if(this.circ_info_type == ACP_OBJ_TYPE)
+                       title = acp.getString("dummy_title");
+               
+               return title;
+       }
+       
+       public String getRenewals(){
+               
+               if(circ != null)
+                       circ.getInt("renewal_remaining");
+                       
+               return null;
+       }
+       
+       private void parseDate(OSRFObject circ){
+               
+               final SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
+        
+               if(circ.getString("due_date") != null)
+                       try
+               {
+                   this.circ_due_date = sdf.parse(circ.getString("due_date"));
+                   System.out.println(this.circ_due_date);
+               } 
+               catch (ParseException e)
+               {
+                   e.printStackTrace();
+               }
+       }
+       
+}
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/ItemsCheckOutListView.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/ItemsCheckOutListView.java
new file mode 100644 (file)
index 0000000..053fb36
--- /dev/null
@@ -0,0 +1,134 @@
+package org.evergreen.android.accountAccess;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.evergreen.android.R;
+import org.evergreen.android.globals.GlobalConfigs;
+import org.evergreen.android.searchCatalog.RecordInfo;
+import org.opensrf.util.OSRFObject;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class ItemsCheckOutListView extends Activity{
+
+       private String TAG = "ItemsCheckOutListView";
+       
+       private AccountAccess accountAccess = null;
+       
+       private ListView lv;
+       
+       private CheckOutArrayAdapter listAdapter = null;
+
+       private ArrayList<CircRecord> circRecords = null;
+       
+       @Override
+       public void onCreate(Bundle savedInstanceState) {
+               // TODO Auto-generated method stub
+               super.onCreate(savedInstanceState);
+               
+               setContentView(R.layout.checkout_list);
+               
+               accountAccess = AccountAccess.getAccountAccess();
+               
+               lv = (ListView) findViewById(R.id.checkout_items_list);
+               
+               circRecords = accountAccess.getItemsCheckedOut();
+               
+               listAdapter = new CheckOutArrayAdapter(this, R.layout.checkout_list_item, circRecords);
+               lv.setAdapter(listAdapter);
+               
+
+
+               listAdapter.notifyDataSetChanged();
+
+       }
+       
+       
+         class CheckOutArrayAdapter extends ArrayAdapter<CircRecord> {
+               private static final String tag = "CheckoutArrayAdapter";
+               
+               private TextView recordTitle;
+               private TextView recordAuthor;
+               private TextView recordDueDate;
+               private TextView recordRenewals;
+               
+               private List<CircRecord> records = new ArrayList<CircRecord>();
+
+               public CheckOutArrayAdapter(Context context, int textViewResourceId,
+                               List<CircRecord> objects) {
+                       super(context, textViewResourceId, objects);
+                       this.records = objects;
+               }
+
+               public int getCount() {
+                       return this.records.size();
+               }
+
+               public CircRecord getItem(int index) {
+                       return this.records.get(index);
+               }
+
+               public View getView(int position, View convertView, ViewGroup parent) {
+                       View row = convertView;
+                       
+                       // Get item
+                       CircRecord record = getItem(position);
+                       
+                       
+                       if(record == null)
+                       {
+                                       Log.d(tag, "Starting XML view more infaltion ... ");
+                               LayoutInflater inflater = (LayoutInflater) this.getContext()
+                                               .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+                               row = inflater.inflate(R.layout.search_result_footer_view, parent, false);
+                               Log.d(tag, "Successfully completed XML view more Inflation!");
+
+                               
+                               }
+                       else{
+                       
+                               //if it is the right type of view
+                                       if (row == null ) {
+               
+                                                       Log.d(tag, "Starting XML Row Inflation ... ");
+                                                       LayoutInflater inflater = (LayoutInflater) this.getContext()
+                                                                       .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+                                                       row = inflater.inflate(R.layout.checkout_list_item, parent, false);
+                                                       Log.d(tag, "Successfully completed XML Row Inflation!");
+               
+                                       }
+
+                               // Get reference to TextView - title
+                               recordTitle = (TextView) row.findViewById(R.id.checkout_record_title);
+                               
+                               // Get reference to TextView - author
+                               recordAuthor = (TextView) row.findViewById(R.id.checkout_record_author);
+                               
+                               //Get reference to TextView - record Publisher date+publisher
+                               recordDueDate = (TextView) row.findViewById(R.id.checkout_due_date);
+                   
+                               //Get remaining renewals
+                               recordRenewals = (TextView) row.findViewById(R.id.checkout_renewals_remaining);
+                               //set text
+                               System.out.println("Row" + record.getTitle() + " " + record.getAuthor() + " " + record.getDueDate() + " " + record.getRenewals());
+                               recordTitle.setText(record.getTitle());
+                               recordAuthor.setText(record.getAuthor());
+                               recordDueDate.setText(record.getDueDate());
+                               recordRenewals.setText(record.getRenewals());
+                       }
+                       
+                       return row;
+               }
+           }
+}
index b5533d3..d6db656 100644 (file)
@@ -66,7 +66,7 @@ public class GlobalConfigs {
                        
                        
                        //authenticate
-                       AccountAccess ac = new AccountAccess(GlobalConfigs.httpAddress);
+                       AccountAccess ac = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
                        ac.authenticate();
                        
                        return true;
index be017b2..333dc34 100644 (file)
@@ -9,6 +9,7 @@ import java.net.MalformedURLException;
 import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.Map;
 
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -18,7 +19,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
-import org.evergreen.android.accountAccess.SessionNotFoundException;
+import org.evergreen.android.accountAccess.AccountAccess;
 import org.opensrf.Method;
 import org.opensrf.net.http.GatewayRequest;
 import org.opensrf.net.http.HttpConnection;
@@ -218,15 +219,17 @@ public class Utils {
         
 
        }
-       
-       public static Object doRequest(HttpConnection conn, String service, String methodName, Object[] params) throws SessionNotFoundException{
-
+       //TODO throw NO_SESSION 
+       public static Object doRequest(HttpConnection conn, String service, String methodName, Object[] params) //throws SessionNotFoundException{
+       {
                //TODO check params and throw errors
                Method method = new Method(methodName);
-
-               for(int i=0;i<params.length;i++)
-               method.addParam(params[i]);
-               
+               System.out.println();
+               for(int i=0;i<params.length;i++){
+                       method.addParam(params[i]);
+                       System.out.print("Param "+i+":" + params[i]);
+               }
+               System.out.println();
                //sync request
                HttpRequest req = new GatewayRequest(conn, service, method).send();
                Object resp;
@@ -234,12 +237,37 @@ public class Utils {
                while ((resp = req.recv()) != null) {
                        System.out.println("Sync Response: " + resp);
                        Object response = (Object) resp;
-                       return response;
+                       
+                               try{
+                                       String textcode = ((Map<String,String>)response).get("textcode");
+                                       if(textcode != null){
+                                               if(textcode.equals("NO_SESSION")){
+                                                       response = requireNewSession(conn, service, methodName, params);
+                                               }
+                                               
+                                       }
+                               }catch(Exception e){
+                                       
+                               }
+                               return response;
                        
                }
                return null;
                
        }
-
+       
+       public static Object requireNewSession(HttpConnection conn, String service, String methodName, Object[] params){
+               
+               AccountAccess ac = AccountAccess.getAccountAccess();
+               boolean success = ac.authenticate();
+               
+               Object response = null;
+               
+               if(success){
+                       response =  doRequest(conn, service, methodName, params);
+               }
+               
+               return response;
+       }
 
 }
index c5dd27d..30c20e7 100644 (file)
@@ -2,9 +2,10 @@
 package org.evergreen.android.views;
 
 import org.evergreen.android.R;
-import org.evergreen.android.globals.GlobalConfigs;
+import org.evergreen.android.accountAccess.ItemsCheckOutListView;
 
 import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
 
@@ -110,7 +111,7 @@ public class AccountScreenDashboard extends Activity {
            switch (id) {
           
              case R.id.account_btn_check_out :
-                  //startActivity (new Intent(getApplicationContext(), F3Activity.class));
+                  startActivity (new Intent(getApplicationContext(),ItemsCheckOutListView.class));
                   break;
              case R.id.account_btn_holds:
                   //startActivity (new Intent(getApplicationContext(), F4Activity.class));
index e7d82e2..416f00d 100644 (file)
@@ -75,6 +75,8 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                        String key) {
                
+               
+               
                if(key.equals("username")){
                        AccountAccess.userName = sharedPreferences.getString("username", "");
                }else
@@ -95,7 +97,7 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                        public void run() {
                                
                                boolean routeToAddress = true;
-                               AccountAccess account = new AccountAccess(GlobalConfigs.httpAddress);
+                               AccountAccess account = AccountAccess.getAccountAccess(GlobalConfigs.httpAddress);
                                try{
                                        Utils.checkNetworkStatus((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE), context);
                                }catch(NoNetworkAccessException e){