Bah, added a couple more missing classes to fm_IDL.xml. In developer/debug mode...
authorkenstir <kenstir@gmail.com>
Sun, 3 Nov 2013 18:21:08 +0000 (13:21 -0500)
committerkenstir <kenstir@gmail.com>
Sun, 3 Nov 2013 18:21:08 +0000 (13:21 -0500)
Open-ILS/src/Android/assets/fm_IDL.xml
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java

index eb917e0..fc7491f 100644 (file)
                        <field name='serials' oils_persist:virtual='true'></field>
                        <field name='foreign_copy_maps' oils_persist:virtual='true'></field>
                </fields>
+       </class><class id='ex' controller='open-ils.cstore' oils_obj:fieldmapper='ex' oils_persist:virtual='true'>
+               <fields>
+                       <field name='err_msg' oils_persist:virtual='true'></field>
+                       <field name='type' oils_persist:virtual='true'></field>
+               </fields>
+       </class><class id='perm_ex' controller='open-ils.cstore' oils_obj:fieldmapper='perm_ex' oils_persist:virtual='true'>
+               <fields>
+                       <field name='err_msg' oils_persist:virtual='true'></field>
+                       <field name='type' oils_persist:virtual='true'></field>
+               </fields>
        </class><class id='mbts' controller='open-ils.cstore' oils_obj:fieldmapper='money::billable_transaction_summary' oils_persist:tablename='money.materialized_billable_xact_summary' reporter:label='Billable Transaction Summary' oils_persist:readonly='true'>
                <fields oils_persist:primary='id' oils_persist:sequence=''>
                        <field reporter:label='Balance Owed' name='balance_owed' reporter:datatype='money'></field>
                 <delete permission='DELETE_VOLUME' context_field='owning_lib'></delete>
             </actions>
         </permacrud>
+       </class><class id='mous' controller='open-ils.cstore open-ils.pcrud' oils_obj:fieldmapper='money::open_user_summary' oils_persist:tablename='money.open_usr_summary' reporter:label='Open User Summary'>
+               <fields oils_persist:primary='usr' oils_persist:sequence=''>
+                       <field name='balance_owed' reporter:datatype='money'></field>
+                       <field name='total_owed' reporter:datatype='money'></field>
+                       <field name='total_paid' reporter:datatype='money'></field>
+                       <field name='usr' reporter:datatype='link'></field>
+               </fields>
+               <links>
+                       <link field='usr' reltype='has_a' key='id' map='' class='au'></link>
+        </links>
+        <permacrud xmlns='http://open-ils.org/spec/opensrf/IDL/permacrud/v1'>
+            <actions>
+                <retrieve permission='VIEW_USER'>
+                    <context link='usr' field='home_ou'></context>
+                </retrieve>
+            </actions>
+        </permacrud>
        </class><class id='au' controller='open-ils.cstore open-ils.pcrud' oils_obj:fieldmapper='actor::user' oils_persist:tablename='actor.usr' reporter:core='true' reporter:label='ILS User'>
                <fields oils_persist:primary='id' oils_persist:sequence='actor.usr_id_seq'>
                        <field reporter:label='All Addresses' name='addresses' oils_persist:virtual='true' reporter:datatype='link'></field>
                                <retrieve permission='VIEW_CIRCULATIONS' context_field='circ_lib'></retrieve>
                        </actions>
                </permacrud>
