From a11a4db335279a31cef25019fd9658e8e39f5d4d Mon Sep 17 00:00:00 2001 From: drizea Date: Wed, 6 Jun 2012 13:25:37 +0300 Subject: [PATCH] Added Checked out Items tab functions --- .../android/accountAccess/AccountAccess.java | 158 +++++++++++++++++++-- 1 file changed, 148 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java index ba0ca39e9f..54192c8315 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AccountAccess.java @@ -3,31 +3,78 @@ package org.evergreen.android.accountAccess; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.opensrf.Method; import org.opensrf.net.http.GatewayRequest; import org.opensrf.net.http.HttpConnection; import org.opensrf.net.http.HttpRequest; +import org.opensrf.util.OSRFObject; /** * The Class AuthenticateUser. */ public class AccountAccess { + //Used for authentication purpose + /** The SERVICE. */ - public static String SERVICE = "open-ils.auth"; - - /** The METHOD Auth init */ + public static String SERVICE_AUTH = "open-ils.auth"; + + /** The METHOD Auth init. */ public static String METHOD_AUTH_INIT = "open-ils.auth.authenticate.init"; - /** The METHOD Auth complete */ + /** The METHOD Auth complete. */ public static String METHOD_AUTH_COMPLETE = "open-ils.auth.authenticate.complete"; - /** The METHOD Auth session retrieve */ + /** The METHOD Auth session retrieve. */ public static String METHOD_AUTH_SESSION_RETRV = "open-ils.auth.session.retrieve"; + // Used for the Checked out Items Tab + + /** The SERVIC e_ actor. */ + public static String SERVICE_ACTOR = "open-ils.actor"; + + /** The SERVIC e_ circ. */ + public static String SERVICE_CIRC = "open-ils.circ"; + + public static String SERVICE_SEARCH = "open-ils.search"; + + /** The METHOD_FETCH_CHECKED_OUT_SUM + * description : for a given user returns a a structure of circulation objects sorted by + * out, overdue, lost, claims_returned, long_overdue; A list of ID's returned for each type : "out":[id1,id2,...] + * @param : authtoken , UserID + * @returns: { "out":[id's],"claims_returned":[],"long_overdue":[],"overdue":[],"lost":[]} + */ + public static String METHOD_FETCH_CHECKED_OUT_SUM = "open-ils.actor.user.checked_out"; + + /** The METHOD_FETCH_NON_CAT_CIRCS + * description : for a given user, returns an id-list of non-cataloged circulations that are considered open for now. + * A circ is open if circ time + circ duration (based on type) is > than now + * @param : authtoken, UserID + * @returns: Array of non-catalogen circ IDs, event or error + */ + public static String METHOD_FETCH_NON_CAT_CIRCS = "open-ils.circ.open_non_cataloged_circulation.user"; + + /** The METHOD_FETCH_CIRC_BY_ID + * description : Retrieves a circ object by ID + * @param : authtoken, circ_id + * @returns : "circ" class + */ + public static String METHOD_FETCH_CIRC_BY_ID = "open-ils.circ.retrieve"; + + /** The METHOD_FETCH_MODS_FROM_COPY + * description : + * @param : target_copy + * @returns : mvr class OSRF Object + */ + public static String METHOD_FETCH_MODS_FROM_COPY = "open-ils.search.biblio.mods_from_copy"; + + public static String METHOD_FETCH_COPY = "open-ils.search.asset.copy.retrieve"; + /** The conn. */ public HttpConnection conn; @@ -42,11 +89,12 @@ public class AccountAccess { * */ private String authToken = null; + /** The auth time. */ private Integer authTime = null; //for demo purpose /** The user name. */ - private String userName = "staff"; + private String userName = "admin"; /** The password. */ private String password = "demo123"; @@ -127,12 +175,12 @@ public class AccountAccess { method.addParam(authToken); //sync request - HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); + HttpRequest req = new GatewayRequest(conn, SERVICE_AUTH, method).send(); Object resp; while ((resp = req.recv()) != null) { System.out.println("Sync Response: " + resp); - + OSRFObject au = (OSRFObject) resp; } } /** @@ -146,7 +194,7 @@ public class AccountAccess { method.addParam(userName); // sync test - HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); + HttpRequest req = new GatewayRequest(conn, SERVICE_AUTH, method).send(); Object resp; String seed = null; @@ -188,7 +236,7 @@ public class AccountAccess { System.out.println("Compelx param " + complexParam); // sync test - HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); + HttpRequest req = new GatewayRequest(conn, SERVICE_AUTH, method).send(); Object resp; @@ -217,5 +265,95 @@ public class AccountAccess { } + public void getItemsCheckedOut(){ + + Method method = new Method(METHOD_FETCH_CHECKED_OUT_SUM); + + method.addParam(authToken); + method.addParam(1); + + //sync request + HttpRequest req = new GatewayRequest(conn, SERVICE_ACTOR, method).send(); + Object resp; + + + ArrayList long_overdue = new ArrayList(); + ArrayList claims_returned = new ArrayList(); + ArrayList lost = new ArrayList(); + ArrayList out = new ArrayList(); + + List long_overdue_id; + List claims_returned_id; + List lost_id; + List out_id; + while ((resp = req.recv()) != null) { + System.out.println("Sync Response: " + resp); + + long_overdue_id = (List)((Map)resp).get("long_overdue"); + claims_returned_id = (List)((Map)resp).get("claims_returned"); + lost_id = (List)((Map)resp).get("lost"); + out_id = (List)((Map)resp).get("out"); + + //get all the record circ info + for(int i=0;i