.settings
bin/
gen/
-kc/
+kcxxx/
out/
proguard_logs/
local.properties
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="?android:attr/spinnerItemStyle"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="left" />
<Spinner
android:id="@+id/chose_organisation"
- android:layout_width="0dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
private ArrayList<BookBag> bookBags = new ArrayList<BookBag>();
/** The TAG. */
- private final String TAG = AccountAccess.class.getSimpleName();
+ private final static String TAG = AccountAccess.class.getSimpleName();
/**
* The auth token. Sent with every request that needs authentication
// ------------------------orgs Section
// --------------------------------------//
- public OSRFObject fetchOrgs() {
- OSRFObject response = (OSRFObject) Utils.doRequest(conn(), SERVICE_ACTOR,
+ // todo: call service=open-ils.actor&method=open-ils.actor.org_types.retrieve
+
+ public OSRFObject fetchOrgTree() {
+ Object response = Utils.doRequest(conn(), SERVICE_ACTOR,
METHOD_ORG_TREE_RETRIEVE, new Object[]{});
- try {
- //List<OSRFObject> l = (List<OSRFObject>) response;
- Log.d(TAG, "response="+response);
- } catch (Exception e) {
- Log.d(TAG, "caught exception", e);
- }
- return response;
+ return (OSRFObject) response;
}
/**
import java.util.Calendar;
import java.util.Date;
-import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.MenuItem;
import org.evergreen_ils.utils.ui.CompatSpinnerAdapter;
import org.evergreen_ils.views.splashscreen.SplashActivity;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.format.DateFormat;
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < globalConfigs.organisations.size(); i++) {
- list.add(globalConfigs.organisations.get(i).padding
+ list.add(globalConfigs.organisations.get(i).displayName
+ globalConfigs.organisations.get(i).name);
if (globalConfigs.organisations.get(i).id == record.pickup_lib)
import java.util.Calendar;
import java.util.Date;
-import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.MenuItem;
import org.evergreen_ils.utils.ui.CompatSpinnerAdapter;
import org.evergreen_ils.views.splashscreen.SplashActivity;
-import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Context;
-import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.format.DateFormat;
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < globalConfigs.organisations.size(); i++) {
Organisation org = globalConfigs.organisations.get(i);
- list.add(org.padding + org.name);
+ list.add(org.displayName + org.name);
if (org.id == homeLibrary) {
selectedOrgPos = i;
}
public static final int PENALTY_INVALID_PATRON_ADDRESS = 29;
public static final int BILLING_TYPE_NOTIFICATION_FEE = 9;
+
+ // todo: fetch from service=open-ils.actor&method=open-ils.actor.org_types.retrieve
+ public static final int ORG_TYPE_CONSORTIUM = 1;
+ public static final int ORG_TYPE_SYSTEM = 2;
+ public static final int ORG_TYPE_BRANCH = 3;
+ public static final int ORG_TYPE_SUB_LIBRARY = 4;
+ public static final int ORG_TYPE_BOOKMOBILE = 5;
}
package org.evergreen_ils.globals;
import android.content.Context;
-import android.net.ConnectivityManager;
-import android.provider.Settings;
+import android.content.pm.ApplicationInfo;
import android.text.TextUtils;
import android.util.Log;
-import org.evergreen_ils.auth.Const;
import org.evergreen_ils.searchCatalog.Organisation;
import org.evergreen_ils.searchCatalog.SearchCatalog;
import org.open_ils.idl.IDLParser;
import org.opensrf.net.http.HttpConnection;
-import org.opensrf.util.JSONException;
-import org.opensrf.util.JSONReader;
+import org.opensrf.util.OSRFObject;
import java.io.InputStream;
import java.net.MalformedURLException;
private static String TAG = "GlobalConfigs";
- private static boolean debugMode = true;//todo get from boolean isDebuggable = ( 0 != ( getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) );
+ private static Boolean isDebuggable = null;
private static boolean loadedIDL = false;
/** The locale. */
public String locale = "en-US";
- private static GlobalConfigs globalConfigSingleton = null;
+ private static GlobalConfigs instance = null;
/** The organisations. */
public ArrayList<Organisation> organisations;
public static GlobalConfigs getGlobalConfigs(Context context) {
Log.d(TAG, "getGlobalConfigs (url="+httpAddress+")");
- if (globalConfigSingleton == null)
- globalConfigSingleton = new GlobalConfigs();
- return globalConfigSingleton;
+ if (instance == null)
+ instance = new GlobalConfigs();
+ if (context != null && isDebuggable == null)
+ isDebuggable = (0 != (context.getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE));
+ return instance;
}
public static GlobalConfigs getGlobalConfigs(Context context, String library_url) {
httpAddress = library_url;
conn = null; // must come before loadXXX()
loadIDL();
- loadOrganizations();
loadCopyStatusesAvailable();
return true;
}
return false;
}
- public static boolean isDebugMode() {
- return debugMode;
+ public static boolean isDebuggable() {
+ if (isDebuggable == null)
+ return false;
+ return isDebuggable;
}
public static HttpConnection gatewayConnection() {
loadedIDL = true;
}
- /**
- * Fetch the OrgTree.js file, and from it parse the list of organisations.
- */
- public void loadOrganizations() {
-
- String orgFile = null;
-
- organisations = new ArrayList<Organisation>();
-
+ public void addOrganization(OSRFObject obj, int level) {
+ Organisation org = new Organisation();
+ org.level = level;
+ org.id = obj.getInt("id");
+ org.name = obj.getString("name");
+ org.shortname = obj.getString("shortname");
+ org.orgType = obj.getInt("ou_type");
+ //if (org.orgType < EvergreenConstants.ORG_TYPE_BRANCH) return;
+ org.displayName = new String(new char[level]).replace("\0", " ");
+ organisations.add(org);
+
+ List<OSRFObject> children = null;
try {
- Log.d(TAG, "getOrg fetching "+httpAddress + collectionsRequest);
- orgFile = Utils.getNetPageContent(httpAddress + collectionsRequest);
+ children = (List<OSRFObject>) obj.get("children");
+ for (OSRFObject child : children) {
+ addOrganization(child, level + 1);
+ }
} catch (Exception e) {
+ Log.d(TAG, "addOrganization caught exception decoding children of "+org.name, e);
}
+ }
- if (orgFile != null) {
- long start_ms = System.currentTimeMillis();
- Log.d(TAG, "getOrg loading");
- organisations = new ArrayList<Organisation>();
-
- // in case of wrong file
- if (orgFile.indexOf("=") == -1)
- return;
- String orgArray = orgFile.substring(orgFile.indexOf("=") + 1,
- orgFile.indexOf(";"));
- Log.d(TAG, "getOrg array=" + orgArray.substring(0, orgArray.length()>50 ? 50 : -1));
-
- // Parse javascript list
- // Format: [[id, ou_type, parent_ou, name, opac_visible, shortname],...]
- // Sample: [[149,3,146,"Agawam",0,"AGAWAM_MA"],
- // [150,4,149,"Agawam Public Library",1,"AGAWAM"],...]
- // ou_type can be treated as hierarchical nesting level
- List orgList;
- try {
- orgList = new JSONReader(orgArray).readArray();
- } catch (JSONException e) {
- Log.d(TAG, "getOrg failed parsing array", e);
- return;
- }
-
- // Convert json list into array of Organisation
- for (int i=0; i<orgList.size(); ++i) {
- Organisation org = new Organisation();
- List orgItem = (List) orgList.get(i);
- org.id= (Integer)orgItem.get(0);
- org.level = (Integer)orgItem.get(1);
- org.parent = (Integer)orgItem.get(2);
- org.name = (String)orgItem.get(3);
- org.isVisible = (Integer)orgItem.get(4);
- org.shortName = (String)orgItem.get(5);
- if (org.isVisible == 0) {
- continue;
- }
-
- organisations.add(org);
- }
-
- /*
- for (int i=0; i<organisations.size(); ++i) {
- Log.d(TAG, "getOrg presort org["+i+"]= id:"+organisations.get(i).id+" parent:"+organisations.get(i).parent+" name:"+organisations.get(i).name);
- }
- */
- Collections.sort(organisations, new Comparator<Organisation>() {
- @Override
- public int compare(Organisation a, Organisation b) {
- if (a.parent == null)
- return -1; // root is always first
- return a.name.compareTo(b.name);
- }
- });
-
- long duration_ms = System.currentTimeMillis() - start_ms;
- Log.d(TAG, "getOrg took "+duration_ms+"ms");
- loadedOrgTree = true;
- }
+ public void loadOrganizations(OSRFObject orgTree) {
+ organisations = new ArrayList<Organisation>();
+ addOrganization(orgTree, 0);
}
public void loadCopyStatusesAvailable() {
*/
package org.evergreen_ils.globals;
-import java.io.BufferedInputStream;
import java.io.BufferedReader;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
import java.util.Map;
import android.os.Looper;
import org.opensrf.net.http.HttpConnection;
import org.opensrf.net.http.HttpRequest;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.ConnectivityManager;
import android.util.Log;
-import android.widget.ImageView;
public class Utils {
private static final String TAG = "osrf";
// 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 from service "+service+" method "+methodName, e);
- if (GlobalConfigs.isDebugMode()) {
+ if (GlobalConfigs.isDebuggable()) {
throw(e);
}
}
*/
package org.evergreen_ils.searchCatalog;
-public class Organisation {
-
- public String name = null;
+import org.evergreen_ils.barcodescan.Intents;
- public String shortName = null;
-
- public Integer id = null;
+public class Organisation {
public Integer level = null;
+ public Integer id = null;
+ public String name = null;
+ public String shortname = null;
+ public Integer orgType = null;
+ public String displayName = "";
- public Integer parent = null;
-
- public Integer isVisible = null;
-
- public Integer hiddenDepth = null;
-
- // used for indent display
- public String padding = "";
+ public Boolean opac_visible = null;
public Organisation() {
-
}
}
private static final long serialVersionUID = 10123L;
- private final String TAG = RecordInfo.class.getName();
+ private static final String TAG = RecordInfo.class.getSimpleName();
public String title = null;
-
public String author = null;
-
public String pubdate = null;
-
public String isbn = null;
-
public Integer doc_id = null;
-
public String publisher = null;
-
public String subject = null;
-
public String doc_type = null;
-
public String online_loc = null;
-
public String synopsis = null;
-
public String physical_description = null;
-
public String series = null;
-
- // tcn field
- public String image = null;
-
public boolean dummy = false;
public ArrayList<CopyCountInformation> copyCountListInfo = null;
this.pubdate = safeString(info.getString("pubdate"));
this.publisher = safeString(info.getString("publisher"));
this.doc_id = info.getInt("doc_id");
- this.image = safeString(info.getString("tcn"));
- Log.d(TAG, "image=" + image);
this.doc_type = safeString(info.getString("doc_type"));
} catch (Exception e) {
Log.d(TAG, "Exception basic info " + e.getMessage());
public String TAG = SearchCatalog.class.getSimpleName();
- // the org on witch the searches will be made
- /** The selected organization. */
+ // the org on which the searches will be made
public Organisation selectedOrganization = null;
public Integer offset;
complexParm.put("org_unit", this.selectedOrganization.id);
if (this.selectedOrganization.level != null)
complexParm.put("depth", this.selectedOrganization.level - 1);
-// if (!this.searchFormat.isEmpty())
-// complexParm.put("format", this.searchFormat);
}
complexParm.put("limit", searchLimit);
complexParm.put("offset", offset);
if (searchClass != null) complexParm.put("default_class", searchClass);
- /*
- * complexParm.put("offset",0);
- * complexParm.put("visibility_limit", 3000);
- */
+// complexParm.put("offset",0);
+// complexParm.put("visibility_limit", 3000);
} catch (Exception e) {
Log.d(TAG, "Exception in JSON " + e.getMessage());
}
for (int i = 0; i < result_ids.size(); i++) {
ids.add(result_ids.get(i).get(0));
}
-
Log.d(TAG, "Ids " + ids);
// request other info based on ids
-
for (int i = 0; i < ids.size(); i++) {
Integer record_id = Integer.parseInt(ids.get(i));
import java.util.*;
-import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.*;
import org.evergreen_ils.R;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
-import android.net.ConnectivityManager;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu.ContextMenuInfo;
searchResults = search.getSearchResults(text, getSearchClass(), getSearchFormat(), 0);
runOnUiThread(new Runnable() {
-
@Override
public void run() {
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < globalConfigs.organisations.size(); i++) {
Organisation org = globalConfigs.organisations.get(i);
- list.add(org.padding + org.name);
+ list.add(org.displayName + org.name);
if (org.id == homeLibrary) {
selectedOrgPos = i;
}
}
- ArrayAdapter<String> adapter = CompatSpinnerAdapter.CreateCompatSpinnerAdapter(this, list);
+ //ArrayAdapter<String> adapter = CompatSpinnerAdapter.CreateCompatSpinnerAdapter(this, list);
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.org_item_layout, list);
choseOrganisation = (Spinner) findViewById(R.id.chose_organisation);
choseOrganisation.setAdapter(adapter);
choseOrganisation.setSelection(selectedOrgPos);
import org.evergreen_ils.searchCatalog.Library;
import org.opensrf.util.OSRFObject;
+import java.util.Map;
+
/** This is basically the same as an AsyncTask<String,String,String>, except that it uses
* a Thread. Starting with HONEYCOMB, tasks are executed on a single thread and the 2nd
* AsyncTask doesn't start until the first finishes.
Log.d(TAG, tag+"Loading resources from "+library.url);
publishProgress("Loading resources");
- GlobalConfigs.getGlobalConfigs(mCallingActivity, library.url);
-
AccountAccess ac = AccountAccess.getAccountAccess();
+ GlobalConfigs gc = GlobalConfigs.getGlobalConfigs(mCallingActivity, library.url);
- /* way to fetch org tree using OSRF rather than parsing JS
- try {
- OSRFObject o = ac.fetchOrgs();
- } catch (Exception e) {
- Log.d(TAG, tag+"caught exception", e);
- }
- */
+ /* fetch org tree using OSRF rather than parsing JS */
+ gc.loadOrganizations(ac.fetchOrgTree());
// auth token zen: try once and if it fails, invalidate the token and try again
Log.d(TAG, tag+"Starting session");