From: drizea Date: Mon, 4 Jun 2012 13:53:56 +0000 (+0300) Subject: first commit to Android project X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4010920b25ad241bd2ac32e69c37b2d73e5089fd;p=working%2FEvergreen.git first commit to Android project --- diff --git a/Open-ILS/src/Android/AndroidManifest.xml b/Open-ILS/src/Android/AndroidManifest.xml new file mode 100644 index 0000000000..8db0af68f6 --- /dev/null +++ b/Open-ILS/src/Android/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/assets/fm_IDL.xml b/Open-ILS/src/Android/assets/fm_IDL.xml new file mode 100644 index 0000000000..88b1b71310 --- /dev/null +++ b/Open-ILS/src/Android/assets/fm_IDL.xml @@ -0,0 +1,9996 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT * FROM metabib.author_field_entry + UNION ALL + SELECT * FROM metabib.keyword_field_entry + UNION ALL + SELECT * FROM metabib.identifier_field_entry + UNION ALL + SELECT * FROM metabib.title_field_entry + UNION ALL + SELECT * FROM metabib.subject_field_entry + UNION ALL + SELECT * FROM metabib.series_field_entry + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +SELECT usr, + SUM( + CASE + WHEN ( + ((fine_interval >= '1 day' AND due_date >= 'today') OR (fine_interval < '1 day' AND due_date > 'now')) + AND (stop_fines IS NULL OR stop_fines NOT IN ('LOST','CLAIMSRETURNED','LONGOVERDUE')) + ) THEN 1 + ELSE 0 + END + ) AS out, + + SUM( + CASE + WHEN ( + ((fine_interval >= '1 day' AND due_date < 'today') OR (fine_interval < '1 day' AND due_date < 'now')) + AND (stop_fines IS NULL OR stop_fines NOT IN ('LOST','CLAIMSRETURNED','LONGOVERDUE')) + ) THEN 1 + ELSE 0 + END + ) AS overdue, + + SUM( CASE WHEN (xact_finish IS NULL AND stop_fines = 'LOST') THEN 1 ELSE 0 END) AS lost, + SUM( CASE WHEN (xact_finish IS NULL AND stop_fines = 'CLAIMSRETURNED') THEN 1 ELSE 0 END) AS claims_returned, + SUM( CASE WHEN (xact_finish IS NULL AND stop_fines = 'LONGOVERDUE') THEN 1 ELSE 0 END) AS long_overdue + FROM action.circulation + WHERE checkin_time IS NULL + GROUP BY 1 + + + + + + + + + + + + + + + +SELECT usr, + ARRAY_TO_STRING(ARRAY_ACCUM( + CASE + WHEN ( + ((fine_interval >= '1 day' AND due_date >= 'today') OR (fine_interval < '1 day' AND due_date > 'now')) + AND (stop_fines IS NULL OR stop_fines NOT IN ('LOST','CLAIMSRETURNED','LONGOVERDUE')) + ) THEN id + ELSE 0 + END + ),',') AS out, + + ARRAY_TO_STRING(ARRAY_ACCUM( + CASE + WHEN ( + ((fine_interval >= '1 day' AND due_date < 'today') OR (fine_interval < '1 day' AND due_date < 'now')) + AND (stop_fines IS NULL OR stop_fines NOT IN ('LOST','CLAIMSRETURNED','LONGOVERDUE')) + ) THEN id + ELSE 0 + END + ),',') AS overdue, + + ARRAY_TO_STRING(ARRAY_ACCUM( CASE WHEN (xact_finish IS NULL AND stop_fines = 'LOST') THEN id ELSE 0 END),',') AS lost, + ARRAY_TO_STRING(ARRAY_ACCUM( CASE WHEN (xact_finish IS NULL AND stop_fines = 'CLAIMSRETURNED') THEN id ELSE 0 END),',') AS claims_returned, + ARRAY_TO_STRING(ARRAY_ACCUM( CASE WHEN (xact_finish IS NULL AND stop_fines = 'LONGOVERDUE') THEN id ELSE 0 END),',') AS long_overdue + FROM action.circulation + WHERE checkin_time IS NULL + GROUP BY 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ahr.requestor) AS is_staff_hold + FROM action.hold_request ahr + JOIN asset.copy acp ON (acp.id = ahr.current_copy) + JOIN asset.call_number acn ON (acp.call_number = acn.id) + JOIN asset.call_number_prefix acnp ON (acn.prefix = acnp.id) + JOIN asset.call_number_suffix acns ON (acn.suffix = acns.id) + JOIN actor.usr au ON (au.id = ahr.usr) + LEFT JOIN serial.issuance siss + ON (ahr.hold_type = 'I' AND siss.id = ahr.target) + LEFT JOIN asset.copy_location_order acplo + ON (acp.location = acplo.location AND + acp.circ_lib = acplo.org) + WHERE + ahr.capture_time IS NULL AND + ahr.cancel_time IS NULL AND + (ahr.expire_time is NULL OR ahr.expire_time > NOW()) + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT ahr.* FROM action.hold_request ahr JOIN (SELECT current_copy, MAX(capture_time) AS capture_time FROM action.hold_request WHERE capture_time IS NOT NULL GROUP BY current_copy)x USING (current_copy, capture_time) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT DISTINCT l.* + FROM action.unfulfilled_hold_loops l + JOIN action.unfulfilled_hold_max_loop m USING (hold) + WHERE l.count = m.max + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT b.id, + MAX(dcp.edit_date) AS last_delete_date + FROM biblio.record_entry b + JOIN asset.call_number cn ON (cn.record = b.id) + JOIN asset.copy dcp ON (cn.id = dcp.call_number) + WHERE NOT b.deleted + GROUP BY b.id + HAVING SUM( CASE WHEN NOT dcp.deleted THEN 1 ELSE 0 END) = 0 + + + + + + + + + + + + + + + + + + + + -- -- If we uncomment the RIGHT JOIN against biblio.record_entry, then we'll get a row for every non-deleted bib, whether it has active holds or not. + -- -- If we expect to use pcrud to query against specific bibs, we probably want to do this. However, if we're using this to populate a report, we + -- -- may not. + -- SELECT + -- bre.id AS "bib_id", + -- COALESCE( z.copy_count, 0 ) AS "copy_count", + -- COALESCE( z.hold_count, 0 ) AS "hold_count", + -- COALESCE( z.copy_hold_ratio, 0 ) AS "hold_copy_ratio" + -- FROM ( + SELECT + y.bre AS "id", + COALESCE( x.copy_count, 0 ) AS "copy_count", + y.hold_count AS "hold_count", + (y.hold_count::REAL / (CASE WHEN x.copy_count = 0 OR x.copy_count IS NULL THEN 0.1 ELSE x.copy_count::REAL END)) AS "hold_copy_ratio" + FROM ( + SELECT + (SELECT bib_record FROM reporter.hold_request_record r WHERE r.id = h.id LIMIT 1) AS "bre", + COUNT(*) AS "hold_count" + FROM action.hold_request h + WHERE + cancel_time IS NULL + AND fulfillment_time IS NULL + -- AND NOT frozen -- a frozen hold is still a desired hold, eh? + GROUP BY 1 + )y LEFT JOIN ( + SELECT + (SELECT id + FROM biblio.record_entry + WHERE id = (SELECT record FROM asset.call_number WHERE id = call_number) + ) AS "bre", + COUNT(*) AS "copy_count" + FROM asset.copy + JOIN asset.copy_location loc ON (copy.location = loc.id AND loc.holdable) + WHERE copy.holdable + AND NOT copy.deleted + AND copy.status IN ( SELECT id FROM config.copy_status WHERE holdable ) + GROUP BY 1 + )x ON x.bre = y.bre + -- )z RIGHT JOIN ( + -- SELECT id + -- FROM biblio.record_entry + -- WHERE NOT deleted + -- )bre ON (z.bib_id = bre.id) + + + + + + + + + + + + + + + + + + + + + + SELECT *, + CASE WHEN copy_count_at_pickup_library = 0 THEN 'Infinity'::FLOAT ELSE holds_at_pickup_library::FLOAT/copy_count_at_pickup_library END AS pickup_library_ratio, + CASE WHEN copy_count_everywhere = 0 THEN 'Infinity'::FLOAT ELSE holds_everywhere::FLOAT/copy_count_everywhere END AS everywhere_ratio + FROM + (SELECT bib_record as id, pickup_lib, count(DISTINCT ahr.id) AS holds_at_pickup_library, COALESCE(count(DISTINCT ac.id),0) as copy_count_at_pickup_library + FROM + action.hold_request ahr + JOIN reporter.hold_request_record rhrr USING (id) + LEFT JOIN action.hold_copy_map ahcm ON (ahr.id = ahcm.hold) + LEFT JOIN asset.copy ac ON (ahcm.target_copy = ac.id AND ahr.pickup_lib = ac.circ_lib) + WHERE + ahr.cancel_time IS NULL + AND ahr.fulfillment_time IS NULL + GROUP BY bib_record, pickup_lib + )x + JOIN + (SELECT bib_record as id, count(DISTINCT ahr.id) AS holds_everywhere, COALESCE(count(DISTINCT target_copy),0) as copy_count_everywhere + FROM + action.hold_request ahr + JOIN reporter.hold_request_record rhrr USING (id) + LEFT JOIN action.hold_copy_map ahcm ON (ahr.id = ahcm.hold) + WHERE + ahr.cancel_time IS NULL + AND ahr.fulfillment_time IS NULL + GROUP BY bib_record + )y + USING (id) + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + ac.id, + COALESCE(MAX(actac.xact_start), ac.create_date) AS last_circ_or_create, + MAX(actac.xact_start) AS last_circ + FROM asset.copy ac + LEFT JOIN action.all_circulation actac ON ac.id = actac.target_copy + GROUP BY ac.id + + -- Alternate version, say if you have migrated last checkout information in extend_reporter.legacy_circ_timestamp: + --SELECT + -- ac.id, + -- GREATEST(MAX(actac.xact_start), erlct.last_cko_ts, ac.create_date) AS last_circ_or_create, + -- GREATEST(MAX(actac.xact_start), erlct.last_cko_ts) AS last_circ + --FROM asset.copy ac + -- LEFT JOIN action.all_circulation actac ON ac.id = actac.target_copy + -- LEFT JOIN extend_reporter.legacy_circ_timestamp erlct ON ac.id = erlct.id + --GROUP BY ac.id, ac.create_date, erlct.last_cko_ts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + po.ordering_agency AS ordering_agency, + po.id AS purchase_order, + li.id AS lineitem, + lid.id AS lineitem_detail, + cpa.id AS claim_policy_action + FROM + acq.lineitem_detail lid + JOIN acq.lineitem li ON (li.id = lid.lineitem) + JOIN acq.purchase_order po ON (po.id = li.purchase_order) + JOIN acq.claim_policy cp ON (li.claim_policy = cp.id) + JOIN acq.claim_policy_action cpa ON ( + cpa.claim_policy = cp.id + + -- we only care about claim policy actions whose claim + -- interval we'd reached or exceeded + AND (NOW() - cpa.action_interval) > po.order_date + + -- filter out all claim policy actions where claim events + -- have occurred on or after the action's action_interval + AND NOT EXISTS ( + SELECT 1 + FROM + acq.claim_event evt + JOIN acq.claim claim ON ( + claim.id = evt.claim + AND claim.lineitem_detail = lid.id + ) + WHERE + evt.event_date >= (po.order_date + cpa.action_interval) + ) + ) + WHERE + lid.cancel_reason IS NULL + AND li.cancel_reason IS NULL -- belt/suspenders + AND po.cancel_reason IS NULL -- belt/suspenders + AND lid.recv_time IS NULL + AND po.state = 'on-order' + ORDER BY 1, 2, 3, 4, 5 + + + + + + + + + + + + + + + + + + + + + + SELECT + li.id AS lineitem, + ( + SELECT COUNT(lid.id) + FROM acq.lineitem_detail lid + WHERE lineitem = li.id + ) AS item_count, + ( + SELECT COUNT(lid.id) + FROM acq.lineitem_detail lid + WHERE recv_time IS NOT NULL AND lineitem = li.id + ) AS recv_count, + ( + SELECT COUNT(lid.id) + FROM acq.lineitem_detail lid + WHERE cancel_reason IS NOT NULL AND lineitem = li.id + ) AS cancel_count, + ( + SELECT COUNT(lid.id) + FROM acq.lineitem_detail lid + JOIN acq.fund_debit debit ON (lid.fund_debit = debit.id) + WHERE NOT debit.encumbrance AND lineitem = li.id + ) AS invoice_count, + ( + SELECT COUNT(DISTINCT(lid.id)) + FROM acq.lineitem_detail lid + JOIN acq.claim claim ON (claim.lineitem_detail = lid.id) + WHERE lineitem = li.id + ) AS claim_count, + ( + SELECT (COUNT(lid.id) * li.estimated_unit_price)::NUMERIC(8,2) + FROM acq.lineitem_detail lid + WHERE lid.cancel_reason IS NULL AND lineitem = li.id + ) AS estimated_amount, + ( + SELECT SUM(debit.amount)::NUMERIC(8,2) + FROM acq.lineitem_detail lid + JOIN acq.fund_debit debit ON (lid.fund_debit = debit.id) + WHERE debit.encumbrance AND lineitem = li.id + ) AS encumbrance_amount, + ( + SELECT SUM(debit.amount)::NUMERIC(8,2) + FROM acq.lineitem_detail lid + JOIN acq.fund_debit debit ON (lid.fund_debit = debit.id) + WHERE NOT debit.encumbrance AND lineitem = li.id + ) AS paid_amount + + FROM acq.lineitem AS li + + + + + + + + + + + + + + + + + + + + + + SELECT t.* + FROM action.transit_copy t + JOIN actor.org_unit AS s ON (t.source = s.id) + JOIN actor.org_unit AS d ON (t.dest = d.id) + WHERE s.parent_ou <> d.parent_ou + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT copy, SUM(count) AS count, year, is_renewal FROM ( + SELECT + cp.id as copy, + COUNT(circ.id), + EXTRACT(YEAR FROM circ.xact_start) AS year, + (phone_renewal OR desk_renewal OR opac_renewal) as is_renewal + FROM + asset.copy cp + JOIN action.circulation circ ON (cp.id = circ.target_copy) + GROUP BY 1, 3, 4 + UNION + SELECT + cp.id as copy, + COUNT(circ.id), + EXTRACT(YEAR FROM circ.xact_start) AS year, + (phone_renewal OR desk_renewal OR opac_renewal) as is_renewal + FROM + asset.copy cp + JOIN action.aged_circulation circ ON (cp.id = circ.target_copy) + GROUP BY 1, 3, 4 + UNION + SELECT + id as copy, + circ_count, + -1 AS year, + false as is_renewal + FROM + extend_reporter.legacy_circ_count + )x GROUP BY 1, 3, 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/Android/lib/org.openils_ild.jar b/Open-ILS/src/Android/lib/org.openils_ild.jar new file mode 100644 index 0000000000..af2ba362bd Binary files /dev/null and b/Open-ILS/src/Android/lib/org.openils_ild.jar differ diff --git a/Open-ILS/src/Android/lib/org.opensrf.jar b/Open-ILS/src/Android/lib/org.opensrf.jar new file mode 100644 index 0000000000..f4a50234a1 Binary files /dev/null and b/Open-ILS/src/Android/lib/org.opensrf.jar differ diff --git a/Open-ILS/src/Android/lib/simple-xml-2.6.4.jar b/Open-ILS/src/Android/lib/simple-xml-2.6.4.jar new file mode 100644 index 0000000000..be60eaeaa6 Binary files /dev/null and b/Open-ILS/src/Android/lib/simple-xml-2.6.4.jar differ diff --git a/Open-ILS/src/Android/proguard.cfg b/Open-ILS/src/Android/proguard.cfg new file mode 100644 index 0000000000..b1cdf17b5b --- /dev/null +++ b/Open-ILS/src/Android/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/Open-ILS/src/Android/project.properties b/Open-ILS/src/Android/project.properties new file mode 100644 index 0000000000..b00386b133 --- /dev/null +++ b/Open-ILS/src/Android/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=Google Inc.:Google APIs:8 diff --git a/Open-ILS/src/Android/res/drawable-hdpi/action_search.png b/Open-ILS/src/Android/res/drawable-hdpi/action_search.png new file mode 100644 index 0000000000..f12e005ebe Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-hdpi/action_search.png differ diff --git a/Open-ILS/src/Android/res/drawable-hdpi/address_book.png b/Open-ILS/src/Android/res/drawable-hdpi/address_book.png new file mode 100644 index 0000000000..427b05e977 Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-hdpi/address_book.png differ diff --git a/Open-ILS/src/Android/res/drawable-hdpi/ic_launcher.png b/Open-ILS/src/Android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000000..8074c4c571 Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-hdpi/ic_launcher.png differ diff --git a/Open-ILS/src/Android/res/drawable-ldpi/address_book.png b/Open-ILS/src/Android/res/drawable-ldpi/address_book.png new file mode 100644 index 0000000000..cba08b1a4e Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-ldpi/address_book.png differ diff --git a/Open-ILS/src/Android/res/drawable-ldpi/ic_launcher.png b/Open-ILS/src/Android/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000000..1095584ec2 Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-ldpi/ic_launcher.png differ diff --git a/Open-ILS/src/Android/res/drawable-mdpi/address_book.png b/Open-ILS/src/Android/res/drawable-mdpi/address_book.png new file mode 100644 index 0000000000..10d7e22868 Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-mdpi/address_book.png differ diff --git a/Open-ILS/src/Android/res/drawable-mdpi/ic_launcher.png b/Open-ILS/src/Android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000000..a07c69fa5a Binary files /dev/null and b/Open-ILS/src/Android/res/drawable-mdpi/ic_launcher.png differ diff --git a/Open-ILS/src/Android/res/layout/main.xml b/Open-ILS/src/Android/res/layout/main.xml new file mode 100644 index 0000000000..bc12cd8231 --- /dev/null +++ b/Open-ILS/src/Android/res/layout/main.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/layout/record_details_info.xml b/Open-ILS/src/Android/res/layout/record_details_info.xml new file mode 100644 index 0000000000..a806b6b412 --- /dev/null +++ b/Open-ILS/src/Android/res/layout/record_details_info.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/layout/record_details_simple.xml b/Open-ILS/src/Android/res/layout/record_details_simple.xml new file mode 100644 index 0000000000..71f6c937b2 --- /dev/null +++ b/Open-ILS/src/Android/res/layout/record_details_simple.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/layout/search_result_item.xml b/Open-ILS/src/Android/res/layout/search_result_item.xml new file mode 100644 index 0000000000..ea8ffbb2ea --- /dev/null +++ b/Open-ILS/src/Android/res/layout/search_result_item.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/layout/search_result_list.xml b/Open-ILS/src/Android/res/layout/search_result_list.xml new file mode 100644 index 0000000000..2c1e7599bd --- /dev/null +++ b/Open-ILS/src/Android/res/layout/search_result_list.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/values/colors.xml b/Open-ILS/src/Android/res/values/colors.xml new file mode 100644 index 0000000000..5f326a2352 --- /dev/null +++ b/Open-ILS/src/Android/res/values/colors.xml @@ -0,0 +1,36 @@ + + + + #ff355689 + #ffffffff + #ff000000 + #ff355689 + #ff7081a3 + #ffffffff + #ffd5ddeb + #ffe3e8f1 + #40ffffff + + + + #99cc00 + + #31b6e7 + #cecbce + + #ffffff + diff --git a/Open-ILS/src/Android/res/values/strings.xml b/Open-ILS/src/Android/res/values/strings.xml new file mode 100644 index 0000000000..6fa08137a9 --- /dev/null +++ b/Open-ILS/src/Android/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + Hello World, EvergreenAppActivity! + EvergreenApp + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/values/styles.xml b/Open-ILS/src/Android/res/values/styles.xml new file mode 100644 index 0000000000..4ea885f813 --- /dev/null +++ b/Open-ILS/src/Android/res/values/styles.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AuthenticateUser.java b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AuthenticateUser.java new file mode 100644 index 0000000000..8ec8804e4f --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/accountAccess/AuthenticateUser.java @@ -0,0 +1,188 @@ + +package org.evergreen.android.accountAccess; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +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; + +/** + * The Class AuthenticateUser. + */ +public class AuthenticateUser { + + /** The SERVICE. */ + public static String SERVICE = "open-ils.auth"; + + /** The METHO d_ multicas s_ search. */ + public static String METHOD_AUTH_INIT = "open-ils.auth.authenticate.init"; + + /** The METHO d_ sli m_ retrive. */ + public static String METHOD_AUTH_COMPLETE = "open-ils.auth.authenticate.complete"; + + /** The conn. */ + public HttpConnection conn; + + /** The http address. */ + public String httpAddress = "http://ulysses.calvin.edu"; + + /** The TAG. */ + public String TAG = "AuthenticareUser"; + + /** The auth token. + * Sent with every request that needs authentication + * */ + private String authToken = null; + + //for demo purpose + /** The user name. */ + private String userName = "staff"; + + /** The password. */ + private String password = "demo123"; + + /** + * Instantiates a new authenticate user. + * + * @param httpAddress the http address + */ + public AuthenticateUser(String httpAddress) { + + this.httpAddress = httpAddress; + + try { + // configure the connection + + System.out.println("Connection with " + httpAddress); + conn = new HttpConnection(httpAddress + "/osrf-gateway-v1"); + + } catch (Exception e) { + System.err.println("Exception in establishing connection " + + e.getMessage()); + } + + // OSRFRegistry.registerObject("mvr", WireProtocol.ARRAY, new String[] + // {"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"}); + + } + + /** + * Md5. + * + * @param s the s + * @return the string + */ + public String md5(String s) { + try { + // Create MD5 Hash + MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); + digest.update(s.getBytes()); + byte messageDigest[] = digest.digest(); + + // Create Hex String + StringBuffer hexString = new StringBuffer(); + for (int i=0; i complexParam = new HashMap(); + + + complexParam.put("username", userName); + complexParam.put("password", hash+"'"); + + + method.addParam(complexParam); + System.out.println("Compelx param " + complexParam); + + // sync test + HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); + Object resp; + + + while ((resp = req.recv()) != null) { + System.out.println("Sync Response: " + resp); + + String queryResult = ((Map) resp).get("desc"); + + System.out.println("Result " + queryResult); + + if(queryResult.equals("Success")){ + authToken = ((Map) resp).get("authtoken"); + } + } + + + } + +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java new file mode 100644 index 0000000000..f5ab2bc84c --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java @@ -0,0 +1,6 @@ +package org.evergreen.android.globals; + +public class GlobalConfigs { + + //public static String httpAddress = "http://ulysses.calvin.edu"; +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java new file mode 100644 index 0000000000..fd8caf73af --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java @@ -0,0 +1,5 @@ +package org.evergreen.android.globals; + +public class Utils { + +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/Organisation.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/Organisation.java new file mode 100644 index 0000000000..1dd804792c --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/Organisation.java @@ -0,0 +1,20 @@ +package org.evergreen.android.searchCatalog; + +public class Organisation { + + public String name = null; + + public String shortName = null; + + public Integer id = null; + + public Integer level = null; + + public Integer parent = null; + + public Integer canHaveVolumesBool = null; + + public Organisation(){ + + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails.java new file mode 100644 index 0000000000..a1eb4b9a7a --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails.java @@ -0,0 +1,47 @@ +package org.evergreen.android.searchCatalog; + +import android.app.TabActivity; +import android.content.Intent; +import android.os.Bundle; +import android.widget.TabHost; +import android.widget.TabHost.TabSpec; + +public class RecordDetails extends TabActivity{ + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + TabHost tabHost = getTabHost(); + + + RecordInfo record = (RecordInfo) getIntent().getSerializableExtra("recordInfo"); + + // Tab for Photos + TabSpec photospec = tabHost.newTabSpec("Info"); + // setting Title and Icon for the Tab + photospec.setIndicator("Info"); + Intent photosIntent = new Intent(this, RecordDetails_Info.class); + photospec.setContent(photosIntent); + photosIntent.putExtra("recordInfo", record); + + // Tab for Songs + TabSpec songspec = tabHost.newTabSpec("Content"); + songspec.setIndicator("Content"); + Intent songsIntent = new Intent(this, RecordDetails_Content.class); + songspec.setContent(songsIntent); + songsIntent.putExtra("recordInfo", record); + // Tab for Videos + TabSpec videospec = tabHost.newTabSpec("Other"); + videospec.setIndicator("Other"); + Intent videosIntent = new Intent(this, RecordDetails_Details.class); + videospec.setContent(videosIntent); + videosIntent.putExtra("recordInfo",record); + + // Adding all TabSpec to TabHost + tabHost.addTab(photospec); // Adding photos tab + tabHost.addTab(songspec); // Adding songs tab + tabHost.addTab(videospec); // Adding videos tab + + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Content.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Content.java new file mode 100644 index 0000000000..c03b957726 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Content.java @@ -0,0 +1,13 @@ +package org.evergreen.android.searchCatalog; + +import android.app.Activity; +import android.os.Bundle; + +public class RecordDetails_Content extends Activity{ + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Details.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Details.java new file mode 100644 index 0000000000..7c48d11935 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Details.java @@ -0,0 +1,13 @@ +package org.evergreen.android.searchCatalog; + +import android.app.Activity; +import android.os.Bundle; + +public class RecordDetails_Details extends Activity{ + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Info.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Info.java new file mode 100644 index 0000000000..a7543e7561 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Info.java @@ -0,0 +1,40 @@ +package org.evergreen.android.searchCatalog; + +import java.security.PublicKey; + +import org.evergreen.android.R; +import org.evergreen.android.R.id; +import org.evergreen.android.R.layout; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +public class RecordDetails_Info extends Activity{ + + + private TextView titleTextView; + + private TextView authorTextView; + + private TextView publisherTextView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + setContentView(R.layout.record_details_info); + + RecordInfo record = (RecordInfo)getIntent().getSerializableExtra("recordInfo"); + + titleTextView = (TextView) findViewById(R.id.record_details_info_title); + authorTextView = (TextView) findViewById(R.id.record_details_info_author); + publisherTextView = (TextView) findViewById(R.id.record_details_info_publisher); + + + titleTextView.setText(record.title); + authorTextView.setText(record.author); + publisherTextView.setText(record.publisher); + + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Simple.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Simple.java new file mode 100644 index 0000000000..9b7098c9c1 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordDetails_Simple.java @@ -0,0 +1,50 @@ +package org.evergreen.android.searchCatalog; + +import org.evergreen.android.R; +import org.evergreen.android.R.id; +import org.evergreen.android.R.layout; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +public class RecordDetails_Simple extends Activity { + + + private TextView titleTextView; + private TextView authorTextView; + private TextView publisherTextView; + private TextView seriesTextView; + private TextView subjectTextView; + private TextView synopsisTextView; + private TextView isbnTextView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.record_details_simple); + + titleTextView = (TextView) findViewById(R.id.record_details_simple_title); + authorTextView = (TextView) findViewById(R.id.record_details_simple_author); + publisherTextView = (TextView) findViewById(R.id.record_details_simple_publisher); + + seriesTextView = (TextView) findViewById(R.id.record_details_simple_series); + subjectTextView = (TextView) findViewById(R.id.record_details_simple_subject); + synopsisTextView = (TextView) findViewById(R.id.record_details_simple_synopsis); + + isbnTextView = (TextView) findViewById(R.id.record_details_simple_isbn); + + RecordInfo record = (RecordInfo) getIntent().getSerializableExtra("recordInfo"); + + titleTextView.setText(record.title); + authorTextView.setText(record.author); + publisherTextView.setText(record.pubdate + " " + record.publisher); + + seriesTextView.setText(record.series); + subjectTextView.setText(record.subject); + synopsisTextView.setText(record.synopsis); + + isbnTextView.setText(record.isbn); + + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java new file mode 100644 index 0000000000..1384646181 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java @@ -0,0 +1,104 @@ +package org.evergreen.android.searchCatalog; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +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; + + 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 online_loc = null; + + public String synopsis = null; + + public String physical_description = null; + + public String series = null; + + public RecordInfo(Map info){ + + try{ + + this.title = (String)info.get("title"); + this.author = (String)info.get("author"); + this.pubdate = (String)info.get("pubdate"); + this.publisher = (String)info.get("publisher"); + this.doc_id = (Integer)info.get("doc_id"); + + } + catch(Exception e){System.out.println("Exception basic info " + e.getMessage());}; + + try{ + this.isbn = (String)info.get("isbn"); + }catch(Exception e){ + System.out.println("Exception isbn " + e.getMessage()); + }; + + try{ + + Map subjectMap = (Map) info.get("subject"); + + this.subject = ""; + + int no = subjectMap.entrySet().size(); + int i=0; + for(Entry entry : subjectMap.entrySet()){ + i++; + if(i seriesList = (List) info.get("series"); + for(int i=0;i organisations; + + //the org on witch the searches will be made + /** The selected organization. */ + private Organisation selectedOrganization = null; + + private Context context; + /** + * Instantiates a new search catalog. + * + * @param httpAddress the http address + * @param locale the locale + */ + public SearchCatalog(String httpAddress, String locale, Context context) { + super(); + this.context = context; + this.httpAddress = httpAddress; + try{ + // configure the connection + conn = new HttpConnection(httpAddress+"/osrf-gateway-v1"); + this.locale = locale; + collectionsRequest += locale + "/OrgTree.js"; + + }catch(Exception e){ + System.err.println("Exception in establishing connection " + e.getMessage()); + } + //registering classes so no longer necessary to register object classes manually + readIDLFile(); + + this.organisations = new ArrayList(); + getOrganisations(); + } + + + /** + * Gets the organisations get's OrgTree.js from server, parses the input and recovers the organisations + * + * @return the organisations + */ + private void getOrganisations(){ + + String orgFile = null; + try{ + orgFile = getNetPageContent(httpAddress+collectionsRequest); + System.out.println("Request org " + httpAddress + collectionsRequest ); + }catch(Exception e){}; + + + if(orgFile != null){ + System.out.println("Page content " + orgFile); + + String orgArray = orgFile.substring( orgFile.indexOf("=")+1, orgFile.indexOf(";")); + + String arrayContent = orgArray.substring(orgArray.indexOf("[")+1,orgArray.lastIndexOf("]")); + + + Log.d(TAG,"Array to pe parsed " + arrayContent); + + //parser for list + + //format [104,2,1,"Curriculum Center",1,"CURRICULUM"] : [id,level,parent,name,can_have_volumes_bool,short_name] + + int index = 0; + while(true){ + + if(index >= arrayContent.length()) + break; + + int start = arrayContent.indexOf("[", index)+1; + int stop = arrayContent.indexOf("]", index); + + Log.d(TAG," start stop length index" + start+ " " + stop + " " + arrayContent.length() + " " + index); + if(start == -1 || stop == -1) + break; + + index = stop+1; + + String content = arrayContent.substring(start,stop); + + System.out.println("Content " + content); + + StringTokenizer tokenizer = new StringTokenizer(content,","); + + Organisation org = new Organisation(); + + //first is ID + String element = (String)tokenizer.nextElement(); + System.out.println("Element " + element); + try{ + org.id = Integer.parseInt(element); + }catch(Exception e){}; + + //level + element = (String)tokenizer.nextElement(); + System.out.println("Element " + element); + try{ + org.level = Integer.parseInt(element); + }catch(Exception e){}; + + //parent + element = (String)tokenizer.nextElement(); + System.out.println("Element " + element); + try{ + org.parent = Integer.parseInt(element); + }catch(Exception e){}; + + //name + element = (String)tokenizer.nextToken("\","); + System.out.println("Element " + element); + org.name = element; + + //can_have_volume_boo. + element = (String)tokenizer.nextElement(); + System.out.println("Element " + element); + try{ + org.canHaveVolumesBool = Integer.parseInt(element); + }catch(Exception e){}; + + //short name + element = (String)tokenizer.nextToken("\","); + System.out.println("Element " + element); + org.shortName = element; + + organisations.add(org); + } + + } + } + + + + /** + * Gets the net page content. + * + * @param url the url of the page to be retrieved + * @return the net page content + */ + private String getNetPageContent(String url){ + + String result = ""; + + HttpResponse response = null; + + try{ + HttpClient client = new DefaultHttpClient(); + HttpGet request = new HttpGet(url); + response = client.execute(request); + }catch(Exception e){ + System.out.println("Exception to GET page " + url); + } + StringBuilder str = null; + + try{ + InputStream in = response.getEntity().getContent(); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + str = new StringBuilder(); + String line = null; + while((line = reader.readLine()) != null) + { + str.append(line); + } + in.close(); + }catch(Exception e){ + System.err.println("Error in retrieving response " + e.getMessage()); + } + + result = str.toString(); + + + return result; + } + + /** + * Gets the search results + * + * @param searchWords the search words + * @return the search results + */ + public ArrayList getSearchResults(String searchWords){ + + + ArrayList resultsRecordInfo = new ArrayList(); + + + Method method = new Method(METHOD_MULTICASS_SEARCH); + + HashMap complexParm = new HashMap(); + + try{ + if(this.selectedOrganization != null){ + if(this.selectedOrganization.id != null) + complexParm.put("org_unit", this.selectedOrganization.id); + if(this.selectedOrganization.level != null) + complexParm.put("depth", this.selectedOrganization.level-1); + } + /* + complexParm.put("limit", 10); + complexParm.put("offset",0); + complexParm.put("visibility_limit", 3000); + complexParm.put("default_class","keyword"); + */ + + }catch(Exception e) + { + System.out.println("Exception in JSON " + e.getMessage()); + } + + System.out.println("JSON argument " + complexParm); + method.addParam(complexParm); + method.addParam(searchWords); + method.addParam(1); + + // sync test + HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); + Object resp; + + //why in while ? + + ArrayList ids = new ArrayList(); + + while ( (resp = req.recv()) != null){ + System.out.println("Sync Response: " + resp); + + Map response = (Map) resp; + + System.out.println(" ids : " + response.get("ids") + " " ); + + List> result_ids = (List) response.get("ids"); + + for(int i=0;i getItemShortInfo(String 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) { + System.out.println("Sync Response: " + resp); + return (Map)resp; + } + + return null; + } + + + /** + * Search catalog. + * + * @param searchWords the search words + * @return the object + */ + public Object searchCatalog(String searchWords){ + + + Method method = new Method(METHOD_SLIM_RETRIVE); + + method.addParam("keyword"); + method.addParam(searchWords); + + + // sync test + HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); + Object resp; + while ( (resp = req.recv()) != null) { + System.out.println("Sync Response: " + resp); + return resp; + } + + + // exceptions are captured instead of thrown, + // primarily to better support async requests + if (req.failed()) { + req.getFailure().printStackTrace(); + return null; + } + + return null; + } + + /** + * 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); + + } + + + /** + * Select organisation. + * + * @param org the organization on witch the searches will be made + */ + public void selectOrganisation(Organisation org){ + + + Log.d(TAG,"Select search organisation " + (org.level-1) + " " + org.id ); + this.selectedOrganization = org; + + + } + + private void readIDLFile(){ + + String idlFile = "fm_IDL.xml"; + try{ + Log.d("debug","Read fm"); + IDLParser parser = new IDLParser(context.getAssets().open(idlFile)); + parser.parse(); + }catch(Exception e){ + System.err.println("Error in parsing IDL file " + idlFile + " " + e.getMessage()); + }; + + } +} diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java new file mode 100644 index 0000000000..7981b91cb3 --- /dev/null +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java @@ -0,0 +1,252 @@ +package org.evergreen.android.searchCatalog; + +import java.util.ArrayList; +import java.util.List; + +import org.evergreen.android.R; +import org.open_ils.idl.IDLParser; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.Spinner; +import android.widget.TextView; + +public class SearchCatalogListView extends Activity{ + /** + * + */ + + + /** Called when the activity is first created. */ + + private List recordList; + + private EditText searchText; + + private ImageButton searchButton; + + private SearchCatalog search; + + private ListView lv; + + private SearchArrayAdapter adapter; + + private Context context; + + private ProgressDialog progressDialog; + + private ArrayList searchResults; + + private Spinner choseOrganisation; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.search_result_list); + + + context = this; + search = new SearchCatalog("http://ulysses.calvin.edu","en-US",this); + + recordList= new ArrayList(); + + // Create a customized ArrayAdapter + adapter = new SearchArrayAdapter( + getApplicationContext(), R.layout.search_result_item, recordList); + + // Get reference to ListView holder + lv = (ListView) this.findViewById(R.id.search_results_list); + + //System.out.println("Here it is " + lv); + // Set the ListView adapter + lv.setAdapter(adapter); + + + lv.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView arg0, View arg1, int position, + long arg3) { + + + RecordInfo info = (RecordInfo)lv.getItemAtPosition(position); + //start activity with book details + + Intent intent = new Intent(getBaseContext(),RecordDetails_Simple.class); + //serialize object and pass it to next activity + intent.putExtra("recordInfo", info); + + startActivity(intent); + } + }); + + searchText = (EditText) findViewById(R.id.searchText); + + choseOrganisation = (Spinner) findViewById(R.id.chose_organisation); + + searchButton = (ImageButton) findViewById(R.id.searchButton); + + searchButton.setOnClickListener(new OnClickListener() { + + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + + final String text = searchText.getText().toString(); + + + progressDialog = new ProgressDialog(context); + + progressDialog.setMessage("Fetching data"); + progressDialog.show(); + + if(text.length()>0){ + + Thread searchThread = new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + searchResults = search.getSearchResults(text); + + runOnUiThread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + recordList.clear(); + if(searchResults.size()>0){ + //TODO + for(int j=0;j list = new ArrayList(); + for(int i=0;i adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item,list); + choseOrganisation.setAdapter(adapter); + + choseOrganisation.setSelection(selectedPos); + + choseOrganisation.setOnItemSelectedListener(new OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView arg0, View arg1, + int ID, long arg3) { + //select the specific organization + search.selectOrganisation(search.organisations.get(ID)); + + } + + @Override + public void onNothingSelected(AdapterView arg0) { + + } + + }); + + } + + class SearchArrayAdapter extends ArrayAdapter { + private static final String tag = "SearchArrayAdapter"; + private Context context; + private ImageView recordImage; + private TextView recordTitle; + private TextView recordAuthor; + private TextView recordPublisher; + + private List records = new ArrayList(); + + public SearchArrayAdapter(Context context, int textViewResourceId, + List objects) { + super(context, textViewResourceId, objects); + this.context = context; + this.records = objects; + } + + public int getCount() { + return this.records.size(); + } + + public RecordInfo getItem(int index) { + return this.records.get(index); + } + + public View getView(int position, View convertView, ViewGroup parent) { + View row = convertView; + if (row == null) { + // ROW INFLATION + Log.d(tag, "Starting XML Row Inflation ... "); + LayoutInflater inflater = (LayoutInflater) this.getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + row = inflater.inflate(R.layout.search_result_item, parent, false); + Log.d(tag, "Successfully completed XML Row Inflation!"); + } + + // Get item + RecordInfo record = getItem(position); + + // Get reference to ImageView + recordImage = (ImageView) row.findViewById(R.id.search_record_img); + + // Get reference to TextView - title + recordTitle = (TextView) row.findViewById(R.id.search_record_title); + + // Get reference to TextView - author + recordAuthor = (TextView) row.findViewById(R.id.search_record_author); + + //Get referance to TextView - record Publisher date+publisher + recordPublisher = (TextView) row.findViewById(R.id.search_record_publishing); + + //set text + + recordTitle.setText(record.title); + recordAuthor.setText(record.author); + recordPublisher.setText(record.pubdate + " " + record.publisher); + + return row; + } + } + + +} + + diff --git a/Open-ILS/src/Android/src/org/open_ils/Event.java b/Open-ILS/src/Android/src/org/open_ils/Event.java new file mode 100644 index 0000000000..69a73a1aec --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/Event.java @@ -0,0 +1,33 @@ +package org.open_ils; + +import java.util.Map; +import java.util.HashMap; + +public class Event extends HashMap { + + public Event() { + } + + public Event(Map map) { + super(map); + } + + public static Event parseEvent(Object map) { + if( map != null && map instanceof Map) { + Map m = (Map) map; + if( m.containsKey("ilsevent") && m.containsKey("textcode")) + return new Event(m); + } + + return null; + } + + public String getTextCode() { + return (String) get("textcode"); + } + + public int getCode() { + return Integer.parseInt((String) get("ilsevent")); + } +} + diff --git a/Open-ILS/src/Android/src/org/open_ils/Sys.java b/Open-ILS/src/Android/src/org/open_ils/Sys.java new file mode 100644 index 0000000000..0d66edca88 --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/Sys.java @@ -0,0 +1,70 @@ +package org.open_ils; + +import org.opensrf.*; +import org.opensrf.util.*; +import org.open_ils.*; +import org.open_ils.idl.*; +import org.opensrf.util.*; + +import java.util.Map; +import java.util.HashMap; +import java.io.IOException; + + +public class Sys { + + private static IDLParser idlParser = null; + + /** + * Initializes the connection to the OpenSRF network and parses the IDL file. + * @param attrs A map of configuration attributes. Options include:
+ *
    + *
  • configFile - The OpenSRF core config file
  • + *
  • configContext - The path to the config chunk in the config XML, typically "opensrf"
  • + *
  • logProtocol - Currently supported option is "file".
  • + *
  • logLevel - The log level. Options are 1,2,3, or 4 (error, warn, info, debug)
  • + *
  • syslogFacility - For future use, when syslog is a supported log option
  • + *
  • idlFile - The path to the IDL file. May be relative or absolute. If this option is + * not provided, the system will ask the OpenSRF Settings server for the IDL file path.
  • + *