+       </class><class id='ahr' controller='open-ils.cstore open-ils.pcrud' oils_obj:fieldmapper='action::hold_request' oils_persist:tablename='action.hold_request' reporter:core='true' reporter:label='Hold Request'>
+               <fields oils_persist:primary='id' oils_persist:sequence='action.hold_request_id_seq'>
+                       <field reporter:label='Status' name='status' oils_persist:virtual='true'></field>
+                       <field reporter:label='Transit' name='transit' oils_persist:virtual='true'></field>
+                       <field reporter:label='Capture Date/Time' name='capture_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Currently Targeted Copy' name='current_copy'></field>
+                       <field reporter:label='Notify by Email?' name='email_notify' reporter:datatype='bool'></field>
+                       <field reporter:label='Hold Expire Date/Time' name='expire_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Fulfilling Library' name='fulfillment_lib' reporter:datatype='org_unit'></field>
+                       <field reporter:label='Fulfilling Staff' name='fulfillment_staff'></field>
+                       <field reporter:label='Fulfillment Date/Time' name='fulfillment_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Hold Type' name='hold_type' reporter:datatype='text'></field>
+                       <field reporter:label='Holdable Formats (for M-type hold)' name='holdable_formats' reporter:datatype='text'></field>
+                       <field reporter:label='Hold ID' name='id' reporter:datatype='id'></field>
+                       <field reporter:label='Notifications Phone Number' name='phone_notify' reporter:datatype='text'></field>
+                       <field reporter:label='Notifications SMS Number' name='sms_notify' reporter:datatype='text'></field>
+                       <field reporter:label='Notifications SMS Carrier' name='sms_carrier' reporter:datatype='link'></field>
+                       <field reporter:label='Pickup Library' name='pickup_lib' reporter:datatype='org_unit'></field>
+                       <field reporter:label='Last Targeting Date/Time' name='prev_check_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Requesting Library' name='request_lib' reporter:datatype='org_unit'></field>
+                       <field reporter:label='Request Date/Time' name='request_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Requesting User' name='requestor' reporter:datatype='link'></field>
+                       <field reporter:label='Item Selection Depth' name='selection_depth'></field>
+                       <field reporter:label='Selection Locus' name='selection_ou' reporter:datatype='org_unit'></field>
+                       <field reporter:label='Target Object ID' name='target' reporter:datatype='link'></field>
+                       <field reporter:label='Hold User' name='usr' reporter:datatype='link'></field>
+                       <field reporter:label='Hold Cancel Date/Time' name='cancel_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Notify Time' name='notify_time' oils_persist:virtual='true' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Notify Count' name='notify_count' oils_persist:virtual='true' reporter:datatype='int'></field>
+                       <field reporter:label='Notifications' name='notifications' oils_persist:virtual='true' reporter:datatype='link'></field>
+                       <field reporter:label='Bib Record link' name='bib_rec' oils_persist:virtual='true' reporter:datatype='link'></field>
+                       <field reporter:label='Eligible Copies' name='eligible_copies' oils_persist:virtual='true' reporter:datatype='link'></field>
+                       <field reporter:label='Currently Frozen' name='frozen' reporter:datatype='bool'></field>
+                       <field reporter:label='Thaw Date (if frozen)' name='thaw_date' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Shelf Time' name='shelf_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Cancelation cause' name='cancel_cause' reporter:datatype='link'></field>
+                       <field reporter:label='Cancelation note' name='cancel_note' reporter:datatype='text'></field>
+                       <field reporter:label='Top of Queue' name='cut_in_line' reporter:datatype='bool'></field>
+                       <field reporter:label='Is Mint Condition' name='mint_condition' reporter:datatype='bool'></field>
+                       <field reporter:label='Shelf Expire Time' name='shelf_expire_time' reporter:datatype='timestamp'></field>
+                       <field reporter:label='Notes' name='notes' reporter:datatype='link' oils_persist:virtual='true'></field>
+                       <field reporter:label='Current Shelf Lib' name='current_shelf_lib' reporter:datatype='org_unit'></field>
+               </fields>
+               <links>
+                       <link field='fulfillment_lib' reltype='has_a' key='id' map='' class='aou'></link>
+                       <link field='fulfillment_staff' reltype='has_a' key='id' map='' class='au'></link>
+                       <link field='pickup_lib' reltype='has_a' key='id' map='' class='aou'></link>
+                       <link field='selection_ou' reltype='has_a' key='id' map='' class='aou'></link>
+                       <link field='requestor' reltype='has_a' key='id' map='' class='au'></link>
+                       <link field='current_copy' reltype='has_a' key='id' map='' class='acp'></link>
+                       <link field='usr' reltype='has_a' key='id' map='' class='au'></link>
+                       <link field='request_lib' reltype='has_a' key='id' map='' class='aou'></link>
+                       <link field='transit' reltype='might_have' key='hold' map='' class='ahtc'></link>
+                       <link field='notifications' reltype='has_many' key='hold' map='' class='ahn'></link>
+                       <link field='eligible_copies' reltype='has_many' key='hold' map='target_copy' class='ahcm'></link>
+                       <link field='bib_rec' reltype='might_have' key='id' map='' class='rhrr'></link>
+                       <link field='cancel_cause' reltype='might_have' key='id' map='' class='ahrcc'></link>
+                       <link field='notes' reltype='has_many' key='hold' map='' class='ahrn'></link>
+                       <link field='current_shelf_lib' reltype='has_a' key='id' map='' class='aou'></link>
+                       <link field='sms_carrier' reltype='has_a' key='id' map='' class='csc'></link>
+               </links>
+               <permacrud xmlns='http://open-ils.org/spec/opensrf/IDL/permacrud/v1'>
+                       <actions>
+                               <retrieve permission='VIEW_HOLD' context_field='pickup_lib'></retrieve>
+                       </actions>
+               </permacrud>
        </class><class id='mbt' controller='open-ils.cstore' oils_obj:fieldmapper='money::billable_transaction' oils_persist:tablename='money.billable_xact' reporter:label='Billable Transaction'>
                <fields oils_persist:primary='id' oils_persist:sequence='money.billable_xact_id_seq'>
                        <field reporter:label='Transaction ID' name='id' reporter:datatype='id'></field>
