aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/entity_crud.rs
diff options
context:
space:
mode:
authorMartin Czygan <martin@archive.org>2020-11-24 19:29:07 +0000
committerMartin Czygan <martin@archive.org>2020-11-24 19:29:07 +0000
commitcfd13852d7cb58fcc3387373960adaf3680f0faf (patch)
tree675954b8b34324fe22fc5a00f3fbb99a21a77a21 /rust/src/entity_crud.rs
parentfcfcd3224a113fa90da2045a3c7fe90127088ebe (diff)
parent1fca5a9822944d0646d2dcba6cf54f27a0ffe5c0 (diff)
downloadfatcat-cfd13852d7cb58fcc3387373960adaf3680f0faf.tar.gz
fatcat-cfd13852d7cb58fcc3387373960adaf3680f0faf.zip
Merge branch 'bnewbold-doaj-metadata' into 'master'
DOAJ article metadata import See merge request webgroup/fatcat!89
Diffstat (limited to 'rust/src/entity_crud.rs')
-rw-r--r--rust/src/entity_crud.rs38
1 files changed, 35 insertions, 3 deletions
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index 83dd26c9..0d72788d 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -334,7 +334,9 @@ macro_rules! generic_db_create {
fn db_create(&self, conn: &DbConn, edit_context: &EditContext) -> Result<Self::EditRow> {
if self.redirect.is_some() {
return Err(FatcatError::BadRequest(
- "can't create an entity that redirects from the start".to_string()).into());
+ "can't create an entity that redirects from the start".to_string(),
+ )
+ .into());
}
let rev_id = self.db_insert_rev(conn)?;
let ident: Uuid = insert_into($ident_table::table)
@@ -351,7 +353,7 @@ macro_rules! generic_db_create {
.get_result(conn)?;
Ok(edit)
}
- }
+ };
}
macro_rules! generic_db_create_batch {
@@ -764,7 +766,7 @@ macro_rules! generic_db_insert_rev {
fn db_insert_rev(&self, conn: &DbConn) -> Result<Uuid> {
Self::db_insert_revs(conn, &[self]).map(|id_list| id_list[0])
}
- }
+ };
}
impl EntityCrud for ContainerEntity {
@@ -1742,6 +1744,9 @@ impl EntityCrud for ReleaseEntity {
jstor: None,
ark: None,
mag: None,
+ doaj: None,
+ dblp: None,
+ oai: None,
},
refs: None,
contribs: None,
@@ -2018,6 +2023,9 @@ impl EntityCrud for ReleaseEntity {
jstor: None,
ark: None,
mag: None,
+ doaj: None,
+ dblp: None,
+ oai: None,
};
let extid_rows: Vec<ReleaseExtidRow> = release_rev_extid::table
@@ -2030,6 +2038,9 @@ impl EntityCrud for ReleaseEntity {
"jstor" => ext_ids.jstor = Some(extid_row.value),
"ark" => ext_ids.ark = Some(extid_row.value),
"mag" => ext_ids.mag = Some(extid_row.value),
+ "doaj" => ext_ids.doaj = Some(extid_row.value),
+ "dblp" => ext_ids.dblp = Some(extid_row.value),
+ "oai" => ext_ids.oai = Some(extid_row.value),
_ => (),
}
}
@@ -2290,6 +2301,27 @@ impl EntityCrud for ReleaseEntity {
value: extid.clone(),
});
};
+ if let Some(extid) = &model.ext_ids.doaj {
+ release_extid_rows.push(ReleaseExtidRow {
+ release_rev: *rev_id,
+ extid_type: "doaj".to_string(),
+ value: extid.clone(),
+ });
+ };
+ if let Some(extid) = &model.ext_ids.dblp {
+ release_extid_rows.push(ReleaseExtidRow {
+ release_rev: *rev_id,
+ extid_type: "dblp".to_string(),
+ value: extid.clone(),
+ });
+ };
+ if let Some(extid) = &model.ext_ids.oai {
+ release_extid_rows.push(ReleaseExtidRow {
+ release_rev: *rev_id,
+ extid_type: "oai".to_string(),
+ value: extid.clone(),
+ });
+ };
}
for (model, rev_id) in models.iter().zip(rev_ids.iter()) {