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)
--- /dev/null
+<?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
</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>
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;
loadIDLFile();
getOrganisations();
+ getCopyStatusesAvailable((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE));
+
AccountAccess.setAccountInfo(preferences.getString("username", ""), preferences.getString("password", ""));
}
}
+ 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
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()));
+ }
+ }
}
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;
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");
public Fragment getItem(int position) {
// position +1 for 1 - size values
return BasicDetailsFragment.newInstance(records.get(position),position+1,records.size());
-
-
}
@Override
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;
import org.opensrf.net.http.HttpRequestHandler;
import org.opensrf.util.OSRFObject;
-import android.content.Context;
import android.net.ConnectivityManager;
import android.util.Log;
*/
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";
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);
}
}
+ 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});
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{
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;
}