diff --git a/lib/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry.ex b/lib/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry.ex index a778ecef..88f60412 100644 --- a/lib/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry.ex +++ b/lib/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry.ex @@ -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", @@ -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"}] diff --git a/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs b/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs index acf646be..f17d9ee5 100644 --- a/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs +++ b/test/dpul_collections/indexing_pipeline/figgy/hydration_cache_entry_test.exs @@ -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 @@ -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()