* indicate item type in search results, e.g. "ebook" or "lpbook"
authorkenstir <kenstir@gmail.com>
Thu, 15 Oct 2015 02:52:23 +0000 (22:52 -0400)
committerkenstir <kenstir@gmail.com>
Thu, 15 Oct 2015 02:52:23 +0000 (22:52 -0400)
* this requires an extra round-trip using the PCRUD service, which
  in turn requires an extra round of special-case parsing of what
  looks like Data::Dumper formatted output

Open-ILS/src/Android/core/libs/opensrf2_android.jar
Open-ILS/src/Android/core/res/layout/search_result_item.xml
Open-ILS/src/Android/core/res/values/styles.xml
Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java
Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/RecordInfo.java
Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalog.java
Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java
Open-ILS/src/Android/cwmars_app/fetch_idl.sh

index 71af946..11940e0 100644 (file)
Binary files a/Open-ILS/src/Android/core/libs/opensrf2_android.jar and b/Open-ILS/src/Android/core/libs/opensrf2_android.jar differ
index 3629f7d..93f8399 100644 (file)
                android:src="@drawable/address_book"
                android:padding="4dip"
                />
-       
-       
-       
+
        <LinearLayout 
        android:layout_width="wrap_content"
     android:layout_height="fill_parent"
     android:orientation="vertical"
-    android:gravity="center_vertical" 
+    android:gravity="top"
        android:paddingLeft="4dip"
        >
                <TextView
                style="@style/TitleSearchStyleList"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
-               
-                />   
-           
+                />
+
                <TextView
-               android:id="@+id/search_record_author"
-               style="@style/AuthorSearchStyleList"
-               android:layout_width="wrap_content"
-               android:layout_height="wrap_content"
+                               android:id="@+id/search_record_format"
+                               style="@style/AuthorSearchStyleList"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               />
+
+               <TextView
+                               android:id="@+id/search_record_author"
+                               style="@style/AuthorSearchStyleList"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               />
 
-               />
-                   
                <TextView
                android:id="@+id/search_record_publishing"
                style="@style/PubSearchStyleList"
index 4bffa6b..27b3487 100644 (file)
@@ -34,7 +34,7 @@
     </style>
 
     <style name="TitleSearchStyleList">
-        <item name="android:textSize">16sp</item>
+        <item name="android:textSize">14sp</item>
         <item name="android:gravity">left</item>
         <item name="android:textStyle">bold</item>
         <!--
