Skip to content

Commit

Permalink
Handle file sets that do not have a service url
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Nov 21, 2024
1 parent 4cbe89b commit 0985c9f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntry do
extract_service_url(member_data[id])
end

defp extract_service_url(_id, _) do
nil
end

# Find the derivative FileMetadata
defp extract_service_url(%{
"internal_resource" => "FileSet",
Expand Down Expand Up @@ -84,6 +80,10 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntry do
"https://iiif-cloud.princeton.edu/iiif/2/#{uuid_path}"
end

defp extract_service_url(nil), do: nil

defp extract_service_url(_id, _), do: nil

defp is_derivative(%{
"mime_type" => ["image/tiff"],
"use" => [%{"@id" => "http://pcdm.org/use#ServiceFile"}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntryTest do
"member_ids" => %{
"1" => %{
"internal_resource" => "FileSet",
"id" => "9ad621a7b-01ea-4895-9c3d-a8c6eaab4013",
"metadata" => %{
"file_metadata" => [
# Not this one - it's an old JP2
Expand Down Expand Up @@ -80,6 +81,46 @@ defmodule DpulCollections.IndexingPipeline.Figgy.HydrationCacheEntryTest do
]
end

test "can handle when members do not have the correct file metadata type" do
{:ok, entry} =
IndexingPipeline.write_hydration_cache_entry(%{
cache_version: 0,
record_id: "0cff895a-01ea-4895-9c3d-a8c6eaab4013",
source_cache_order: ~U[2018-03-09 20:19:35.465203Z],
related_data: %{
"member_ids" => %{
"1" => %{
"internal_resource" => "FileSet",
"id" => "9ad621a7b-01ea-4895-9c3d-a8c6eaab4013",
"metadata" => %{
"file_metadata" => [
# PDF member
%{
"id" => %{"id" => "0cff895a-01ea-4895-9c3d-a8c6eaab4017"},
"internal_resource" => "FileMetadata",
"mime_type" => ["application/pdf"],
"use" => [%{"@id" => "http://pcdm.org/use#ServiceFile"}]
}
]
}
}
}
},
data: %{
"id" => "0cff895a-01ea-4895-9c3d-a8c6eaab4013",
"internal_resource" => "EphemeraFolder",
"metadata" => %{
"member_ids" => [%{"id" => "1"}],
"title" => ["test title 4"]
}
}
})

doc = HydrationCacheEntry.to_solr_document(entry)

assert doc[:image_service_urls_ss] == []
end

test "includes date range if found, date if not" do
entries =
FiggyTestFixtures.hydration_cache_entries()
Expand Down

0 comments on commit 0985c9f

Please sign in to comment.