Skip to content

Commit

Permalink
Merge pull request #986 from dbrandenstein/gfbio_collections_adjustments
Browse files Browse the repository at this point in the history
Gfbio collections adjustments
  • Loading branch information
michaelmattig authored Oct 22, 2024
2 parents 46a5336 + 6f516d3 commit 03ae4f3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
15 changes: 6 additions & 9 deletions services/src/datasets/external/gfbio_collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ pub struct CollectionResponse {
#[derive(Debug, Deserialize)]
pub struct CollectionEntry {
pub id: String,
#[serde(rename = "parentIdentifier")]
pub parent_identifier: String,
pub vat: bool,
pub datalink: Option<String>,
pub citation: CollectionEntryCitation,
Expand All @@ -133,7 +131,6 @@ pub struct CollectionEntry {
#[derive(Debug, Deserialize)]
pub struct CollectionEntryCitation {
pub title: String,
pub source: String,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -186,14 +183,14 @@ fn gfbio_dataset_identifier_to_dataset_unit(
dataset_identifier: &str,
) -> Result<(String, Option<String>)> {
// urn:gfbio.org:abcd:{dataset}:{unit} (unit is optional)
let id_parts: Vec<_> = dataset_identifier.split(':').collect();
let id_parts: Vec<_> = dataset_identifier.splitn(5, ':').collect();

Ok(match id_parts.as_slice() {
[_, _, _, dataset, unit] => (
["urn", "gfbio.org", "abcd", dataset, unit] => (
format!("urn:gfbio.org:abcd:{dataset}"),
Some((*unit).to_string()),
),
[_, _, _, dataset] => (format!("urn:gfbio.org:abcd:{dataset}"), None),
["urn", "gfbio.org", "abcd", dataset] => (format!("urn:gfbio.org:abcd:{dataset}"), None),
_ => return Err(crate::error::Error::InvalidLayerId),
})
}
Expand Down Expand Up @@ -370,9 +367,11 @@ impl GfbioCollectionsDataProvider {
collection: &str,
entry: CollectionEntry,
) -> Result<CollectionItem> {
let (dataset, unit) = gfbio_dataset_identifier_to_dataset_unit(&entry.id)?;

let status = if entry.vat {
let in_database = self
.get_surrogate_key_for_gfbio_dataset(&entry.parent_identifier)
.get_surrogate_key_for_gfbio_dataset(&dataset)
.await
.is_ok();

Expand All @@ -385,8 +384,6 @@ impl GfbioCollectionsDataProvider {
LayerStatus::Unavailable
};

let (dataset, unit) = gfbio_dataset_identifier_to_dataset_unit(&entry.id)?;

Ok(CollectionItem::Layer(LayerListing {
id: ProviderLayerId {
provider_id: GFBIO_COLLECTIONS_PROVIDER_ID,
Expand Down
Loading

0 comments on commit 03ae4f3

Please sign in to comment.