index a6c33bf..ddc1fdc 100644 (file)
@@ -37,7 +37,7 @@ import java.util.*;
 
 public class GlobalConfigs {
 
-    public static String IDL_FILE_FROM_ROOT = "/reports/fm_IDL.xml?class=acn&class=acp&class=ahr&class=ahtc&class=au&class=bmp&class=cbreb&class=cbrebi&class=cbrebin&class=cbrebn&class=ccs&class=circ&class=ex&class=mbt&class=mbts&class=mous&class=mus&class=mvr&class=perm_ex";
+    public static String IDL_FILE_FROM_ROOT = "/reports/fm_IDL.xml?class=acn&class=acp&class=ahr&class=ahtc&class=au&class=bmp&class=cbreb&class=cbrebi&class=cbrebin&class=cbrebn&class=ccs&class=circ&class=ex&class=mbt&class=mbts&class=mous&class=mra&class=mus&class=mvr&class=perm_ex";
     public static String IDL_FILE_FROM_ASSETS = "fm_IDL.xml";
     public static String httpAddress = "";
 
index f69fa94..a2ed760 100644 (file)
@@ -31,8 +31,6 @@ import org.opensrf.util.OSRFObject;
 
 public class RecordInfo implements Serializable {
 
-    // {"title","author","doc_id","doc_type","pubdate","isbn","publisher","tcn","subject","type_of_resources","call_numbers","edition","online_loc","synopsis","physical_description","toc","copy_count","series","serials","foreign_copy_maps"});
-
     private static final long serialVersionUID = 10123L;
 
     private final String TAG = RecordInfo.class.getName();
@@ -69,6 +67,7 @@ public class RecordInfo implements Serializable {
     public ArrayList<CopyCountInformation> copyCountListInfo = null;
 
     public List<CopyInformation> copyInformationList = null;
+    public String search_format = null;
 
     public RecordInfo() {
         this.title = "Test title";
index 264bc5c..ea6513b 100644 (file)
@@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
+import android.text.TextUtils;
 import org.evergreen_ils.globals.GlobalConfigs;
 import org.evergreen_ils.globals.Utils;
 import org.opensrf.Method;
@@ -42,13 +43,10 @@ import android.util.Log;
  */
 public class SearchCatalog {
 
-    /** The SERVICE. */
     public static String SERVICE = "open-ils.search";
-
-    /** The METHO d_ multicas s_ search. */
+    public static String PCRUD_SERVICE = "open-ils.pcrud";
+    public static String PCRUD_METHOD_RETRIEVE_MRA = "open-ils.pcrud.retrieve.mra";
     public static String METHOD_MULTICLASS_QUERY = "open-ils.search.biblio.multiclass.query";
-
-    /** The METHO d_ sli m_ retrive. */
     public static String METHOD_SLIM_RETRIVE = "open-ils.search.biblio.record.mods_slim.retrieve";
 
     /**
@@ -57,7 +55,6 @@ public class SearchCatalog {
      * @param : no parameters
      * @returns : returns array of ccs objects
      */
-
     public static String METHOD_COPY_STATUS_ALL = "open-ils.search.config.copy_status.retrieve.all";
 
     /**
@@ -94,13 +91,9 @@ public class SearchCatalog {
     public static String METHOD_GET_COPY_COUNT = "open-ils.search.biblio.record.copy_count";
 
     public static SearchCatalog searchCatalogSingleton = null;
-    /** The conn. */
-    public HttpConnection conn;
 
-    // TODO get statuses on load
-    // open-ils.search.config.copy_status.retrieve.all
+    public HttpConnection conn;
 
-    /** The TAG. */
     public String TAG = "SearchCatalog";
 
     // the org on witch the searches will be made
@@ -222,14 +215,16 @@ public class SearchCatalog {
         // request other info based on ids
 
         for (int i = 0; i < ids.size(); i++) {
+            Integer record_id = Integer.parseInt(ids.get(i));
 
-            RecordInfo record = new RecordInfo(getItemShortInfo(Integer.parseInt(ids.get(i))));
+            RecordInfo record = new RecordInfo(getItemShortInfo(record_id));
             resultsRecordInfo.add(record);
 
-            record.copyCountListInfo = getCopyCount(
-                    Integer.parseInt(ids.get(i)), this.selectedOrganization.id);
+            record.search_format = getFormat(record_id);
+
+            record.copyCountListInfo = getCopyCount(record_id, this.selectedOrganization.id);
             List<List<Object>> list = (List<List<Object>>) getLocationCount(
-                    Integer.parseInt(ids.get(i)), this.selectedOrganization.id,
+                    record_id, this.selectedOrganization.id,
                     this.selectedOrganization.level - 1);
             if (list != null)
                 for (int j = 0; j < list.size(); j++) {
@@ -254,56 +249,30 @@ public class SearchCatalog {
      * @return the item short info
      */
     private OSRFObject getItemShortInfo(Integer id) {
-
-        Method method = new Method(METHOD_SLIM_RETRIVE);
-
-        method.addParam(id);
-
-        HttpRequest req = new GatewayRequest(conn, SERVICE, method).send();
-        Object resp;
-        while ((resp = req.recv()) != null) {
-            Log.d(TAG, "Sync Response: " + resp);
-            return (OSRFObject) resp;
-        }
-
-        return null;
-    }
-
-    /**
-     * Search catalog.
-     * 
-     * @param searchWords
-     *            the search words
-     * @return the object
-     */
-    public Object searchCatalog(String searchWords) {
-
-        Object response = Utils.doRequest(conn, SERVICE, METHOD_SLIM_RETRIVE,
-                new Object[] { "keyword", searchWords });
-
+        OSRFObject response = (OSRFObject) Utils.doRequestSimple(conn, SERVICE,
+                METHOD_SLIM_RETRIVE, new Object[] {
+                        id });
         return response;
-
     }
 
-    /**
-     * Search catalog.
-     * 
-     * @param searchWords
-     *            the search words
-     * @param requestHandler
-     *            the request handler
-     */
-    public void searchCatalog(String searchWords,
-            HttpRequestHandler requestHandler) {
-
-        Method method = new Method(METHOD_SLIM_RETRIVE);
-
-        method.addParam(searchWords);
-
-        // sync test
-        HttpRequest req = new GatewayRequest(conn, SERVICE, method).send();
-        req.sendAsync(requestHandler);
-
+    private String getFormat(Integer id) {
+        OSRFObject resp = (OSRFObject) Utils.doRequestSimple(conn, PCRUD_SERVICE,
+                PCRUD_METHOD_RETRIEVE_MRA, new Object[] { "ANONYMOUS", id });
+
+        // This is not beautiful.  This MRA record comes back with an 'attrs' field that
+        // appears to have been serialized by perl Data::Dumper, e.g.
+        // '"biog"=>"b", "conf"=>"0", "search_format"=>"ebook"'.
+        String attrs = resp.getString("attrs");
+        Log.d(TAG, "attrs="+attrs);
+        String[] attr_arr = TextUtils.split(attrs, ", ");
+        for (int i=0; i<attr_arr.length; ++i) {
+            String[] kv = TextUtils.split(attr_arr[i], "=>");
+            String key = kv[0].replace("\"", "");
+            if (key.equalsIgnoreCase("search_format")) {
+                return kv[1].replace("\"", "");
+            }
+        }
+        return "";
     }
 
     public Object getCopyStatuses() {
index ae9e559..9a5f548 100644 (file)
@@ -686,6 +686,7 @@ public class SearchCatalogListView extends ActionBarActivity {
         private ImageView recordImage;
         private TextView recordTitle;
         private TextView recordAuthor;
+        private TextView recordFormat;
         private TextView recordPublisher;
 
         private List<RecordInfo> records = new ArrayList<RecordInfo>();
@@ -735,11 +736,13 @@ public class SearchCatalogListView extends ActionBarActivity {
 
             recordTitle = (TextView) row.findViewById(R.id.search_record_title);
             recordAuthor = (TextView) row.findViewById(R.id.search_record_author);
+            recordFormat = (TextView) row.findViewById(R.id.search_record_format);
             recordPublisher = (TextView) row.findViewById(R.id.search_record_publishing);
 
             // set text
             recordTitle.setText(record.title);
             recordAuthor.setText(record.author);
+            recordFormat.setText(record.search_format);
             recordPublisher.setText(record.pubdate + " " + record.publisher);
 
             return row;
index 55b8cc9..302e4b7 100644 (file)
@@ -1,3 +1,3 @@
 #!/bin/sh
 root=http://bark.cwmars.org
-curl -o fm_IDL.xml "$root/reports/fm_IDL.xml?class=acn&class=acp&class=ahr&class=ahtc&class=au&class=bmp&class=cbreb&class=cbrebi&class=cbrebin&class=cbrebn&class=ccs&class=circ&class=ex&class=mbt&class=mbts&class=mous&class=mus&class=mvr&class=perm_ex"
+curl -o fm_IDL.xml "$root/reports/fm_IDL.xml?class=acn&class=acp&class=ahr&class=ahtc&class=au&class=bmp&class=cbreb&class=cbrebi&class=cbrebin&class=cbrebn&class=ccs&class=circ&class=ex&class=mbt&class=mbts&class=mous&class=mra&class=mus&class=mvr&class=perm_ex"