From 7f6cb7fbe480d349d5ed5c705c5cfadff3453229 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 21 Jan 2019 12:02:31 -0800 Subject: rust impl of new fields --- rust/src/database_models.rs | 16 ++++++++++++---- rust/src/database_schema.rs | 8 ++++++-- rust/src/entity_crud.rs | 28 ++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs index 7f574893..adb38bda 100644 --- a/rust/src/database_models.rs +++ b/rust/src/database_models.rs @@ -129,11 +129,10 @@ pub struct ContainerRevRow { pub id: Uuid, pub extra_json: Option, pub name: String, + pub container_type: Option, pub publisher: Option, pub issnl: Option, pub wikidata_qid: Option, - pub abbrev: Option, - pub coden: Option, } #[derive(Debug, Associations, AsChangeset, Insertable)] @@ -141,11 +140,10 @@ pub struct ContainerRevRow { pub struct ContainerRevNewRow { pub extra_json: Option, pub name: String, + pub container_type: Option, pub publisher: Option, pub issnl: Option, pub wikidata_qid: Option, - pub abbrev: Option, - pub coden: Option, } entity_structs!( @@ -380,6 +378,7 @@ pub struct ReleaseRevRow { pub container_ident_id: Option, pub refs_blob_sha1: Option, pub title: String, + pub original_title: Option, pub release_type: Option, pub release_status: Option, pub release_date: Option, @@ -390,11 +389,14 @@ pub struct ReleaseRevRow { pub wikidata_qid: Option, pub isbn13: Option, pub core_id: Option, + pub arxiv_id: Option, + pub jstor_id: Option, pub volume: Option, pub issue: Option, pub pages: Option, pub publisher: Option, pub language: Option, + pub license_slug: Option, } #[derive(Debug, Associations, AsChangeset, Insertable)] @@ -405,6 +407,7 @@ pub struct ReleaseRevNewRow { pub container_ident_id: Option, pub refs_blob_sha1: Option, pub title: String, + pub original_title: Option, pub release_type: Option, pub release_status: Option, pub release_date: Option, @@ -415,11 +418,14 @@ pub struct ReleaseRevNewRow { pub wikidata_qid: Option, pub isbn13: Option, pub core_id: Option, + pub arxiv_id: Option, + pub jstor_id: Option, pub volume: Option, pub issue: Option, pub pages: Option, pub publisher: Option, pub language: Option, + pub license_slug: Option, } entity_structs!( @@ -480,6 +486,7 @@ pub struct ReleaseContribRow { pub creator_ident_id: Option, pub raw_name: Option, pub role: Option, + pub raw_affiliation: Option, pub index_val: Option, pub extra_json: Option, } @@ -491,6 +498,7 @@ pub struct ReleaseContribNewRow { pub creator_ident_id: Option, pub raw_name: Option, pub role: Option, + pub raw_affiliation: Option, pub index_val: Option, pub extra_json: Option, } diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs index 69b8c342..ea184226 100644 --- a/rust/src/database_schema.rs +++ b/rust/src/database_schema.rs @@ -51,11 +51,10 @@ table! { id -> Uuid, extra_json -> Nullable, name -> Text, + container_type -> Nullable, publisher -> Nullable, issnl -> Nullable, wikidata_qid -> Nullable, - abbrev -> Nullable, - coden -> Nullable, } } @@ -252,6 +251,7 @@ table! { creator_ident_id -> Nullable, raw_name -> Nullable, role -> Nullable, + raw_affiliation -> Nullable, index_val -> Nullable, extra_json -> Nullable, } @@ -295,6 +295,7 @@ table! { container_ident_id -> Nullable, refs_blob_sha1 -> Nullable, title -> Text, + original_title -> Nullable, release_type -> Nullable, release_status -> Nullable, release_date -> Nullable, @@ -305,11 +306,14 @@ table! { wikidata_qid -> Nullable, isbn13 -> Nullable, core_id -> Nullable, + arxiv_id -> Nullable, + jstor_id -> Nullable, volume -> Nullable, issue -> Nullable, pages -> Nullable, publisher -> Nullable, language -> Nullable, + license_slug -> Nullable, } } diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs index f5c092eb..a92c45a6 100644 --- a/rust/src/entity_crud.rs +++ b/rust/src/entity_crud.rs @@ -798,8 +798,7 @@ impl EntityCrud for ContainerEntity { wikidata_qid: None, publisher: None, name: None, - abbrev: None, - coden: None, + container_type: None, state: Some(ident_row.state().unwrap().shortname()), ident: Some(FatcatId::from_uuid(&ident_row.id).to_string()), revision: ident_row.rev_id.map(|u| u.to_string()), @@ -831,8 +830,7 @@ impl EntityCrud for ContainerEntity { wikidata_qid: rev_row.wikidata_qid, publisher: rev_row.publisher, name: Some(rev_row.name), - abbrev: rev_row.abbrev, - coden: rev_row.coden, + container_type: rev_row.container_type, state, ident: ident_id, revision: Some(rev_row.id.to_string()), @@ -869,8 +867,7 @@ impl EntityCrud for ContainerEntity { publisher: model.publisher.clone(), issnl: model.issnl.clone(), wikidata_qid: model.wikidata_qid.clone(), - abbrev: model.abbrev.clone(), - coden: model.coden.clone(), + container_type: model.container_type.clone(), extra_json: model.extra.clone(), }) .collect::>(), @@ -1619,6 +1616,7 @@ impl EntityCrud for ReleaseEntity { Ok(ReleaseEntity { title: None, + original_title: None, release_type: None, release_status: None, release_date: None, @@ -1627,8 +1625,10 @@ impl EntityCrud for ReleaseEntity { pmid: None, pmcid: None, isbn13: None, - core_id: None, wikidata_qid: None, + core_id: None, + arxiv_id: None, + jstor_id: None, volume: None, issue: None, pages: None, @@ -1639,6 +1639,7 @@ impl EntityCrud for ReleaseEntity { container_id: None, publisher: None, language: None, + license_slug: None, work_id: None, refs: None, contribs: None, @@ -1871,6 +1872,7 @@ impl EntityCrud for ReleaseEntity { index: c.index_val.map(|v| v as i64), raw_name: c.raw_name, role: c.role, + raw_affiliation: c.raw_affiliation, extra: c.extra_json, creator_id: c .creator_ident_id @@ -1904,6 +1906,7 @@ impl EntityCrud for ReleaseEntity { Ok(ReleaseEntity { title: Some(rev_row.title), + original_title: rev_row.original_title, release_type: rev_row.release_type, release_status: rev_row.release_status, release_date: rev_row.release_date, @@ -1912,8 +1915,10 @@ impl EntityCrud for ReleaseEntity { pmid: rev_row.pmid, pmcid: rev_row.pmcid, isbn13: rev_row.isbn13, - core_id: rev_row.core_id, wikidata_qid: rev_row.wikidata_qid, + core_id: rev_row.core_id, + arxiv_id: rev_row.arxiv_id, + jstor_id: rev_row.jstor_id, volume: rev_row.volume, issue: rev_row.issue, pages: rev_row.pages, @@ -1926,6 +1931,7 @@ impl EntityCrud for ReleaseEntity { .map(|u| FatcatId::from_uuid(&u).to_string()), publisher: rev_row.publisher, language: rev_row.language, + license_slug: rev_row.license_slug, work_id: Some(FatcatId::from_uuid(&rev_row.work_ident_id).to_string()), refs, contribs, @@ -1954,6 +1960,7 @@ impl EntityCrud for ReleaseEntity { if let Some(ref extid) = entity.wikidata_qid { check_wikidata_qid(extid)?; } + // TODO: JSTOR and arxiv IDs if let Some(ref release_type) = entity.release_type { check_release_type(release_type)?; } @@ -2031,6 +2038,7 @@ impl EntityCrud for ReleaseEntity { Ok(ReleaseRevNewRow { refs_blob_sha1: refs_sha1, title: model.title.clone().unwrap(), // titles checked above + original_title: model.original_title.clone(), release_type: model.release_type.clone(), release_status: model.release_status.clone(), release_date: model.release_date, @@ -2041,6 +2049,8 @@ impl EntityCrud for ReleaseEntity { wikidata_qid: model.wikidata_qid.clone(), isbn13: model.isbn13.clone(), core_id: model.core_id.clone(), + arxiv_id: model.arxiv_id.clone(), + jstor_id: model.jstor_id.clone(), volume: model.volume.clone(), issue: model.issue.clone(), pages: model.pages.clone(), @@ -2054,6 +2064,7 @@ impl EntityCrud for ReleaseEntity { }, publisher: model.publisher.clone(), language: model.language.clone(), + license_slug: model.license_slug.clone(), extra_json: model.extra.clone() }) }) @@ -2107,6 +2118,7 @@ impl EntityCrud for ReleaseEntity { raw_name: c.raw_name.clone(), index_val: c.index.map(|v| v as i32), role: c.role.clone(), + raw_affiliation: c.raw_affiliation.clone(), extra_json: c.extra.clone(), }) }) -- cgit v1.2.3