summaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-21 12:02:31 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-21 12:02:31 -0800
commit7f6cb7fbe480d349d5ed5c705c5cfadff3453229 (patch)
tree951709ed2a5f962c8ab4e069e0a9fae610dd2a27 /rust/src
parent4c54f3bf32e0d0e9dbe52b22f911027a667c0e34 (diff)
downloadfatcat-7f6cb7fbe480d349d5ed5c705c5cfadff3453229.tar.gz
fatcat-7f6cb7fbe480d349d5ed5c705c5cfadff3453229.zip
rust impl of new fields
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/database_models.rs16
-rw-r--r--rust/src/database_schema.rs8
-rw-r--r--rust/src/entity_crud.rs28
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<serde_json::Value>,
pub name: String,
+ pub container_type: Option<String>,
pub publisher: Option<String>,
pub issnl: Option<String>,
pub wikidata_qid: Option<String>,
- pub abbrev: Option<String>,
- pub coden: Option<String>,
}
#[derive(Debug, Associations, AsChangeset, Insertable)]
@@ -141,11 +140,10 @@ pub struct ContainerRevRow {
pub struct ContainerRevNewRow {
pub extra_json: Option<serde_json::Value>,
pub name: String,
+ pub container_type: Option<String>,
pub publisher: Option<String>,
pub issnl: Option<String>,
pub wikidata_qid: Option<String>,
- pub abbrev: Option<String>,
- pub coden: Option<String>,
}
entity_structs!(
@@ -380,6 +378,7 @@ pub struct ReleaseRevRow {
pub container_ident_id: Option<Uuid>,
pub refs_blob_sha1: Option<String>,
pub title: String,
+ pub original_title: Option<String>,
pub release_type: Option<String>,
pub release_status: Option<String>,
pub release_date: Option<chrono::NaiveDate>,
@@ -390,11 +389,14 @@ pub struct ReleaseRevRow {
pub wikidata_qid: Option<String>,
pub isbn13: Option<String>,
pub core_id: Option<String>,
+ pub arxiv_id: Option<String>,
+ pub jstor_id: Option<String>,
pub volume: Option<String>,
pub issue: Option<String>,
pub pages: Option<String>,
pub publisher: Option<String>,
pub language: Option<String>,
+ pub license_slug: Option<String>,
}
#[derive(Debug, Associations, AsChangeset, Insertable)]
@@ -405,6 +407,7 @@ pub struct ReleaseRevNewRow {
pub container_ident_id: Option<Uuid>,
pub refs_blob_sha1: Option<String>,
pub title: String,
+ pub original_title: Option<String>,
pub release_type: Option<String>,
pub release_status: Option<String>,
pub release_date: Option<chrono::NaiveDate>,
@@ -415,11 +418,14 @@ pub struct ReleaseRevNewRow {
pub wikidata_qid: Option<String>,
pub isbn13: Option<String>,
pub core_id: Option<String>,
+ pub arxiv_id: Option<String>,
+ pub jstor_id: Option<String>,
pub volume: Option<String>,
pub issue: Option<String>,
pub pages: Option<String>,
pub publisher: Option<String>,
pub language: Option<String>,
+ pub license_slug: Option<String>,
}
entity_structs!(
@@ -480,6 +486,7 @@ pub struct ReleaseContribRow {
pub creator_ident_id: Option<Uuid>,
pub raw_name: Option<String>,
pub role: Option<String>,
+ pub raw_affiliation: Option<String>,
pub index_val: Option<i32>,
pub extra_json: Option<serde_json::Value>,
}
@@ -491,6 +498,7 @@ pub struct ReleaseContribNewRow {
pub creator_ident_id: Option<Uuid>,
pub raw_name: Option<String>,
pub role: Option<String>,
+ pub raw_affiliation: Option<String>,
pub index_val: Option<i32>,
pub extra_json: Option<serde_json::Value>,
}
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<Jsonb>,
name -> Text,
+ container_type -> Nullable<Text>,
publisher -> Nullable<Text>,
issnl -> Nullable<Text>,
wikidata_qid -> Nullable<Text>,
- abbrev -> Nullable<Text>,
- coden -> Nullable<Text>,
}
}
@@ -252,6 +251,7 @@ table! {
creator_ident_id -> Nullable<Uuid>,
raw_name -> Nullable<Text>,
role -> Nullable<Text>,
+ raw_affiliation -> Nullable<Text>,
index_val -> Nullable<Int4>,
extra_json -> Nullable<Jsonb>,
}
@@ -295,6 +295,7 @@ table! {
container_ident_id -> Nullable<Uuid>,
refs_blob_sha1 -> Nullable<Text>,
title -> Text,
+ original_title -> Nullable<Text>,
release_type -> Nullable<Text>,
release_status -> Nullable<Text>,
release_date -> Nullable<Date>,
@@ -305,11 +306,14 @@ table! {
wikidata_qid -> Nullable<Text>,
isbn13 -> Nullable<Text>,
core_id -> Nullable<Text>,
+ arxiv_id -> Nullable<Text>,
+ jstor_id -> Nullable<Text>,
volume -> Nullable<Text>,
issue -> Nullable<Text>,
pages -> Nullable<Text>,
publisher -> Nullable<Text>,
language -> Nullable<Text>,
+ license_slug -> Nullable<Text>,
}
}
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::<Vec<ContainerRevNewRow>>(),
@@ -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(),
})
})