aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/entity_crud.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-10-12 19:56:08 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-10-13 16:21:30 -0700
commit11fdff350e0549d46a8a7b5e74451e08ce067cb2 (patch)
tree20f48fb619e4267bb066340e249acc14649ae3da /rust/src/entity_crud.rs
parent8d1f8d02f2e43c13d35b57ff3a625ab5de6c51c7 (diff)
downloadfatcat-11fdff350e0549d46a8a7b5e74451e08ce067cb2.tar.gz
fatcat-11fdff350e0549d46a8a7b5e74451e08ce067cb2.zip
rust: implement scheman and API changes
Diffstat (limited to 'rust/src/entity_crud.rs')
-rw-r--r--rust/src/entity_crud.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index b3b97c73..cbf9592b 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -797,10 +797,13 @@ impl EntityCrud for ContainerEntity {
Ok(ContainerEntity {
issnl: None,
+ issne: None,
+ issnp: None,
wikidata_qid: None,
publisher: None,
name: None,
container_type: None,
+ publication_status: 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()),
@@ -829,10 +832,13 @@ impl EntityCrud for ContainerEntity {
Ok(ContainerEntity {
issnl: rev_row.issnl,
+ issne: rev_row.issne,
+ issnp: rev_row.issnp,
wikidata_qid: rev_row.wikidata_qid,
publisher: rev_row.publisher,
name: Some(rev_row.name),
container_type: rev_row.container_type,
+ publication_status: rev_row.publication_status,
state,
ident: ident_id,
revision: Some(rev_row.id.to_string()),
@@ -851,6 +857,16 @@ impl EntityCrud for ContainerEntity {
if let Some(ref extid) = entity.issnl {
check_issn(extid)?;
}
+ if let Some(ref extid) = entity.issne {
+ check_issn(extid)?;
+ }
+ if let Some(ref extid) = entity.issnp {
+ check_issn(extid)?;
+ }
+
+ if let Some(ref status) = entity.publication_status {
+ check_publication_status(status)?;
+ }
}
if models.iter().any(|m| m.name.is_none()) {
@@ -868,8 +884,11 @@ impl EntityCrud for ContainerEntity {
name: model.name.clone().unwrap(), // unwrap checked above
publisher: model.publisher.clone(),
issnl: model.issnl.clone(),
+ issnp: model.issnp.clone(),
+ issne: model.issne.clone(),
wikidata_qid: model.wikidata_qid.clone(),
container_type: model.container_type.clone(),
+ publication_status: model.publication_status.clone(),
extra_json: model.extra.clone(),
})
.collect::<Vec<ContainerRevNewRow>>(),
@@ -1292,6 +1311,7 @@ impl EntityCrud for FilesetEntity {
md5: r.md5,
sha1: r.sha1,
sha256: r.sha256,
+ mimetype: r.mimetype,
extra: r.extra_json,
})
.collect();
@@ -1374,6 +1394,7 @@ impl EntityCrud for FilesetEntity {
md5: f.md5.clone(),
sha1: f.sha1.clone(),
sha256: f.sha256.clone(),
+ mimetype: f.mimetype.clone(),
extra_json: f.extra.clone(),
})
.collect();
@@ -1747,6 +1768,7 @@ impl EntityCrud for ReleaseEntity {
doaj: None,
dblp: None,
oai: None,
+ hdl: None,
},
refs: None,
contribs: None,
@@ -2026,6 +2048,7 @@ impl EntityCrud for ReleaseEntity {
doaj: None,
dblp: None,
oai: None,
+ hdl: None,
};
let extid_rows: Vec<ReleaseExtidRow> = release_rev_extid::table
@@ -2041,6 +2064,7 @@ impl EntityCrud for ReleaseEntity {
"doaj" => ext_ids.doaj = Some(extid_row.value),
"dblp" => ext_ids.dblp = Some(extid_row.value),
"oai" => ext_ids.oai = Some(extid_row.value),
+ "hdl" => ext_ids.hdl = Some(extid_row.value),
_ => (),
}
}
@@ -2128,6 +2152,9 @@ impl EntityCrud for ReleaseEntity {
if let Some(ref extid) = entity.ext_ids.oai {
check_oai_id(extid)?;
}
+ if let Some(ref extid) = entity.ext_ids.hdl {
+ check_hdl(extid)?;
+ }
if let Some(ref release_type) = entity.release_type {
check_release_type(release_type)?;
@@ -2335,6 +2362,13 @@ impl EntityCrud for ReleaseEntity {
value: extid.clone(),
});
};
+ if let Some(extid) = &model.ext_ids.hdl {
+ release_extid_rows.push(ReleaseExtidRow {
+ release_rev: *rev_id,
+ extid_type: "hdl".to_string(),
+ value: extid.to_lowercase(),
+ });
+ };
}
for (model, rev_id) in models.iter().zip(rev_ids.iter()) {