+ */ + public static void init(Map attrs) throws ConfigException, SessionException, IOException, IDLException { + + String configFile = attrs.get("configFile"); + String configContext = attrs.get("configContext"); + String logProto = attrs.get("logProtocol"); + String logFile = attrs.get("logFile"); + String logLevel = attrs.get("logLevel"); + String syslogFacility = attrs.get("syslogFacility"); + String idlFile = attrs.get("idlFile"); + + + if(idlParser != null) { + /** if we've parsed the IDL file, then all of the global setup has been done. + * We just need to verify this thread is connected to the OpenSRF network. */ + org.opensrf.Sys.bootstrapClient(configFile, configContext); + return; + } + + /** initialize the logging infrastructure */ + if("file".equals(logProto)) + Logger.init(Short.parseShort(logLevel), new FileLogger(logFile)); + + if("syslog".equals(logProto)) + throw new ConfigException("syslog not yet implemented"); + + /** connect to the opensrf network. */ + org.opensrf.Sys.bootstrapClient(configFile, configContext); + + /** Grab the IDL file setting if not explicitly provided */ + if(idlFile == null) { + SettingsClient client = SettingsClient.instance(); + idlFile = client.getString("/IDL"); + } + + /** Parse the IDL if necessary */ + idlParser = new IDLParser(idlFile); + idlParser.parse(); + } +} + diff --git a/Open-ILS/src/Android/src/org/open_ils/idl/IDLException.java b/Open-ILS/src/Android/src/org/open_ils/idl/IDLException.java new file mode 100644 index 0000000000..1b84d2481b --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/idl/IDLException.java @@ -0,0 +1,10 @@ +package org.open_ils.idl; + +public class IDLException extends Exception { + public IDLException(String info) { + super(info); + } + public IDLException(String info, Throwable cause) { + super(info, cause); + } +} diff --git a/Open-ILS/src/Android/src/org/open_ils/idl/IDLField.java b/Open-ILS/src/Android/src/org/open_ils/idl/IDLField.java new file mode 100644 index 0000000000..6955bc5794 --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/idl/IDLField.java @@ -0,0 +1,46 @@ +package org.open_ils.idl; + +public class IDLField { + + /** Field name */ + private String name; + + /** Where this field resides in the array when serilized */ + private int arrayPos; + + /** True if this field does not belong in the database */ + private boolean isVirtual; + + public void setName(String name) { + this.name = name; + } + public void setArrayPos(int arrayPos) { + this.arrayPos = arrayPos; + } + public void setIsVirtual(boolean isVirtual) { + this.isVirtual = isVirtual; + } + public String getName() { + return this.name; + } + public int getArrayPos() { + return this.arrayPos; + } + public boolean getIsVirtual() { + return this.isVirtual; + } + + public void toXML(StringBuffer sb) { + sb.append("\t\t\t\n"); + } +} diff --git a/Open-ILS/src/Android/src/org/open_ils/idl/IDLLink.java b/Open-ILS/src/Android/src/org/open_ils/idl/IDLLink.java new file mode 100644 index 0000000000..69a5772c75 --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/idl/IDLLink.java @@ -0,0 +1,46 @@ +package org.open_ils.idl; + + +public class IDLLink { + + /**The field on the IDLObject this link extends from */ + private String field; + private String reltype; + private String key; + private String map; + /**The IDL class linked to */ + private String IDLClass; + + + public void setField(String field) { + this.field = field; + } + public void setReltype(String reltype) { + this.reltype = reltype; + } + public void setKey(String key) { + this.key = key; + } + public void setMap(String map) { + this.map = map; + } + public void setIDLClass(String IDLClass) { + this.IDLClass = IDLClass; + } + public String getField() { + return this.field; + } + public String getReltype() { + return this.reltype; + } + public String getKey() { + return this.key; + } + public String getMap() { + return this.map; + } + public String getIDLClass() { + return this.IDLClass; + } +} + diff --git a/Open-ILS/src/Android/src/org/open_ils/idl/IDLObject.java b/Open-ILS/src/Android/src/org/open_ils/idl/IDLObject.java new file mode 100644 index 0000000000..aafde6e031 --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/idl/IDLObject.java @@ -0,0 +1,96 @@ +package org.open_ils.idl; +import java.util.HashMap; +import java.util.Iterator; + + +public class IDLObject { + + private String IDLClass; + private String fieldMapper; + private String controller; + private String rptLabel; + private HashMap fields; + private HashMap links; + + /** true if this is a virtual object (does not live in the database) */ + private boolean isVirtual; + + public IDLObject() { + fields = new HashMap(); + links = new HashMap(); + } + + public String getIDLClass() { + return IDLClass; + } + + public void addLink(IDLLink link) { + links.put(link.getField(), link); + } + + public void addField(IDLField field) { + fields.put(field.getName(), field); + } + + public IDLField getField(String name) { + return (IDLField) fields.get(name); + } + + public HashMap getFields() { + return fields; + } + + + /** + * Returns the link object found at the given field on + * this IDLObject. + */ + public IDLLink getLink(String fieldName) { + return (IDLLink) links.get(fieldName); + } + + public String getFieldMapper() { + return fieldMapper; + } + + public String getController() { + return controller; + } + + public String getRptLabel() { + return rptLabel; + } + public boolean isVirtual() { + return isVirtual; + } + + public void setIDLClass(String IDLClass) { + this.IDLClass = IDLClass; + } + + public void setFieldMapper(String fm) { + this.fieldMapper = fm; + } + public void setController(String controller) { + this.controller = controller; + } + public void setRptLabel(String label) { + this.rptLabel = label; + } + public void setIsVirtual(boolean isVirtual) { + this.isVirtual = isVirtual; + } + + + public void toXML(StringBuffer sb) { + + sb.append("\t\t"); + Iterator itr = fields.keySet().iterator(); + IDLField field; + while(itr.hasNext()) { + field = fields.get((String) itr.next()); + field.toXML(sb); + } + sb.append("\t\t"); + } +} diff --git a/Open-ILS/src/Android/src/org/open_ils/idl/IDLParser.java b/Open-ILS/src/Android/src/org/open_ils/idl/IDLParser.java new file mode 100644 index 0000000000..dbfa507c8b --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/idl/IDLParser.java @@ -0,0 +1,217 @@ +package org.open_ils.idl; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +import org.opensrf.util.OSRFRegistry; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlPullParserFactory; + +import android.util.Log; + + +public class IDLParser { + + public static final String OILS_NS_BASE="http://opensrf.org/spec/IDL/base/v1"; + public static final String OILS_NS_OBJ="http://open-ils.org/spec/opensrf/IDL/objects/v1"; + public static final String OILS_NS_OBJ_PREFIX="oils_obj"; + public static final String OILS_NS_PERSIST="http://open-ils.org/spec/opensrf/IDL/persistence/v1"; + public static final String OILS_NS_PERSIST_PREFIX="oils_persist"; + public static final String OILS_NS_REPORTER="http://open-ils.org/spec/opensrf/IDL/reporter/v1"; + public static final String OILS_NS_REPORTER_PREFIX="reporter"; + + /** The source for the IDL XML */ + InputStream inStream; + HashMap IDLObjects; + IDLObject current; + private int fieldIndex; + + /** If true, we retain the full set of IDL objects in memory. This is true by default. */ + private boolean keepIDLObjects; + + private int parsedObjectCount; + + public IDLParser() { + IDLObjects = new HashMap(); + keepIDLObjects = true; + parsedObjectCount = 0; + fieldIndex = 0; + } + + public IDLParser(String fileName) throws IOException { + this(new FileInputStream(fileName)); + } + + public IDLParser(InputStream inStream) { + this(); + this.inStream = inStream; + } + + + /** + * Parses the IDL XML + */ + public void parse() throws IOException, IDLException { + + try { + //XMLInputFactory factory = XMLInputFactory.newInstance(); + + XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); + factory.setNamespaceAware(true); + XmlPullParser xpp = factory.newPullParser(); + + xpp.setInput(this.inStream,null ); + int eventType = xpp.getEventType(); + + /** disable as many unused features as possible to speed up the parsing */ + /* + factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); + factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); + factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); + factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); + factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); + */ + + /** create the stream reader */ + + while(eventType != XmlPullParser.END_DOCUMENT) { + /** cycle through the XML events */ + + // eventType = reader.next(); + + switch(eventType) { + + case XmlPullParser.START_TAG: + handleStartElement(xpp); + break; + + case XmlPullParser.END_TAG: + handleEndElement(xpp); + break; + } + eventType = xpp.next(); + } + + } catch(XmlPullParserException se) { + throw new IDLException("Error parsing IDL XML", se); + } + } + + /** + * Returns the IDLObject with the given IDLClass + */ + public IDLObject getObject(String IDLClass) { + return (IDLObject) IDLObjects.get(IDLClass); + } + + /** + * Returns the full set of IDL objects as a hash from classname to object. + * If keepIDLObjects is false, the map will be empty. + */ + public HashMap getIDLObjects() { + return IDLObjects; + } + + /** + * Returns the number of parsed objects, regardless of the keepIDLObjects setting. + */ + public int getObjectCount() { + return parsedObjectCount; + } + + + public void handleStartElement(XmlPullParser reader) { + + if(!OILS_NS_BASE.equals(reader.getNamespace())) return; + String localpart = reader.getName(); + + if( "class".equals(localpart) ) { + fieldIndex = 0; + current = new IDLObject(); + current.setIDLClass(reader.getAttributeValue(null, "id")); + current.setController(reader.getAttributeValue(null, "controller")); + String persist = reader.getAttributeValue(OILS_NS_PERSIST, "virtual"); + current.setIsVirtual("persist".equals(reader.getAttributeValue(OILS_NS_PERSIST, "virtual"))); + return; + } + + if( "field".equals(localpart) ) { + IDLField field = new IDLField(); + field.setName(reader.getAttributeValue(null, "name")); + field.setArrayPos(fieldIndex++); + field.setIsVirtual("true".equals(reader.getAttributeValue(OILS_NS_PERSIST, "virtual"))); + current.addField(field); + //Log.d("parser","Field " + localpart + " " + field ); + } + + if( "link".equals(localpart) ) { + IDLLink link = new IDLLink(); + link.setField(reader.getAttributeValue(null, "field")); + link.setReltype(reader.getAttributeValue(null, "reltype")); + link.setKey(reader.getAttributeValue(null, "key")); + link.setMap(reader.getAttributeValue(null, "map")); + link.setIDLClass(reader.getAttributeValue(null, "class")); + current.addLink(link); + } + } + + public void handleEndElement(XmlPullParser reader) throws IDLException { + + if(!OILS_NS_BASE.equals(reader.getNamespace())) return; + String localpart = reader.getName(); + + if("class".equals(localpart)) { + + if(keepIDLObjects) + IDLObjects.put(current.getIDLClass(), current); + + HashMap fields = current.getFields(); + String fieldNames[] = new String[fields.size()]; + + for(Iterator itr = fields.keySet().iterator(); itr.hasNext(); ) { + String key = (String) itr.next(); + IDLField field = (IDLField) fields.get(key); + try { + fieldNames[ field.getArrayPos() ] = field.getName(); + } catch(ArrayIndexOutOfBoundsException E) { + String msg = "class="+current.getIDLClass()+";field="+key+ + ";fieldcount="+fields.size()+";currentpos="+field.getArrayPos(); + throw new IDLException(msg, E); + } + } + + OSRFRegistry.registerObject( + current.getIDLClass(), OSRFRegistry.WireProtocol.ARRAY, fieldNames); + + parsedObjectCount++; + + current = null; + } + } + + + public String toXML() { + StringBuffer sb = new StringBuffer(); + Set keys = IDLObjects.keySet(); + Iterator itr = IDLObjects.keySet().iterator(); + String IDLClass; + IDLObject obj; + while(itr.hasNext()) { + IDLClass = (String) itr.next(); + obj = IDLObjects.get(IDLClass); + obj.toXML(sb); + } + return sb.toString(); + } +} + + + + + + diff --git a/Open-ILS/src/Android/src/org/open_ils/test/TestIDL.java b/Open-ILS/src/Android/src/org/open_ils/test/TestIDL.java new file mode 100644 index 0000000000..632c28e82b --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/test/TestIDL.java @@ -0,0 +1,24 @@ +package org.open_ils.test; +import org.open_ils.idl.*; +import org.opensrf.*; +import org.opensrf.util.*; + +public class TestIDL { + public static void main(String args[]) throws Exception { + String idlFile = "fm_IDL.xml"; + IDLParser parser = new IDLParser(idlFile); + parser.parse(); + //System.out.print(parser.toXML()); + + OSRFObject bre = new OSRFObject("bre"); + bre.put("id", new Integer(1)); + bre.put("isnew", new Boolean(false)); + bre.put("isdeleted", new Boolean(true)); + + + System.out.println(bre); + System.out.println(new JSONWriter(bre).write()); + + + } +} diff --git a/Open-ILS/src/Android/src/org/open_ils/test/TestLogin.java b/Open-ILS/src/Android/src/org/open_ils/test/TestLogin.java new file mode 100644 index 0000000000..265fa37e02 --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/test/TestLogin.java @@ -0,0 +1,29 @@ +package org.open_ils.test; +import org.open_ils.util.Utils; +import org.open_ils.Event; +import org.opensrf.*; +import java.util.Map; +import java.util.HashMap; + + +public class TestLogin { + public static void main(String args[]) { + try { + + if(args.length < 3) { + System.err.println("usage: java org.open_ils.test.TestLogin "); + return; + } + + Sys.bootstrapClient(args[0], "/config/opensrf"); + Map params = new HashMap(); + params.put("username", args[1]); + params.put("password", args[2]); + Event evt = Utils.login(params); + System.out.println(evt); + } catch(Exception e) { + System.err.println(e); + } + } +} + diff --git a/Open-ILS/src/Android/src/org/open_ils/util/Utils.java b/Open-ILS/src/Android/src/org/open_ils/util/Utils.java new file mode 100644 index 0000000000..ba61a1becd --- /dev/null +++ b/Open-ILS/src/Android/src/org/open_ils/util/Utils.java @@ -0,0 +1,77 @@ +package org.open_ils.util; +import org.open_ils.*; +import org.opensrf.*; +import org.opensrf.util.*; +import java.util.Map; +import java.util.HashMap; +import java.security.MessageDigest; + +public class Utils { + + /** + * Logs in. + * @param params Login arguments, which may consist of
+ * username
+ * barcode - if username is provided, barcode will be ignored
+ * password
+ * workstation - name of the workstation where the login is occuring
+ * type - type of login, currently "opac", "staff", and "temp"
+ * org - optional org ID to provide login context when no workstation is used. + * @return An Event object. On success, the event 'payload' will contain + * 'authtoken' and 'authtime' fields, which represent the session key and + * session inactivity timeout, respectively. + */ + public static Event login(Map params) throws MethodException { + + Map initMap = new HashMap(); + String init = (params.get("username") != null) ? + params.get("username").toString() : params.get("barcode").toString(); + System.out.println("Here"); + + Object resp = ClientSession.atomicRequest( + "open-ils.auth", + "open-ils.auth.authenticate.init", new Object [] {initMap}); + System.out.println("Here"); + /** see if the server responded with some type of unexpected event */ + + Event evt = Event.parseEvent(resp); + if(evt != null) return evt; + + params.put("password", md5Hex(resp + md5Hex(params.get("password").toString()))); + + resp = ClientSession.atomicRequest( + "open-ils.auth", + "open-ils.auth.authenticate.complete", new Object[]{params}); + + return Event.parseEvent(resp); + } + + + /** + * Generates the hex md5sum of a string. + * @param s The string to md5sum + * @return The 32-character hex md5sum + */ + public static String md5Hex(String s) { + StringBuffer sb = new StringBuffer(); + MessageDigest md; + try { + md = MessageDigest.getInstance("MD5"); + } catch(Exception e) { + return null; + } + + md.update(s.getBytes()); + byte[] digest = md.digest(); + for (int i = 0; i < digest.length; i++) { + int b = digest[i] & 0xff; + String hex = Integer.toHexString(b); + if (hex.length() == 1) sb.append("0"); + sb.append(hex); + } + return sb.toString(); + } +} + + +