added copy information for record search details
authordrizea <danielrizea27@gmail.com>
Sun, 15 Jul 2012 08:41:05 +0000 (11:41 +0300)
committerdrizea <danielrizea27@gmail.com>
Sun, 15 Jul 2012 08:41:05 +0000 (11:41 +0300)
the copy statuses are downloaded at the beggining of the program so each library can have it's own personalised copy statuses. The ui is not finished but the information is available (must also convert org_id into name)

Open-ILS/src/Android/res/layout/copy_information.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/record_details_basic_fragment.xml
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/CopyInformation.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java
Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java

diff --git a/Open-ILS/src/Android/res/layout/copy_information.xml b/Open-ILS/src/Android/res/layout/copy_information.xml
new file mode 100644 (file)
index 0000000..2b6abf0
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+    
+
+    <LinearLayout 
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        >
+        
+        <TextView 
+            android:id="@+id/copy_information_library"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            />
+        
+        <TextView 
+            android:id="@+id/copy_information_call_number"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            />
+        
+        <TextView 
+            android:id="@+id/copy_information_copy_location"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            />
+        
+        
+    </LinearLayout>
+    
+    
+    <LinearLayout 
+        android:id="@+id/copy_information_statuses"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:paddingLeft="30dip"
+        >
+        
+        
+    </LinearLayout>
+    
+    
+</LinearLayout>
\ No newline at end of file
index 7bc52f2..61bb72d 100644 (file)
     </LinearLayout>
 
     <ScrollView
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" >
 
         <LinearLayout
+            android:id="@+id/content_layout"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical" >
             <TextView
                 android:id="@+id/record_details_simple_isbn"
                 style="@style/textSmall" />
+            
+            <TextView
+                xmlns:android="http://schemas.android.com/apk/res/android"
+                style="@style/sectionHeader"
+                android:text="Copy information" />
+            
         </LinearLayout>
     </ScrollView>
 
index 33a2808..be96aa2 100644 (file)
@@ -10,6 +10,7 @@ import java.util.StringTokenizer;
 import org.evergreen.android.accountAccess.AccountAccess;
 import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.searchCatalog.Organisation;
+import org.evergreen.android.searchCatalog.SearchCatalog;
 import org.evergreen.android.views.ApplicationPreferences;
 import org.open_ils.idl.IDLParser;
 
@@ -91,6 +92,8 @@ public class GlobalConfigs {
                                loadIDLFile();
                                getOrganisations();
                        
+                               getCopyStatusesAvailable((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE));
+                               
                                AccountAccess.setAccountInfo(preferences.getString("username", ""), preferences.getString("password", ""));
                                
                                
@@ -271,6 +274,22 @@ public class GlobalConfigs {
                }
        }
        