index c9c49fa..ea4de75 100644 (file)
@@ -49,6 +49,8 @@ public class GlobalConfigs {
     private boolean init = false;
 
     private static String TAG = "GlobalConfigs";
+    
+    private static boolean debugMode = true;//KCXXX make a developer preference
 
     public static boolean loadedIDL = false;
 
@@ -139,6 +141,14 @@ public class GlobalConfigs {
         return false;
     }
 
+    public static boolean isDebugMode() {
+        return debugMode;
+    }
+
+    public static void setDebugMode(boolean debugMode) {
+        GlobalConfigs.debugMode = debugMode;
+    }
+
     public void loadIDLFile(Context context) {
 
         try {
index 7c95c13..d6f2bd9 100644 (file)
@@ -44,9 +44,11 @@ import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
+import android.util.Log;
 import android.widget.ImageView;
 
 public class Utils {
+    private static final String TAG = "osrf";
 
     /**
      * Gets the net page content.
@@ -246,18 +248,29 @@ public class Utils {
         // TODO check params and throw errors
         Method method = new Method(methodName);
 
-        System.out.println("doRequest Method :" + methodName + ": token :"+authToken+":");
+        Log.d(TAG, "doRequest Method :" + methodName + ": token :"+authToken+":");
         for (int i = 0; i < params.length; i++) {
             method.addParam(params[i]);
-            System.out.println("Param " + i + ":" + params[i]);
+            Log.d(TAG, "Param " + i + ":" + params[i]);
         }
 
         // sync request
         HttpRequest req = new GatewayRequest(conn, service, method).send();
-        Object resp;
+        Object resp = null;
 
-        while ((resp = req.recv()) != null) {
-            System.out.println("Sync Response: " + resp);
+        try {
+            resp = req.recv();
+        } catch (NullPointerException e) {
+            // I know it's bad form to catch NPE.  But until I implement some kind of on-demand IDL parsing,
+            // this is what happens when the JSONReader tries to parse a response of an unregistered class.
+            // Crash if debugMode, fail if not.
+            Log.d(TAG, "NPE...unregistered type?", e);
+            if (GlobalConfigs.isDebugMode()) {
+                throw(e);
+            }
+        }
+        if (resp != null) {
+            Log.d(TAG, "Sync Response: " + resp);
             Object response = (Object) resp;
 
             String textcode = null;
@@ -269,7 +282,7 @@ public class Utils {
 
             if (textcode != null) {
                 if (textcode.equals("NO_SESSION")) {
-                    System.out.println(textcode);
+                    Log.d(TAG, textcode);
                     throw new SessionNotFoundException();
                 }
             }