From 2027162f9871ebe43a40b0ac4615149141b7a571 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 21 Jan 2019 12:23:08 -0800 Subject: allow arxiv and jstor lookups --- rust/src/endpoint_handlers.rs | 34 +++++++++++++++++++++++++++------- rust/src/endpoints.rs | 4 ++++ 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'rust/src') diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs index bc606af9..4567e810 100644 --- a/rust/src/endpoint_handlers.rs +++ b/rust/src/endpoint_handlers.rs @@ -259,12 +259,14 @@ impl Server { pmid: &Option, pmcid: &Option, core_id: &Option, + arxiv_id: &Option, + jstor_id: &Option, expand_flags: ExpandFlags, hide_flags: HideFlags, ) -> Result { let (ident, rev): (ReleaseIdentRow, ReleaseRevRow) = - match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id) { - (Some(doi), None, None, None, None, None) => { + match (doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id) { + (Some(doi), None, None, None, None, None, None, None) => { check_doi(doi)?; release_ident::table .inner_join(release_rev::table) @@ -273,7 +275,7 @@ impl Server { .filter(release_ident::redirect_id.is_null()) .first(conn)? } - (None, Some(wikidata_qid), None, None, None, None) => { + (None, Some(wikidata_qid), None, None, None, None, None, None) => { check_wikidata_qid(wikidata_qid)?; release_ident::table .inner_join(release_rev::table) @@ -282,7 +284,7 @@ impl Server { .filter(release_ident::redirect_id.is_null()) .first(conn)? } - (None, None, Some(isbn13), None, None, None) => { + (None, None, Some(isbn13), None, None, None, None, None) => { // TODO: check_isbn13(isbn13)?; release_ident::table .inner_join(release_rev::table) @@ -291,7 +293,7 @@ impl Server { .filter(release_ident::redirect_id.is_null()) .first(conn)? } - (None, None, None, Some(pmid), None, None) => { + (None, None, None, Some(pmid), None, None, None, None) => { check_pmid(pmid)?; release_ident::table .inner_join(release_rev::table) @@ -300,7 +302,7 @@ impl Server { .filter(release_ident::redirect_id.is_null()) .first(conn)? } - (None, None, None, None, Some(pmcid), None) => { + (None, None, None, None, Some(pmcid), None, None, None) => { check_pmcid(pmcid)?; release_ident::table .inner_join(release_rev::table) @@ -309,7 +311,7 @@ impl Server { .filter(release_ident::redirect_id.is_null()) .first(conn)? } - (None, None, None, None, None, Some(core_id)) => { + (None, None, None, None, None, Some(core_id), None, None) => { // TODO: check_core_id(core_id)?; release_ident::table .inner_join(release_rev::table) @@ -318,6 +320,24 @@ impl Server { .filter(release_ident::redirect_id.is_null()) .first(conn)? } + (None, None, None, None, None, None, Some(arxiv_id), None) => { + // TODO: check_arxiv_id(arxiv_id)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::arxiv_id.eq(arxiv_id)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } + (None, None, None, None, None, None, None, Some(jstor_id)) => { + // TODO: check_jstor_id(jstor_id)?; + release_ident::table + .inner_join(release_rev::table) + .filter(release_rev::jstor_id.eq(jstor_id)) + .filter(release_ident::is_live.eq(true)) + .filter(release_ident::redirect_id.is_null()) + .first(conn)? + } _ => { return Err( FatcatError::MissingOrMultipleExternalId("in lookup".to_string()).into(), diff --git a/rust/src/endpoints.rs b/rust/src/endpoints.rs index 670c7fd9..8c45ea75 100644 --- a/rust/src/endpoints.rs +++ b/rust/src/endpoints.rs @@ -665,6 +665,8 @@ impl Api for Server { pmid: Option, pmcid: Option, core_id: Option, + arxiv_id: Option, + jstor_id: Option, expand: Option, hide: Option, _context: &Context, @@ -688,6 +690,8 @@ impl Api for Server { &pmid, &pmcid, &core_id, + &arxiv_id, + &jstor_id, expand_flags, hide_flags, ) -- cgit v1.2.3