+       public void getCopyStatusesAvailable(ConnectivityManager cm){
+               
+               SearchCatalog search = SearchCatalog.getInstance(cm);
+               
+               try {
+                       search.getCopyStatuses();
+               } catch (NoNetworkAccessException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (NoAccessToServer e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       
+       }
+       
        public void getOrgHiddentDepth(){
                
                // logic can be found in the opac_utils.js file in web/opac/common/js
index 9b96807..bb68679 100644 (file)
@@ -1,28 +1,60 @@
 package org.evergreen.android.searchCatalog;
 
+import java.io.Serializable;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
 
-public class CopyInformation {
+public class CopyInformation implements Serializable{
 
        
-       public Integer org_id;
+       /**
+        * 
+        */
+       private static final long serialVersionUID = -7269334218707079463L;
+
+       public Integer org_id = -1;
        
        public String call_number_sufix;
        
        public String copy_location;
        
        public HashMap<String,String> statuses;
+
+       //the hash from the request method 
+       private HashMap<Integer,Integer> hashValCopy;
+       
+       //global, it is initialized when orgTree and fm_ild is downloaded
        
+       public static LinkedHashMap<String,String> availableOrgStatuses;
        
-       public CopyInformation(List<String> list){
+       public LinkedHashMap<String, String> statusInformation = null;
+       
+       public CopyInformation(List<Object> list){
+               
+               org_id = Integer.parseInt((String)list.get(0));
+               call_number_sufix = (String)list.get(2);
+               copy_location = (String)list.get(4);
+
+               hashValCopy = (HashMap<Integer,Integer>)list.get(5);
                
+               statusInformation = new LinkedHashMap<String, String>();
                
-               org_id = Integer.parseInt(list.get(0));
-               call_number_sufix = list.get(1);
-               copy_location = list.get(2);
+               Set<Entry<String,String>> set = availableOrgStatuses.entrySet();
                
+               Iterator<Entry<String,String>> it = set.iterator();
                
+               while(it.hasNext()){
+                       Entry<String,String> entry = it.next();
+                       
+                       if(hashValCopy.containsKey(entry.getKey())){
+                               statusInformation.put(entry.getValue(), hashValCopy.get(entry.getKey())+"");
+                               System.out.println("Added " + entry.getKey()+ " " + entry.getValue() + " " + hashValCopy.get(entry.getKey()));
+                       }
+               }
        }
        
        
index af1ce81..0169ba9 100644 (file)
@@ -1,6 +1,7 @@
 package org.evergreen.android.searchCatalog;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -46,16 +47,19 @@ public class RecordInfo implements Serializable{
        
        public boolean dummy = false;
        
+       public List<CopyInformation> copyInformationList = null;
+       
        public RecordInfo(){
                this.title = "Test title";
                this.author = "Test author";
                this.pubdate = "Publication date";
+               copyInformationList = new ArrayList<CopyInformation>();
                
                //marks the fact that this is a record made from no info
                this.dummy = true;
        }
        public RecordInfo(OSRFObject info){
-               
+               copyInformationList = new ArrayList<CopyInformation>();
                try{
 
                        this.title = info.getString("title");
index c3151c3..e4a0e36 100644 (file)
@@ -57,8 +57,6 @@ public class SampleUnderlinesNoFade extends BaseSampleActivity {
         public Fragment getItem(int position) {
                        // position +1 for 1 - size values
                        return BasicDetailsFragment.newInstance(records.get(position),position+1,records.size());
-               
-           
         }
 
         @Override
index f4dccd0..c21d0de 100644 (file)
@@ -1,13 +1,12 @@
 
 package org.evergreen.android.searchCatalog;
 
-import java.io.NotSerializableException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.evergreen.android.accountAccess.SessionNotFoundException;
 import org.evergreen.android.globals.GlobalConfigs;
 import org.evergreen.android.globals.NoAccessToServer;
 import org.evergreen.android.globals.NoNetworkAccessException;
@@ -19,7 +18,6 @@ import org.opensrf.net.http.HttpRequest;
 import org.opensrf.net.http.HttpRequestHandler;
 import org.opensrf.util.OSRFObject;
 
-import android.content.Context;
 import android.net.ConnectivityManager;
 import android.util.Log;
 
@@ -53,10 +51,17 @@ public class SearchCatalog {
        */
        public static String METHOD_COPY_LOCATION_COUNTS = "open-ils.search.biblio.copy_location_counts.summary.retrieve";
 
+       /**
+        * Get copy statuses like Available, Checked_out , in_progress and others, ccs OSRFObjects
+        */
+       public static String METHOD_GET_COPY_STATUSES = "open-ils.search.config.copy_status.retrieve.all";
+       
        public static SearchCatalog searchCatalogSingleton = null;
        /** The conn. */
        public HttpConnection conn;
        
+       //TODO get statuses on load
+       //open-ils.search.config.copy_status.retrieve.all 
        
        /** The TAG. */
        public String TAG = "SearchCatalog";
@@ -174,7 +179,18 @@ public class SearchCatalog {
                for(int i=0;i<ids.size();i++){
                        
                        RecordInfo record = new RecordInfo(getItemShortInfo(ids.get(i)));
+                       //get copy information
                        resultsRecordInfo.add(record);
+                       
+                       //get copy count 
+                       List<List<Object>> list= (List<List<Object>>)getLocationCount(Integer.parseInt(ids.get(i)), this.selectedOrganization.id, this.selectedOrganization.level-1);
+                       
+                       for(int j=0; j<list.size();j++){
+                               CopyInformation copyInfo = new CopyInformation(list.get(j));
+                               
+                               record.copyInformationList.add(copyInfo);
+                       }
+                       
                        System.out.println("Title " + record.title + " Author " + record.author + " Pub date" + record.pubdate +" Publisher" + record.publisher);
                }
                
@@ -240,6 +256,25 @@ public class SearchCatalog {
        }
 
        
+       public Object getCopyStatuses() throws NoNetworkAccessException, NoAccessToServer{
+               
+               List<OSRFObject> ccs_list = (List<OSRFObject>)Utils.doRequest(conn, SERVICE, METHOD_COPY_STATUS_ALL, cm, new Object[]{});
+               
+               CopyInformation.availableOrgStatuses = new LinkedHashMap<String,String>();
+               
+               for(int i=0;i<ccs_list.size();i++){
+                       OSRFObject ccs_obj = ccs_list.get(i);
+                       if(ccs_obj.getString("opac_visible").equals("t")){
+                               
+                               CopyInformation.availableOrgStatuses.put(ccs_obj.getInt("id")+"", ccs_obj.getString("name"));
+                               System.out.println("Add status " + ccs_obj.getString("name"));
+                               
+                       }
+               }
+               
+               return ccs_list;
+       }
+       
        public Object getLocationCount(Integer recordID, Integer orgID, Integer orgDepth) throws NoNetworkAccessException, NoAccessToServer{
                
                List<?> list = (List<?>)Utils.doRequest(conn, SERVICE, METHOD_COPY_LOCATION_COUNTS, cm, new Object[]{recordID, orgID, orgDepth});
index bcbe9c8..948c08e 100644 (file)
@@ -1,18 +1,21 @@
 package org.evergreen.android.utils.ui;
 
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+
 import org.evergreen.android.R;
+import org.evergreen.android.searchCatalog.CopyInformation;
 import org.evergreen.android.searchCatalog.RecordInfo;
 
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
-import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
 import android.widget.LinearLayout;
-import android.widget.ScrollView;
 import android.widget.TextView;
-import android.widget.LinearLayout.LayoutParams;
 
 public class BasicDetailsFragment extends Fragment{
 
@@ -83,6 +86,50 @@ public class BasicDetailsFragment extends Fragment{
                        isbnTextView.setText(record.isbn);
                        
                        
+                       
+                       for(int i=0;i<record.copyInformationList.size();i++){
+                               
+                               View copy_info_view = inflater.inflate(R.layout.copy_information, null);
+       
+                               // fill in any details dynamically here
+                               TextView library = (TextView) copy_info_view.findViewById(R.id.copy_information_library);
+                               TextView call_number = (TextView) copy_info_view.findViewById(R.id.copy_information_call_number);
+                               TextView copy_location = (TextView) copy_info_view.findViewById(R.id.copy_information_copy_location);
+
+                               library.setText(record.copyInformationList.get(i).org_id+"");
+                               call_number.setText(record.copyInformationList.get(i).call_number_sufix);
+                               copy_location.setText(record.copyInformationList.get(i).copy_location);
+                               
+                               // insert into main view
+                               LinearLayout insertPoint = (LinearLayout) layout.findViewById(R.id.content_layout);
+                               insertPoint.addView(copy_info_view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+
+                               LinearLayout copy_statuses = (LinearLayout) copy_info_view.findViewById(R.id.copy_information_statuses);
+                               
+                               
+                               CopyInformation info = record.copyInformationList.get(i);
+                               
+                               Set<Entry<String,String>> set = info.statusInformation.entrySet();
+                               
+                               Iterator<Entry<String, String>> it = set.iterator();
+                               
+                               while(it.hasNext()){
+                                       
+                                       Entry<String,String> ent = it.next();
+                                       TextView statusName = new TextView(getActivity());
+                                       statusName.setText(ent.getKey() + " : " + ent.getValue());
+                                       
+                                       copy_statuses.addView(statusName, new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
+                                       
+                               }
+
+
+                               
+                       }
+                       
+                       
+                       
+                       
                return layout;
            }