From f041326a2bef8ffba7b5318f5b29cbf9e18ba5ea Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Fri, 20 Oct 2017 11:44:25 -0700 Subject: [PATCH] Index from Figgy. --- .rubocop.yml | 1 + app/indexers/plum_jsonld_converter.rb | 18 +- app/indexers/reindexer.rb | 8 +- .../plum_event_processor/create_processor.rb | 2 +- config/config.yml | 6 +- .../b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.json | 230 +++++++++++ ...9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld | 155 ++++++++ ...-baf2-45e4-b32c-5e5b3755c8ef.manifest.json | 367 ++++++++++++++++++ spec/fixtures/vcr_cassettes/reindexer.json | 261 ++++++++++++- spec/indexers/plum_jsonld_converter_spec.rb | 60 +-- spec/indexers/reindexer_spec.rb | 17 +- spec/rails_helper.rb | 1 + spec/services/plum_event_processor_spec.rb | 33 +- spec/support/stub_plum_catalog.rb | 48 +++ 14 files changed, 1133 insertions(+), 74 deletions(-) create mode 100644 spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.json create mode 100644 spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld create mode 100644 spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.manifest.json create mode 100644 spec/support/stub_plum_catalog.rb diff --git a/.rubocop.yml b/.rubocop.yml index 45c6fa85..bdf70b9f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,6 +26,7 @@ Metrics/MethodLength: Exclude: - 'db/migrate/**/*' - 'app/indexers/plum_jsonld_converter.rb' + - 'spec/support/stub_plum_catalog.rb' Metrics/ClassLength: Exclude: - 'app/indexers/plum_jsonld_converter.rb' diff --git a/app/indexers/plum_jsonld_converter.rb b/app/indexers/plum_jsonld_converter.rb index fb095a71..e5baeb3b 100644 --- a/app/indexers/plum_jsonld_converter.rb +++ b/app/indexers/plum_jsonld_converter.rb @@ -66,11 +66,7 @@ def date_modified end def project_label - collection["title"] - end - - def collection - json["memberOf"].find { |x| x["@id"].include?("collections") } || {} + "Latin American Ephemera" end def contributor @@ -90,11 +86,11 @@ def box_barcode end def box - json["memberOf"].find { |x| x["@id"].include?("boxes") } || [] + json["memberOf"].find { |x| x["box_number"].present? } || [] end def category - json["category"] + json["subject"].select { |x| x["in_scheme"].present? }.map { |x| x["in_scheme"]["pref_label"] } end def genre_pul_label @@ -122,11 +118,11 @@ def geo_subject_label end def height - json["height"] + Array.wrap(json["height"]).first end def width - json["width"] + Array.wrap(json["width"]).first end def language_label @@ -138,7 +134,7 @@ def publisher_display end def title_display - json["title"] + Array.wrap(json["title"]).first end def subject_label @@ -160,7 +156,7 @@ def lang_lookup def manifest @manifest ||= begin - open("#{json['@id']}/manifest") + open("#{json['@id'].gsub('catalog', 'concern/ephemera_folders')}/manifest") rescue OpenURI::HTTPError "{}" end diff --git a/app/indexers/reindexer.rb b/app/indexers/reindexer.rb index 17f3cfbb..b484cd7e 100644 --- a/app/indexers/reindexer.rb +++ b/app/indexers/reindexer.rb @@ -17,7 +17,7 @@ def solr end def url - "#{LAE.config['plum_url']}/catalog.json?f[human_readable_type_sim][]=Ephemera+Folder&f[member_of_collections_ssim][]=#{collection_name.tr(' ', '+')}" + "#{LAE.config['plum_url']}/catalog.json?f[human_readable_type_sim][]=Ephemera+Folder&f[ephemera_project_ssim][]=#{collection_name.tr(' ', '+')}" end class JSONLDPathBuilder @@ -27,11 +27,7 @@ def initialize(solr_doc) end def path - "#{LAE.config['plum_url']}/concern/#{model_name}/#{id}.jsonld" - end - - def model_name - solr_doc["has_model_ssim"].first.underscore.pluralize + "#{LAE.config['plum_url']}/catalog/#{id}.jsonld" end def id diff --git a/app/services/plum_event_processor/create_processor.rb b/app/services/plum_event_processor/create_processor.rb index f1a41ea3..64361807 100644 --- a/app/services/plum_event_processor/create_processor.rb +++ b/app/services/plum_event_processor/create_processor.rb @@ -9,7 +9,7 @@ def process end def jsonld_url - manifest_url.gsub("/manifest", ".jsonld") + manifest_url.gsub("/manifest", ".jsonld").gsub("concern/ephemera_folders", "catalog") end def json diff --git a/config/config.yml b/config/config.yml index 2a3c8ed8..b9fd10ba 100644 --- a/config/config.yml +++ b/config/config.yml @@ -1,20 +1,20 @@ --- development: - plum_url: "https://hydra-dev.princeton.edu" + plum_url: "https://figgy.princeton.edu" collection: slug: "lae" events: server: <%= ENV["LAE_RABBITMQ_URL"] || "amqp://localhost:5672" %> exchange: <%= ENV["LAE_RABBITMQ_EXCHANGE"] || "plum_events" %> test: - plum_url: "https://hydra-dev.princeton.edu" + plum_url: "https://figgy.princeton.edu" collection: slug: "lae" events: server: 'amqp://localhost:5672' exchange: 'plum_events' production: - plum_url: "https://plum.princeton.edu" + plum_url: "https://figgy.princeton.edu" collection: slug: "lae" events: diff --git a/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.json b/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.json new file mode 100644 index 00000000..4f70dcd4 --- /dev/null +++ b/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.json @@ -0,0 +1,230 @@ +{ + "id":"b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", + "join_id_ssi":"id-b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", + "created_at_dtsi":"2017-10-18T18:08:59Z", + "internal_resource_tsim":[ + "EphemeraFolder" + ], + "internal_resource_ssim":[ + "EphemeraFolder" + ], + "internal_resource_tesim":[ + "EphemeraFolder" + ], + "read_groups_tsim":[ + "public" + ], + "read_groups_ssim":[ + "public" + ], + "read_groups_tesim":[ + "public" + ], + "barcode_tsim":[ + "32101100069481" + ], + "barcode_ssim":[ + "32101100069481" + ], + "barcode_tesim":[ + "32101100069481" + ], + "folder_number_tsim":[ + "193" + ], + "folder_number_ssim":[ + "193" + ], + "folder_number_tesim":[ + "193" + ], + "title_tsim":[ + "Caripe. Jardín turístico de Monagas. " + ], + "title_ssim":[ + "Caripe. Jardín turístico de Monagas. " + ], + "title_tesim":[ + "Caripe. Jardín turístico de Monagas. " + ], + "sort_title_tsim":[ + "caripe. jardín turístico de monagas. " + ], + "sort_title_ssim":[ + "caripe. jardín turístico de monagas. " + ], + "sort_title_tesim":[ + "caripe. jardín turístico de monagas. " + ], + "language_tsim":[ + "id-1bb6e264-8b3a-452c-9bc5-10e1c4c98c3e" + ], + "language_ssim":[ + "id-1bb6e264-8b3a-452c-9bc5-10e1c4c98c3e" + ], + "language_tesim":[ + "id-1bb6e264-8b3a-452c-9bc5-10e1c4c98c3e" + ], + "genre_tsim":[ + "id-42754ac7-7723-4219-81eb-11085946fdca" + ], + "genre_ssim":[ + "id-42754ac7-7723-4219-81eb-11085946fdca" + ], + "genre_tesim":[ + "id-42754ac7-7723-4219-81eb-11085946fdca" + ], + "width_tsim":[ + "11" + ], + "width_ssim":[ + "11" + ], + "width_tesim":[ + "11" + ], + "height_tsim":[ + "25" + ], + "height_ssim":[ + "25" + ], + "height_tesim":[ + "25" + ], + "page_count_tsim":[ + "6" + ], + "page_count_ssim":[ + "6" + ], + "page_count_tesim":[ + "6" + ], + "rights_statement_tsim":[ + "uri-http://rightsstatements.org/vocab/CNE/1.0/" + ], + "rights_statement_ssim":[ + "uri-http://rightsstatements.org/vocab/CNE/1.0/" + ], + "rights_statement_tesim":[ + "uri-http://rightsstatements.org/vocab/CNE/1.0/" + ], + "contributor_tsim":[ + "Gobierno Bolivariano de Venezuela" + ], + "contributor_ssim":[ + "Gobierno Bolivariano de Venezuela" + ], + "contributor_tesim":[ + "Gobierno Bolivariano de Venezuela" + ], + "publisher_tsim":[ + "Alcaldía del Municipio Caripe" + ], + "publisher_ssim":[ + "Alcaldía del Municipio Caripe" + ], + "publisher_tesim":[ + "Alcaldía del Municipio Caripe" + ], + "geographic_origin_tsim":[ + "id-e36dd185-6875-4efd-a62d-81f01a700097" + ], + "geographic_origin_ssim":[ + "id-e36dd185-6875-4efd-a62d-81f01a700097" + ], + "geographic_origin_tesim":[ + "id-e36dd185-6875-4efd-a62d-81f01a700097" + ], + "subject_tsim":[ + "id-fb359d07-e82d-479b-b3b9-06dcaebebd9f", + "id-a51c7f0b-4203-4ae9-b063-3e03fac1832b" + ], + "subject_ssim":[ + "id-fb359d07-e82d-479b-b3b9-06dcaebebd9f", + "id-a51c7f0b-4203-4ae9-b063-3e03fac1832b" + ], + "subject_tesim":[ + "id-fb359d07-e82d-479b-b3b9-06dcaebebd9f", + "id-a51c7f0b-4203-4ae9-b063-3e03fac1832b" + ], + "geo_subject_tsim":[ + "id-e36dd185-6875-4efd-a62d-81f01a700097" + ], + "geo_subject_ssim":[ + "id-e36dd185-6875-4efd-a62d-81f01a700097" + ], + "geo_subject_tesim":[ + "id-e36dd185-6875-4efd-a62d-81f01a700097" + ], + "date_range_tsim":[ + "serialized-{\"internal_resource\":\"DateRange\",\"created_at\":null,\"updated_at\":null,\"id\":null,\"start\":[\"2004\"],\"end\":[\"2012\"]}" + ], + "viewing_hint_tsim":[ + "individuals" + ], + "viewing_hint_ssim":[ + "individuals" + ], + "viewing_hint_tesim":[ + "individuals" + ], + "visibility_tsim":[ + "open" + ], + "visibility_ssim":[ + "open" + ], + "visibility_tesim":[ + "open" + ], + "pdf_type_tsim":[ + "none" + ], + "pdf_type_ssim":[ + "none" + ], + "pdf_type_tesim":[ + "none" + ], + "local_identifier_tsim":[ + "3cff0" + ], + "local_identifier_ssim":[ + "3cff0" + ], + "local_identifier_tesim":[ + "3cff0" + ], + "state_tsim":[ + "needs_qa" + ], + "state_ssim":[ + "needs_qa" + ], + "state_tesim":[ + "needs_qa" + ], + "read_access_group_ssim":[ + "public" + ], + "display_subject_ssim":[ + "National parks and reserves", + "Advertising--Tourism", + "Environment and ecology", + "Tourism" + ], + "display_language_ssim":[ + "Spanish" + ], + "ephemera_project_ssim":[ + "Latin American Ephemera" + ], + "human_readable_type_ssim":[ + "Ephemera Folder" + ], + "updated_at_dtsi":"2017-10-19T21:01:54Z", + "timestamp":"2017-10-19T21:05:24.090Z", + "score":1.0 +} diff --git a/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld b/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld new file mode 100644 index 00000000..1c094816 --- /dev/null +++ b/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld @@ -0,0 +1,155 @@ +{ + "title":[ + "Caripe. Jardín turístico de Monagas. " + ], + "@context":"https://bibdata.princeton.edu/context.json", + "@id":"https://figgy.princeton.edu/catalog/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", + "edm_rights":{ + "@id":"http://rightsstatements.org/vocab/CNE/1.0/", + "@type":"dcterms:RightsStatement", + "pref_label":"Copyright Not Evaluated" + }, + "memberOf":[ + { + "@id":"https://figgy.princeton.edu/catalog/092e6344-cf18-4ce0-a797-b8578c457767", + "@type":"pcdm:Collection", + "barcode":"32101086454731", + "label":"Box 57", + "box_number":"57" + } + ], + "@type":"pcdm:Object", + "alternative":[ + + ], + "creator":[ + "Test Creator" + ], + "contributor":[ + "Gobierno Bolivariano de Venezuela" + ], + "publisher":[ + "Alcaldía del Municipio Caripe" + ], + "barcode":"32101086454731", + "label":"Folder 193", + "is_part_of":"Latin American Ephemera", + "coverage":[ + { + "@id":"https://figgy.princeton.edu/catalog/e36dd185-6875-4efd-a62d-81f01a700097", + "@type":"skos:Concept", + "pref_label":"Venezuela", + "in_scheme":{ + "@id":"https://figgy.princeton.edu/catalog/22597862-062b-4c91-a6ca-cd73a30aceb1", + "@type":"skos:ConceptScheme", + "pref_label":"LAE Areas" + }, + "exact_match":{ + "@id":"http://id.loc.gov/vocabulary/countries/ve" + } + } + ], + "dcterms_type":[ + { + "@id":"https://figgy.princeton.edu/catalog/42754ac7-7723-4219-81eb-11085946fdca", + "@type":"skos:Concept", + "pref_label":"Pamphlets", + "in_scheme":{ + "@id":"https://figgy.princeton.edu/catalog/e7771cb0-e5a9-4ef7-b7ea-8e2f9b103302", + "@type":"skos:ConceptScheme", + "pref_label":"LAE Genres" + }, + "exact_match":{ + "@id":"http://id.loc.gov/vocabulary/graphicMaterials/tgm007415" + } + } + ], + "origin_place":[ + { + "@id":"https://figgy.princeton.edu/catalog/e36dd185-6875-4efd-a62d-81f01a700097", + "@type":"skos:Concept", + "pref_label":"Venezuela", + "in_scheme":{ + "@id":"https://figgy.princeton.edu/catalog/22597862-062b-4c91-a6ca-cd73a30aceb1", + "@type":"skos:ConceptScheme", + "pref_label":"LAE Areas" + }, + "exact_match":{ + "@id":"http://id.loc.gov/vocabulary/countries/ve" + } + } + ], + "language":[ + { + "@id":"https://figgy.princeton.edu/catalog/1bb6e264-8b3a-452c-9bc5-10e1c4c98c3e", + "@type":"skos:Concept", + "pref_label":"Spanish", + "in_scheme":{ + "@id":"https://figgy.princeton.edu/catalog/f0608fb8-d182-437f-b489-8296dcb87678", + "@type":"skos:ConceptScheme", + "pref_label":"LAE Languages" + }, + "exact_match":{ + "@id":"http://id.loc.gov/vocabulary/iso639-1/es" + } + } + ], + "subject":[ + { + "@id":"https://figgy.princeton.edu/catalog/fb359d07-e82d-479b-b3b9-06dcaebebd9f", + "@type":"skos:Concept", + "pref_label":"National parks and reserves", + "in_scheme":{ + "@id":"https://figgy.princeton.edu/catalog/64275d5f-7148-4e3a-b836-084dff3977f0", + "@type":"skos:ConceptScheme", + "pref_label":"Environment and ecology" + }, + "exact_match":{ + "@id":"http://id.loc.gov/authorities/subjects/sh85090045" + } + }, + { + "@id":"https://figgy.princeton.edu/catalog/a51c7f0b-4203-4ae9-b063-3e03fac1832b", + "@type":"skos:Concept", + "pref_label":"Advertising--Tourism", + "in_scheme":{ + "@id":"https://figgy.princeton.edu/catalog/69d9e1d0-7cf2-49e7-9c28-ac03d6628b64", + "@type":"skos:ConceptScheme", + "pref_label":"Tourism" + }, + "exact_match":{ + "@id":"http://id.loc.gov/authorities/subjects/sh88000359" + } + } + ], + "category":[ + { + "@id":"https://figgy.princeton.edu/catalog/64275d5f-7148-4e3a-b836-084dff3977f0", + "@type":"skos:ConceptScheme", + "pref_label":"Environment and ecology" + }, + { + "@id":"https://figgy.princeton.edu/catalog/69d9e1d0-7cf2-49e7-9c28-ac03d6628b64", + "@type":"skos:ConceptScheme", + "pref_label":"Tourism" + } + ], + "description":[ + + ], + "source":null, + "related_url":null, + "height":[ + "25" + ], + "width":[ + "11" + ], + "sort_title":[ + "caripe. jardín turístico de monagas. " + ], + "page_count":"6", + "created":"10/18/17 06:08:59 PM UTC", + "modified":"10/19/17 09:05:24 PM UTC", + "folder_number":"193" +} diff --git a/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.manifest.json b/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.manifest.json new file mode 100644 index 00000000..56f3da09 --- /dev/null +++ b/spec/fixtures/files/plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.manifest.json @@ -0,0 +1,367 @@ +{ + "@context":"http://iiif.io/api/presentation/2/context.json", + "@type":"sc:Manifest", + "@id":"https://figgy.princeton.edu/concern/ephemera_folders/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef/manifest", + "label":"Caripe. Jardín turístico de Monagas. ", + "viewingHint":"individuals", + "metadata":[ + { + "label":"Created At", + "value":[ + "10/18/17 06:08:59 PM UTC" + ] + }, + { + "label":"Updated At", + "value":[ + "10/19/17 09:01:54 PM UTC" + ] + }, + { + "label":"Barcode", + "value":[ + "32101100069481" + ] + }, + { + "label":"Folder Number", + "value":[ + "193" + ] + }, + { + "label":"Title", + "value":[ + "Caripe. Jardín turístico de Monagas. " + ] + }, + { + "label":"Sort Title", + "value":[ + "caripe. jardín turístico de monagas. " + ] + }, + { + "label":"Language", + "value":[ + { + "internal_resource":"EphemeraTerm", + "created_at":"10/06/17 07:49:23 PM UTC", + "updated_at":"10/06/17 07:49:23 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"1bb6e264-8b3a-452c-9bc5-10e1c4c98c3e" + }, + "label":"Spanish", + "uri":"http://id.loc.gov/vocabulary/iso639-1/es", + "code":null, + "tgm_label":null, + "lcsh_label":null, + "member_of_vocabulary_id":[ + { + "id":"f0608fb8-d182-437f-b489-8296dcb87678" + } + ] + } + ] + }, + { + "label":"Genre", + "value":[ + { + "internal_resource":"EphemeraTerm", + "created_at":"10/06/17 07:51:01 PM UTC", + "updated_at":"10/06/17 07:51:01 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"42754ac7-7723-4219-81eb-11085946fdca" + }, + "label":"Pamphlets", + "uri":"http://id.loc.gov/vocabulary/graphicMaterials/tgm007415", + "code":null, + "tgm_label":null, + "lcsh_label":null, + "member_of_vocabulary_id":[ + { + "id":"e7771cb0-e5a9-4ef7-b7ea-8e2f9b103302" + } + ] + } + ] + }, + { + "label":"Width", + "value":[ + "11" + ] + }, + { + "label":"Height", + "value":[ + "25" + ] + }, + { + "label":"Page Count", + "value":[ + "6" + ] + }, + { + "label":"Contributor", + "value":[ + "Gobierno Bolivariano de Venezuela" + ] + }, + { + "label":"Publisher", + "value":[ + "Alcaldía del Municipio Caripe" + ] + }, + { + "label":"Geographic Origin", + "value":[ + { + "internal_resource":"EphemeraTerm", + "created_at":"10/06/17 07:50:14 PM UTC", + "updated_at":"10/06/17 07:50:14 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"e36dd185-6875-4efd-a62d-81f01a700097" + }, + "label":"Venezuela", + "uri":"http://id.loc.gov/vocabulary/countries/ve", + "code":null, + "tgm_label":null, + "lcsh_label":null, + "member_of_vocabulary_id":[ + { + "id":"22597862-062b-4c91-a6ca-cd73a30aceb1" + } + ] + } + ] + }, + { + "label":"Rendered Subject", + "value":[ + "\u003ca href=\"/?f%5Bdisplay_subject_ssim%5D%5B%5D=Environment+and+ecology\"\u003eEnvironment and ecology\u003c/a\u003e -- \u003ca href=\"/?f%5Bdisplay_subject_ssim%5D%5B%5D=National+parks+and+reserves\"\u003eNational parks and reserves\u003c/a\u003e", + "\u003ca href=\"/?f%5Bdisplay_subject_ssim%5D%5B%5D=Tourism\"\u003eTourism\u003c/a\u003e -- \u003ca href=\"/?f%5Bdisplay_subject_ssim%5D%5B%5D=Advertising--Tourism\"\u003eAdvertising--Tourism\u003c/a\u003e" + ] + }, + { + "label":"Geo Subject", + "value":[ + { + "internal_resource":"EphemeraTerm", + "created_at":"10/06/17 07:50:14 PM UTC", + "updated_at":"10/06/17 07:50:14 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"e36dd185-6875-4efd-a62d-81f01a700097" + }, + "label":"Venezuela", + "uri":"http://id.loc.gov/vocabulary/countries/ve", + "code":null, + "tgm_label":null, + "lcsh_label":null, + "member_of_vocabulary_id":[ + { + "id":"22597862-062b-4c91-a6ca-cd73a30aceb1" + } + ] + } + ] + }, + { + "label":"Rendered Date Range", + "value":[ + "2004-2012" + ] + }, + { + "label":"Subject", + "value":[ + { + "internal_resource":"EphemeraTerm", + "created_at":"10/06/17 07:48:36 PM UTC", + "updated_at":"10/06/17 07:48:36 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"fb359d07-e82d-479b-b3b9-06dcaebebd9f" + }, + "label":"National parks and reserves", + "uri":"http://id.loc.gov/authorities/subjects/sh85090045", + "code":null, + "tgm_label":null, + "lcsh_label":null, + "member_of_vocabulary_id":[ + { + "id":"64275d5f-7148-4e3a-b836-084dff3977f0" + } + ] + }, + { + "internal_resource":"EphemeraTerm", + "created_at":"10/06/17 07:48:38 PM UTC", + "updated_at":"10/06/17 07:48:38 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"a51c7f0b-4203-4ae9-b063-3e03fac1832b" + }, + "label":"Advertising--Tourism", + "uri":"http://id.loc.gov/authorities/subjects/sh88000359", + "code":null, + "tgm_label":null, + "lcsh_label":null, + "member_of_vocabulary_id":[ + { + "id":"69d9e1d0-7cf2-49e7-9c28-ac03d6628b64" + } + ] + } + ] + }, + { + "label":"Categories", + "value":[ + { + "internal_resource":"EphemeraVocabulary", + "created_at":"10/06/17 07:48:36 PM UTC", + "updated_at":"10/06/17 07:48:36 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"64275d5f-7148-4e3a-b836-084dff3977f0" + }, + "label":"Environment and ecology", + "uri":"https://plum.princeton.edu/ns/lAESubjects/environmentAndEcology", + "definition":null, + "member_of_vocabulary_id":[ + { + "id":"94ac8724-64e5-4f46-bbe1-991d6cdd438f" + } + ] + }, + { + "internal_resource":"EphemeraVocabulary", + "created_at":"10/06/17 07:48:38 PM UTC", + "updated_at":"10/06/17 07:48:38 PM UTC", + "read_groups":[ + + ], + "read_users":[ + + ], + "edit_users":[ + + ], + "edit_groups":[ + + ], + "id":{ + "id":"69d9e1d0-7cf2-49e7-9c28-ac03d6628b64" + }, + "label":"Tourism", + "uri":"https://plum.princeton.edu/ns/lAESubjects/tourism", + "definition":null, + "member_of_vocabulary_id":[ + { + "id":"94ac8724-64e5-4f46-bbe1-991d6cdd438f" + } + ] + } + ] + } + ], + "seeAlso":{ + "@id":"https://figgy.princeton.edu/catalog/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld", + "format":"application/ld+json" + }, + "thumbnail":{ + "@id":"https://libimages1.princeton.edu/loris/figgy_prod/c6%2Fb4%2Fbe%2Fc6b4beb0d65b4d979adcd74ceba30e92%2Fintermediate_file.jp2/full/!200,150/0/default.jpg", + "service":{ + "@context":"http://iiiif.io/api/image/2/context.json", + "@id":"https://libimages1.princeton.edu/loris/figgy_prod/c6%2Fb4%2Fbe%2Fc6b4beb0d65b4d979adcd74ceba30e92%2Fintermediate_file.jp2", + "profile":"http;//iiiif.io/api/image/2/level2.json" + } + }, + "license":"http://rightsstatements.org/vocab/CNE/1.0/" +} diff --git a/spec/fixtures/vcr_cassettes/reindexer.json b/spec/fixtures/vcr_cassettes/reindexer.json index bc441f69..a6b0930e 100644 --- a/spec/fixtures/vcr_cassettes/reindexer.json +++ b/spec/fixtures/vcr_cassettes/reindexer.json @@ -1 +1,260 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://hydra-dev.princeton.edu/catalog.json?f%5Bhuman_readable_type_sim%5D%5B0%5D=Ephemera%20Folder\u0026f%5Bmember_of_collections_ssim%5D%5B0%5D=Latin%20American%20Ephemera\u0026page=1","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"],"User-Agent":["Ruby"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Vary":["Accept"],"X-Xss-Protection":["1; mode=block"],"X-Request-Id":["612985b5-afb2-47f2-863e-d43a329b0215"],"Etag":["W/\"c94c01dd1bc9b69906cc1873eb05fee3\""],"X-Frame-Options":["SAMEORIGIN"],"X-Runtime":["0.121882"],"X-Content-Type-Options":["nosniff"],"Date":["Mon, 17 Jul 2017 23:14:45 GMT"],"Set-Cookie":["_aardvark_session=cCthY2ExQS9kMU5FNDB2NmJVWnRPdW9NMFMvbmNZWGlCWEl4Q3UxQ0tNd0NoVHZZdjl3RHpHV1dKNnM2eHNMWmhaQ0pLTElQQWxFM2gxWS9yeHpyYTBKdjBqd0M4YVBGdW5JMjhIM1YxZHp0ZjF4NSt0aFYvTXQ0OGczMkUxR0YtLW1UTVJPaGoxZE5TRnBablFMS3F0NWc9PQ%3D%3D--20cf8c5b4f11596fd86c9132367fc34441e6a75c; path=/; HttpOnly"],"X-Powered-By":["Phusion Passenger 5.1.5"],"Server":["nginx/1.10.3 + Phusion Passenger 5.1.5"]},"body":{"encoding":"UTF-8","string":"{\"response\":{\"docs\":[{\"system_create_dtsi\":\"2017-07-07T22:51:29Z\",\"system_modified_dtsi\":\"2017-07-07T23:07:32Z\",\"has_model_ssim\":[\"EphemeraFolder\"],\"id\":\"sx920fz824\",\"accessControl_ssim\":[\"7d356a92-ee39-4473-a891-617327bdbb33\"],\"hasRelatedMediaFragment_ssim\":[\"st722hc03g\"],\"hasRelatedImage_ssim\":[\"st722hc03g\"],\"depositor_ssim\":[\"tpend\"],\"depositor_tesim\":[\"tpend\"],\"title_tesim\":[\"Test Folder 1\"],\"date_uploaded_dtsi\":\"2017-07-07T22:51:29Z\",\"date_modified_dtsi\":\"2017-07-07T23:07:26Z\",\"isPartOf_ssim\":[\"admin_set/default\"],\"resource_type_tesim\":[\"186\"],\"creator_tesim\":[\"Test Creator\"],\"contributor_tesim\":[\"Test Contributor\"],\"rights_statement_tesim\":[\"http://rightsstatements.org/vocab/NKC/1.0/\"],\"publisher_tesim\":[\"Test Publisher\"],\"subject_tesim\":[\"278\"],\"language_tesim\":[\"149\"],\"barcode_ssim\":[\"00000000000000\"],\"barcode_tesim\":[\"00000000000000\"],\"folder_number_ssim\":[\"1\"],\"folder_number_tesim\":[\"1\"],\"width_ssim\":[\"10\"],\"width_tesim\":[\"10\"],\"height_ssim\":[\"10\"],\"height_tesim\":[\"10\"],\"page_count_ssim\":[\"50\"],\"page_count_tesim\":[\"50\"],\"sort_title_ssim\":[\"test folder 1\"],\"sort_title_tesim\":[\"test folder 1\"],\"alternative_title_ssim\":[\"Alternative Title\"],\"alternative_title_tesim\":[\"Alternative Title\"],\"series_ssim\":[\"Test Series\"],\"series_tesim\":[\"Test Series\"],\"geographic_origin_ssim\":[\"Spain\"],\"geographic_origin_tesim\":[\"Spain\"],\"genre_ssim\":[\"186\"],\"genre_tesim\":[\"186\"],\"geo_subject_ssim\":[\"Spain\"],\"geo_subject_tesim\":[\"Spain\"],\"alternative_ssim\":[\"Alternative Title\"],\"alternative_tesim\":[\"Alternative Title\"],\"thumbnail_path_ss\":\"/assets/work-ff055336041c3f7d310ad69109eda4a887b16ec501f35afc0a547c4adb97ee72.png\",\"suppressed_bsi\":false,\"actionable_workflow_roles_ssim\":[\"folder_works-admin\",\"folder_works-ephemera_editor\",\"folder_works-depositing\"],\"workflow_state_name_ssim\":[\"needs_qa\"],\"member_ids_ssim\":[\"st722hc03g\"],\"member_of_collections_ssim\":[\"Box Number 1\",\"Latin American Ephemera\"],\"member_of_collection_ids_ssim\":[\"s8623j062b\",\"s8w32r7521\"],\"file_set_ids_ssim\":[\"st722hc03g\"],\"admin_set_tesim\":[\"Default Admin Set\"],\"member_of_collection_slugs_ssim\":[\"lae2\"],\"box_id_ssim\":[\"s8623j062b\"],\"ephemera_project_id_ssim\":[\"1\"],\"ephemera_project_name_ssim\":[\"Latin American Ephemera\"],\"has_model_literals_ssim\":[\"EphemeraFolder\"],\"part_of_literals_ssim\":[\"{\\\"@id\\\":\\\"http://localhost:8080/fedora/rest/staging/ad/mi/n_/se/admin_set/default\\\"}\"],\"resource_type_literals_ssim\":[\"186\"],\"creator_literals_ssim\":[\"Test Creator\"],\"contributor_literals_ssim\":[\"Test Contributor\"],\"publisher_literals_ssim\":[\"Test Publisher\"],\"subject_literals_ssim\":[\"278\"],\"language_literals_ssim\":[\"149\"],\"alternative_literals_ssim\":[\"Alternative Title\"],\"barcode_literals_ssim\":[\"00000000000000\"],\"folder_number_literals_ssim\":[\"1\"],\"width_literals_ssim\":[\"10\"],\"height_literals_ssim\":[\"10\"],\"page_count_literals_ssim\":[\"50\"],\"alternative_title_literals_ssim\":[\"Alternative Title\"],\"series_literals_ssim\":[\"Test Series\"],\"geographic_origin_literals_ssim\":[\"Spain\"],\"genre_literals_ssim\":[\"186\"],\"geo_subject_literals_ssim\":[\"Spain\"],\"title_literals_ssim\":[\"Test Folder 1\"],\"human_readable_type_tesim\":[\"Ephemera Folder\"],\"read_access_group_ssim\":[\"public\"],\"edit_access_group_ssim\":[\"admin\",\"ephemera_editor\"],\"timestamp\":\"2017-07-07T23:07:40.189Z\",\"score\":1.125}],\"facets\":[{\"name\":\"human_readable_type_sim\",\"items\":[{\"value\":\"Ephemera Folder\",\"hits\":1,\"label\":\"Ephemera Folder\"}],\"label\":\"Human Readable Type Sim\"},{\"name\":\"subject_sim\",\"items\":[{\"value\":\"Agricultural development projects\",\"hits\":1,\"label\":\"Agricultural development projects\"}],\"label\":\"Subject Sim\"},{\"name\":\"language_sim\",\"items\":[{\"value\":\"Spanish\",\"hits\":1,\"label\":\"Spanish\"}],\"label\":\"Language Sim\"},{\"name\":\"based_near_sim\",\"items\":[],\"label\":\"Based Near Sim\"},{\"name\":\"file_format_sim\",\"items\":[],\"label\":\"File Format Sim\"},{\"name\":\"generic_type_sim\",\"items\":[{\"value\":\"Work\",\"hits\":1,\"label\":\"Work\"}],\"label\":\"Generic Type Sim\"},{\"name\":\"member_of_collections_ssim\",\"items\":[{\"value\":\"Box Number 1\",\"hits\":1,\"label\":\"Box Number 1\"},{\"value\":\"Latin American Ephemera\",\"hits\":1,\"label\":\"Latin American Ephemera\"}],\"label\":\"Collection\"}],\"pages\":{\"current_page\":1,\"next_page\":null,\"prev_page\":null,\"total_pages\":1,\"limit_value\":10,\"offset_value\":0,\"total_count\":1,\"first_page?\":true,\"last_page?\":true}}}"},"http_version":null},"recorded_at":"Mon, 17 Jul 2017 23:14:45 GMT"},{"request":{"method":"get","uri":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824.jsonld","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"],"User-Agent":["Ruby"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Content-Type":["application/ld+json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Vary":["Accept"],"X-Xss-Protection":["1; mode=block"],"X-Request-Id":["aee67f22-5c7f-49f1-8966-c1c1a8c5666f"],"Etag":["W/\"800eae32c45815ff90cba90e90d8dd33\""],"X-Frame-Options":["SAMEORIGIN"],"X-Runtime":["0.187817"],"X-Content-Type-Options":["nosniff"],"Date":["Mon, 17 Jul 2017 23:14:46 GMT"],"X-Powered-By":["Phusion Passenger 5.1.5"],"Server":["nginx/1.10.3 + Phusion Passenger 5.1.5"]},"body":{"encoding":"UTF-8","string":"{\"title\":\"Test Folder 1\",\"@context\":\"https://bibdata.princeton.edu/context.json\",\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824\",\"memberOf\":[{\"@id\":\"/concern/ephemera_boxes/s8623j062b\",\"@type\":\"pcdm:Collection\",\"barcode\":\"00000000000000\",\"label\":\"Box 1\",\"holding_location\":\"rcpxr\"},{\"@id\":\"https://hydra-dev.princeton.edu/collections/s8w32r7521\",\"@type\":\"pcdm:Collection\",\"title\":\"Latin American Ephemera\"}],\"edm_rights\":{\"@id\":\"http://rightsstatements.org/vocab/NKC/1.0/\",\"@type\":\"dcterms:RightsStatement\",\"pref_label\":\"No Known Copyright\"},\"@type\":\"pcdm:Object\",\"alternative\":[\"Alternative Title\"],\"creator\":[\"Test Creator\"],\"contributor\":[\"Test Contributor\"],\"publisher\":[\"Test Publisher\"],\"barcode\":\"00000000000000\",\"label\":\"Folder 1\",\"is_part_of\":\"Latin American Ephemera\",\"coverage\":[\"Spain\"],\"dcterms_type\":[{\"@id\":\"https://hydra-dev.princeton.edu/vocabulary_terms/186\",\"@type\":\"skos:Concept\",\"pref_label\":\"Banners\",\"exact_match\":{\"@id\":\"http://id.loc.gov/vocabulary/graphicMaterials/tgm000777\"}}],\"origin_place\":[\"Spain\"],\"language\":[{\"@id\":\"https://hydra-dev.princeton.edu/vocabulary_terms/149\",\"@type\":\"skos:Concept\",\"pref_label\":\"Spanish\",\"exact_match\":{\"@id\":\"http://id.loc.gov/vocabulary/iso639-1/es\"}}],\"subject\":[{\"@id\":\"https://hydra-dev.princeton.edu/vocabulary_terms/278\",\"@type\":\"skos:Concept\",\"pref_label\":\"Agricultural development projects\",\"exact_match\":{\"@id\":\"http://id.loc.gov/authorities/subjects/sh85002306\"}}],\"category\":[\"Agrarian and rural issues\"],\"description\":[],\"source\":{\"@id\":null},\"related_url\":{\"@id\":null},\"height\":\"10\",\"width\":\"10\",\"sort_title\":[\"test folder 1\"],\"page_count\":\"50\",\"created\":\"07/07/17 10:51:29 PM UTC\",\"modified\":\"07/07/17 11:07:26 PM UTC\"}"},"http_version":null},"recorded_at":"Mon, 17 Jul 2017 23:14:46 GMT"},{"request":{"method":"get","uri":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"],"User-Agent":["Ruby"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Vary":["Accept"],"X-Xss-Protection":["1; mode=block"],"X-Request-Id":["ffa29511-3bec-4091-8ea5-1d1e1568eb31"],"Etag":["W/\"6e28ea0d85c4f088662554a46a7762ae\""],"X-Frame-Options":["SAMEORIGIN"],"X-Runtime":["0.059051"],"X-Content-Type-Options":["nosniff"],"Date":["Mon, 17 Jul 2017 23:14:46 GMT"],"X-Powered-By":["Phusion Passenger 5.1.5"],"Server":["nginx/1.10.3 + Phusion Passenger 5.1.5"],"Access-Control-Allow-Origin":["*"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Methods":["GET, POST, OPTIONS"],"Access-Control-Allow-Headers":["DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Origin"]},"body":{"encoding":"UTF-8","string":"{\"@context\":\"http://iiif.io/api/presentation/2/context.json\",\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest\",\"@type\":\"sc:Manifest\",\"label\":[\"Test Folder 1\"],\"viewingHint\":\"individuals\",\"viewingDirection\":\"left-to-right\",\"sequences\":[{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/sequence/normal\",\"@type\":\"sc:Sequence\",\"canvases\":[{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/canvas/st722hc03g\",\"@type\":\"sc:Canvas\",\"label\":\"color-landscape.tif\",\"images\":[{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/annotation/st722hc03g-image\",\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2/full/!600,600/0/default.jpg\",\"@type\":\"dctypes:Image\",\"format\":\"image/jpeg\",\"width\":287,\"height\":200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}},\"on\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/canvas/st722hc03g\"}],\"width\":287,\"height\":200}],\"viewingHint\":\"individuals\"}],\"metadata\":[{\"label\":\"Creator\",\"value\":[\"Test Creator\"]},{\"label\":\"Contributors\",\"value\":[\"Test Contributor\"]},{\"label\":\"Published/Created\",\"value\":[\"Test Publisher\"]},{\"label\":\"Subject\",\"value\":[\"278\"]},{\"label\":\"Language\",\"value\":[\"149\"]},{\"label\":\"Alternative title\",\"value\":[\"Alternative Title\"]},{\"label\":\"Barcode\",\"value\":\"00000000000000\"},{\"label\":\"Folder number\",\"value\":\"1\"},{\"label\":\"Page count\",\"value\":[\"50\"]},{\"label\":\"Geographic origin\",\"value\":[\"Spain\"]},{\"label\":\"Genre\",\"value\":[\"Banners\"]},{\"label\":\"Geo subject\",\"value\":[\"Spain\"]},{\"label\":\"Collection\",\"value\":[\"Box Number 1\",\"Latin American Ephemera\"]}],\"thumbnail\":{\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2/full/!200,150/0/default.jpg\",\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}},\"seeAlso\":{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824.jsonld\",\"format\":\"application/ld+json\"}}"},"http_version":null},"recorded_at":"Mon, 17 Jul 2017 23:14:46 GMT"}],"recorded_with":"VCR 2.9.3"} \ No newline at end of file +{ + "http_interactions":[ + { + "request":{ + "method":"get", + "uri":"https://hydra-dev.princeton.edu/catalog.json?f%5Bhuman_readable_type_sim%5D%5B0%5D=Ephemera%20Folder\u0026f%5Bmember_of_collections_ssim%5D%5B0%5D=Latin%20American%20Ephemera\u0026page=1", + "body":{ + "encoding":"US-ASCII", + "string":"" + }, + "headers":{ + "Accept-Encoding":[ + "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + ], + "Accept":[ + "*/*" + ], + "User-Agent":[ + "Ruby" + ] + } + }, + "response":{ + "status":{ + "code":200, + "message":"OK" + }, + "headers":{ + "Content-Type":[ + "application/json; charset=utf-8" + ], + "Transfer-Encoding":[ + "chunked" + ], + "Connection":[ + "keep-alive" + ], + "Status":[ + "200 OK" + ], + "Cache-Control":[ + "max-age=0, private, must-revalidate" + ], + "Vary":[ + "Accept" + ], + "X-Xss-Protection":[ + "1; mode=block" + ], + "X-Request-Id":[ + "612985b5-afb2-47f2-863e-d43a329b0215" + ], + "Etag":[ + "W/\"c94c01dd1bc9b69906cc1873eb05fee3\"" + ], + "X-Frame-Options":[ + "SAMEORIGIN" + ], + "X-Runtime":[ + "0.121882" + ], + "X-Content-Type-Options":[ + "nosniff" + ], + "Date":[ + "Mon, 17 Jul 2017 23:14:45 GMT" + ], + "Set-Cookie":[ + "_aardvark_session=cCthY2ExQS9kMU5FNDB2NmJVWnRPdW9NMFMvbmNZWGlCWEl4Q3UxQ0tNd0NoVHZZdjl3RHpHV1dKNnM2eHNMWmhaQ0pLTElQQWxFM2gxWS9yeHpyYTBKdjBqd0M4YVBGdW5JMjhIM1YxZHp0ZjF4NSt0aFYvTXQ0OGczMkUxR0YtLW1UTVJPaGoxZE5TRnBablFMS3F0NWc9PQ%3D%3D--20cf8c5b4f11596fd86c9132367fc34441e6a75c; path=/; HttpOnly" + ], + "X-Powered-By":[ + "Phusion Passenger 5.1.5" + ], + "Server":[ + "nginx/1.10.3 + Phusion Passenger 5.1.5" + ] + }, + "body":{ + "encoding":"UTF-8", + "string":"{\"response\":{\"docs\":[{\"system_create_dtsi\":\"2017-07-07T22:51:29Z\",\"system_modified_dtsi\":\"2017-07-07T23:07:32Z\",\"has_model_ssim\":[\"EphemeraFolder\"],\"id\":\"sx920fz824\",\"accessControl_ssim\":[\"7d356a92-ee39-4473-a891-617327bdbb33\"],\"hasRelatedMediaFragment_ssim\":[\"st722hc03g\"],\"hasRelatedImage_ssim\":[\"st722hc03g\"],\"depositor_ssim\":[\"tpend\"],\"depositor_tesim\":[\"tpend\"],\"title_tesim\":[\"Test Folder 1\"],\"date_uploaded_dtsi\":\"2017-07-07T22:51:29Z\",\"date_modified_dtsi\":\"2017-07-07T23:07:26Z\",\"isPartOf_ssim\":[\"admin_set/default\"],\"resource_type_tesim\":[\"186\"],\"creator_tesim\":[\"Test Creator\"],\"contributor_tesim\":[\"Test Contributor\"],\"rights_statement_tesim\":[\"http://rightsstatements.org/vocab/NKC/1.0/\"],\"publisher_tesim\":[\"Test Publisher\"],\"subject_tesim\":[\"278\"],\"language_tesim\":[\"149\"],\"barcode_ssim\":[\"00000000000000\"],\"barcode_tesim\":[\"00000000000000\"],\"folder_number_ssim\":[\"1\"],\"folder_number_tesim\":[\"1\"],\"width_ssim\":[\"10\"],\"width_tesim\":[\"10\"],\"height_ssim\":[\"10\"],\"height_tesim\":[\"10\"],\"page_count_ssim\":[\"50\"],\"page_count_tesim\":[\"50\"],\"sort_title_ssim\":[\"test folder 1\"],\"sort_title_tesim\":[\"test folder 1\"],\"alternative_title_ssim\":[\"Alternative Title\"],\"alternative_title_tesim\":[\"Alternative Title\"],\"series_ssim\":[\"Test Series\"],\"series_tesim\":[\"Test Series\"],\"geographic_origin_ssim\":[\"Spain\"],\"geographic_origin_tesim\":[\"Spain\"],\"genre_ssim\":[\"186\"],\"genre_tesim\":[\"186\"],\"geo_subject_ssim\":[\"Spain\"],\"geo_subject_tesim\":[\"Spain\"],\"alternative_ssim\":[\"Alternative Title\"],\"alternative_tesim\":[\"Alternative Title\"],\"thumbnail_path_ss\":\"/assets/work-ff055336041c3f7d310ad69109eda4a887b16ec501f35afc0a547c4adb97ee72.png\",\"suppressed_bsi\":false,\"actionable_workflow_roles_ssim\":[\"folder_works-admin\",\"folder_works-ephemera_editor\",\"folder_works-depositing\"],\"workflow_state_name_ssim\":[\"needs_qa\"],\"member_ids_ssim\":[\"st722hc03g\"],\"member_of_collections_ssim\":[\"Box Number 1\",\"Latin American Ephemera\"],\"member_of_collection_ids_ssim\":[\"s8623j062b\",\"s8w32r7521\"],\"file_set_ids_ssim\":[\"st722hc03g\"],\"admin_set_tesim\":[\"Default Admin Set\"],\"member_of_collection_slugs_ssim\":[\"lae2\"],\"box_id_ssim\":[\"s8623j062b\"],\"ephemera_project_id_ssim\":[\"1\"],\"ephemera_project_name_ssim\":[\"Latin American Ephemera\"],\"has_model_literals_ssim\":[\"EphemeraFolder\"],\"part_of_literals_ssim\":[\"{\\\"@id\\\":\\\"http://localhost:8080/fedora/rest/staging/ad/mi/n_/se/admin_set/default\\\"}\"],\"resource_type_literals_ssim\":[\"186\"],\"creator_literals_ssim\":[\"Test Creator\"],\"contributor_literals_ssim\":[\"Test Contributor\"],\"publisher_literals_ssim\":[\"Test Publisher\"],\"subject_literals_ssim\":[\"278\"],\"language_literals_ssim\":[\"149\"],\"alternative_literals_ssim\":[\"Alternative Title\"],\"barcode_literals_ssim\":[\"00000000000000\"],\"folder_number_literals_ssim\":[\"1\"],\"width_literals_ssim\":[\"10\"],\"height_literals_ssim\":[\"10\"],\"page_count_literals_ssim\":[\"50\"],\"alternative_title_literals_ssim\":[\"Alternative Title\"],\"series_literals_ssim\":[\"Test Series\"],\"geographic_origin_literals_ssim\":[\"Spain\"],\"genre_literals_ssim\":[\"186\"],\"geo_subject_literals_ssim\":[\"Spain\"],\"title_literals_ssim\":[\"Test Folder 1\"],\"human_readable_type_tesim\":[\"Ephemera Folder\"],\"read_access_group_ssim\":[\"public\"],\"edit_access_group_ssim\":[\"admin\",\"ephemera_editor\"],\"timestamp\":\"2017-07-07T23:07:40.189Z\",\"score\":1.125}],\"facets\":[{\"name\":\"human_readable_type_sim\",\"items\":[{\"value\":\"Ephemera Folder\",\"hits\":1,\"label\":\"Ephemera Folder\"}],\"label\":\"Human Readable Type Sim\"},{\"name\":\"subject_sim\",\"items\":[{\"value\":\"Agricultural development projects\",\"hits\":1,\"label\":\"Agricultural development projects\"}],\"label\":\"Subject Sim\"},{\"name\":\"language_sim\",\"items\":[{\"value\":\"Spanish\",\"hits\":1,\"label\":\"Spanish\"}],\"label\":\"Language Sim\"},{\"name\":\"based_near_sim\",\"items\":[],\"label\":\"Based Near Sim\"},{\"name\":\"file_format_sim\",\"items\":[],\"label\":\"File Format Sim\"},{\"name\":\"generic_type_sim\",\"items\":[{\"value\":\"Work\",\"hits\":1,\"label\":\"Work\"}],\"label\":\"Generic Type Sim\"},{\"name\":\"member_of_collections_ssim\",\"items\":[{\"value\":\"Box Number 1\",\"hits\":1,\"label\":\"Box Number 1\"},{\"value\":\"Latin American Ephemera\",\"hits\":1,\"label\":\"Latin American Ephemera\"}],\"label\":\"Collection\"}],\"pages\":{\"current_page\":1,\"next_page\":null,\"prev_page\":null,\"total_pages\":1,\"limit_value\":10,\"offset_value\":0,\"total_count\":1,\"first_page?\":true,\"last_page?\":true}}}" + }, + "http_version":null + }, + "recorded_at":"Mon, 17 Jul 2017 23:14:45 GMT" + }, + { + "request":{ + "method":"get", + "uri":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824.jsonld", + "body":{ + "encoding":"US-ASCII", + "string":"" + }, + "headers":{ + "Accept-Encoding":[ + "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + ], + "Accept":[ + "*/*" + ], + "User-Agent":[ + "Ruby" + ] + } + }, + "response":{ + "status":{ + "code":200, + "message":"OK" + }, + "headers":{ + "Content-Type":[ + "application/ld+json; charset=utf-8" + ], + "Transfer-Encoding":[ + "chunked" + ], + "Connection":[ + "keep-alive" + ], + "Status":[ + "200 OK" + ], + "Cache-Control":[ + "max-age=0, private, must-revalidate" + ], + "Vary":[ + "Accept" + ], + "X-Xss-Protection":[ + "1; mode=block" + ], + "X-Request-Id":[ + "aee67f22-5c7f-49f1-8966-c1c1a8c5666f" + ], + "Etag":[ + "W/\"800eae32c45815ff90cba90e90d8dd33\"" + ], + "X-Frame-Options":[ + "SAMEORIGIN" + ], + "X-Runtime":[ + "0.187817" + ], + "X-Content-Type-Options":[ + "nosniff" + ], + "Date":[ + "Mon, 17 Jul 2017 23:14:46 GMT" + ], + "X-Powered-By":[ + "Phusion Passenger 5.1.5" + ], + "Server":[ + "nginx/1.10.3 + Phusion Passenger 5.1.5" + ] + }, + "body":{ + "encoding":"UTF-8", + "string":"{\"title\":\"Test Folder 1\",\"@context\":\"https://bibdata.princeton.edu/context.json\",\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824\",\"memberOf\":[{\"@id\":\"/concern/ephemera_boxes/s8623j062b\",\"@type\":\"pcdm:Collection\",\"barcode\":\"00000000000000\",\"label\":\"Box 1\",\"holding_location\":\"rcpxr\"},{\"@id\":\"https://hydra-dev.princeton.edu/collections/s8w32r7521\",\"@type\":\"pcdm:Collection\",\"title\":\"Latin American Ephemera\"}],\"edm_rights\":{\"@id\":\"http://rightsstatements.org/vocab/NKC/1.0/\",\"@type\":\"dcterms:RightsStatement\",\"pref_label\":\"No Known Copyright\"},\"@type\":\"pcdm:Object\",\"alternative\":[\"Alternative Title\"],\"creator\":[\"Test Creator\"],\"contributor\":[\"Test Contributor\"],\"publisher\":[\"Test Publisher\"],\"barcode\":\"00000000000000\",\"label\":\"Folder 1\",\"is_part_of\":\"Latin American Ephemera\",\"coverage\":[\"Spain\"],\"dcterms_type\":[{\"@id\":\"https://hydra-dev.princeton.edu/vocabulary_terms/186\",\"@type\":\"skos:Concept\",\"pref_label\":\"Banners\",\"exact_match\":{\"@id\":\"http://id.loc.gov/vocabulary/graphicMaterials/tgm000777\"}}],\"origin_place\":[\"Spain\"],\"language\":[{\"@id\":\"https://hydra-dev.princeton.edu/vocabulary_terms/149\",\"@type\":\"skos:Concept\",\"pref_label\":\"Spanish\",\"exact_match\":{\"@id\":\"http://id.loc.gov/vocabulary/iso639-1/es\"}}],\"subject\":[{\"@id\":\"https://hydra-dev.princeton.edu/vocabulary_terms/278\",\"@type\":\"skos:Concept\",\"pref_label\":\"Agricultural development projects\",\"exact_match\":{\"@id\":\"http://id.loc.gov/authorities/subjects/sh85002306\"}}],\"category\":[\"Agrarian and rural issues\"],\"description\":[],\"source\":{\"@id\":null},\"related_url\":{\"@id\":null},\"height\":\"10\",\"width\":\"10\",\"sort_title\":[\"test folder 1\"],\"page_count\":\"50\",\"created\":\"07/07/17 10:51:29 PM UTC\",\"modified\":\"07/07/17 11:07:26 PM UTC\"}" + }, + "http_version":null + }, + "recorded_at":"Mon, 17 Jul 2017 23:14:46 GMT" + }, + { + "request":{ + "method":"get", + "uri":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest", + "body":{ + "encoding":"US-ASCII", + "string":"" + }, + "headers":{ + "Accept-Encoding":[ + "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + ], + "Accept":[ + "*/*" + ], + "User-Agent":[ + "Ruby" + ] + } + }, + "response":{ + "status":{ + "code":200, + "message":"OK" + }, + "headers":{ + "Content-Type":[ + "application/json; charset=utf-8" + ], + "Transfer-Encoding":[ + "chunked" + ], + "Connection":[ + "keep-alive" + ], + "Status":[ + "200 OK" + ], + "Cache-Control":[ + "max-age=0, private, must-revalidate" + ], + "Vary":[ + "Accept" + ], + "X-Xss-Protection":[ + "1; mode=block" + ], + "X-Request-Id":[ + "ffa29511-3bec-4091-8ea5-1d1e1568eb31" + ], + "Etag":[ + "W/\"6e28ea0d85c4f088662554a46a7762ae\"" + ], + "X-Frame-Options":[ + "SAMEORIGIN" + ], + "X-Runtime":[ + "0.059051" + ], + "X-Content-Type-Options":[ + "nosniff" + ], + "Date":[ + "Mon, 17 Jul 2017 23:14:46 GMT" + ], + "X-Powered-By":[ + "Phusion Passenger 5.1.5" + ], + "Server":[ + "nginx/1.10.3 + Phusion Passenger 5.1.5" + ], + "Access-Control-Allow-Origin":[ + "*" + ], + "Access-Control-Allow-Credentials":[ + "true" + ], + "Access-Control-Allow-Methods":[ + "GET, POST, OPTIONS" + ], + "Access-Control-Allow-Headers":[ + "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Origin" + ] + }, + "body":{ + "encoding":"UTF-8", + "string":"{\"@context\":\"http://iiif.io/api/presentation/2/context.json\",\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest\",\"@type\":\"sc:Manifest\",\"label\":[\"Test Folder 1\"],\"viewingHint\":\"individuals\",\"viewingDirection\":\"left-to-right\",\"sequences\":[{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/sequence/normal\",\"@type\":\"sc:Sequence\",\"canvases\":[{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/canvas/st722hc03g\",\"@type\":\"sc:Canvas\",\"label\":\"color-landscape.tif\",\"images\":[{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/annotation/st722hc03g-image\",\"@type\":\"oa:Annotation\",\"motivation\":\"sc:painting\",\"resource\":{\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2/full/!600,600/0/default.jpg\",\"@type\":\"dctypes:Image\",\"format\":\"image/jpeg\",\"width\":287,\"height\":200,\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}},\"on\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/canvas/st722hc03g\"}],\"width\":287,\"height\":200}],\"viewingHint\":\"individuals\"}],\"metadata\":[{\"label\":\"Creator\",\"value\":[\"Test Creator\"]},{\"label\":\"Contributors\",\"value\":[\"Test Contributor\"]},{\"label\":\"Published/Created\",\"value\":[\"Test Publisher\"]},{\"label\":\"Subject\",\"value\":[\"278\"]},{\"label\":\"Language\",\"value\":[\"149\"]},{\"label\":\"Alternative title\",\"value\":[\"Alternative Title\"]},{\"label\":\"Barcode\",\"value\":\"00000000000000\"},{\"label\":\"Folder number\",\"value\":\"1\"},{\"label\":\"Page count\",\"value\":[\"50\"]},{\"label\":\"Geographic origin\",\"value\":[\"Spain\"]},{\"label\":\"Genre\",\"value\":[\"Banners\"]},{\"label\":\"Geo subject\",\"value\":[\"Spain\"]},{\"label\":\"Collection\",\"value\":[\"Box Number 1\",\"Latin American Ephemera\"]}],\"thumbnail\":{\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2/full/!200,150/0/default.jpg\",\"service\":{\"@context\":\"http://iiif.io/api/image/2/context.json\",\"@id\":\"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2\",\"profile\":\"http://iiif.io/api/image/2/level2.json\"}},\"seeAlso\":{\"@id\":\"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824.jsonld\",\"format\":\"application/ld+json\"}}" + }, + "http_version":null + }, + "recorded_at":"Mon, 17 Jul 2017 23:14:46 GMT" + } + ], + "recorded_with":"VCR 2.9.3" +} diff --git a/spec/indexers/plum_jsonld_converter_spec.rb b/spec/indexers/plum_jsonld_converter_spec.rb index 0eebd07e..3e2a1f79 100644 --- a/spec/indexers/plum_jsonld_converter_spec.rb +++ b/spec/indexers/plum_jsonld_converter_spec.rb @@ -3,49 +3,49 @@ RSpec.describe PlumJsonldConverter do subject(:converter) { described_class.new(jsonld: jsonld) } - let(:jsonld) do - '{"title":"Test Folder 1","@context":"https://bibdata.princeton.edu/context.json","@id":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824","memberOf":[{"@id":"/concern/ephemera_boxes/s8623j062b","@type":"pcdm:Collection","barcode":"00000000000000","label":"Box 1","holding_location":"rcpxr","box_number":"1"},{"@id":"https://hydra-dev.princeton.edu/collections/s8w32r7521","@type":"pcdm:Collection","title":"Latin American Ephemera"}],"edm_rights":{"@id":"http://rightsstatements.org/vocab/NKC/1.0/","@type":"dcterms:RightsStatement","pref_label":"No Known Copyright"},"@type":"pcdm:Object","alternative":["Alternative Title"],"creator":["Test Creator"],"contributor":["Test Contributor"],"publisher":["Test Publisher"],"barcode":"00000000000000","label":"Folder 1","is_part_of":"Latin American Ephemera","coverage":["Spain"],"dcterms_type":[{"@id":"https://hydra-dev.princeton.edu/vocabulary_terms/186","@type":"skos:Concept","pref_label":"Banners","exact_match":{"@id":"http://id.loc.gov/vocabulary/graphicMaterials/tgm000777"}}],"origin_place":["Spain"],"language":[{"@id":"https://hydra-dev.princeton.edu/vocabulary_terms/149","@type":"skos:Concept","pref_label":"Spanish","exact_match":{"@id":"http://id.loc.gov/vocabulary/iso639-1/es"}}],"subject":[{"@id":"https://hydra-dev.princeton.edu/vocabulary_terms/278","@type":"skos:Concept","pref_label":"Agricultural development projects","exact_match":{"@id":"http://id.loc.gov/authorities/subjects/sh85002306"}}],"category":["Agrarian and rural issues"],"description":[],"source":{"@id":null},"related_url":{"@id":null},"height":"10","width":"10","sort_title":["test folder 1"],"page_count":"50","created":"07/07/17 10:51:29 PM UTC","modified":"07/07/17 11:07:26 PM UTC","folder_number":"1"}' - end + let(:jsonld) { file_fixture("plum_records/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef.jsonld").read } before do - allow(converter).to receive(:open).with("https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest").and_return( - '{"@context":"http://iiif.io/api/presentation/2/context.json","@id":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest","@type":"sc:Manifest","label":["Test Folder 1"],"viewingHint":"individuals","viewingDirection":"left-to-right","sequences":[{"@id":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/sequence/normal","@type":"sc:Sequence","canvases":[{"@id":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/canvas/st722hc03g","@type":"sc:Canvas","label":"color-landscape.tif","images":[{"@id":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/annotation/st722hc03g-image","@type":"oa:Annotation","motivation":"sc:painting","resource":{"@id":"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2/full/!600,600/0/default.jpg","@type":"dctypes:Image","format":"image/jpeg","width":287,"height":200,"service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"https://libimages1.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2","profile":"http://iiif.io/api/image/2/level2.json"}},"on":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest/canvas/st722hc03g"}],"width":287,"height":200}],"viewingHint":"individuals"}],"metadata":[{"label":"Creator","value":["Test Creator"]},{"label":"Contributors","value":["Test Contributor"]},{"label":"Published/Created","value":["Test Publisher"]},{"label":"Subject","value":["278"]},{"label":"Language","value":["149"]},{"label":"Alternative title","value":["Alternative Title"]},{"label":"Barcode","value":"00000000000000"},{"label":"Folder number","value":"1"},{"label":"Page count","value":["50"]},{"label":"Geographic origin","value":["Spain"]},{"label":"Genre","value":["Banners"]},{"label":"Geo subject","value":["Spain"]},{"label":"Collection","value":["Box Number 1","Latin American Ephemera"]}],"thumbnail":{"@id":"https://libimagestest.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2/full/!200,150/0/default.jpg","service":{"@context":"http://iiif.io/api/image/2/context.json","@id":"https://libimagestest.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2","profile":"http://iiif.io/api/image/2/level2.json"}},"seeAlso":{"@id":"https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824.jsonld","format":"application/ld+json"}}' - ) + VCR.turn_off! + end + after do + VCR.turn_on! end it "converts the JSON-LD into a suitable solr document" do + stub_plum_jsonld(record: "b9e8325e-baf2-45e4-b32c-5e5b3755c8ef") expect(converter.output.except("ttl", "manifest")).to eq( - "id" => "sx920fz824", - "pulstore_pid" => "sx920fz824", - "barcode" => "00000000000000", - "date_uploaded" => "2017-07-07T22:51:29Z", - "date_modified" => "2017-07-07T23:07:26Z", - "physical_number" => "1", ## MISSING + "id" => "b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", + "pulstore_pid" => "b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", + "barcode" => "32101086454731", + "date_uploaded" => "2017-10-18T18:08:59Z", + "date_modified" => "2017-10-19T21:05:24Z", + "physical_number" => "193", "project_label" => "Latin American Ephemera", - "contributor" => ["Test Contributor"], + "contributor" => ["Gobierno Bolivariano de Venezuela"], "creator" => "Test Creator", - "sort_title" => "test folder 1", - "title_es" => "Test Folder 1", - "title_display" => "Test Folder 1", - "height_in_cm" => "10", - "width_in_cm" => "10", - "page_count" => "50", - "publisher_es" => ["Test Publisher"], - "publisher_display" => ["Test Publisher"], + "sort_title" => "caripe. jardín turístico de monagas. ", + "title_es" => "Caripe. Jardín turístico de Monagas. ", + "title_display" => "Caripe. Jardín turístico de Monagas. ", + "height_in_cm" => "25", + "width_in_cm" => "11", + "page_count" => "6", + "publisher_es" => ["Alcaldía del Municipio Caripe"], + "publisher_display" => ["Alcaldía del Municipio Caripe"], "rights" => "This digital reproduction is intended to support research, teaching, and private study. Users are responsible for determining any copyright questions", ## Is this right? - "category" => ["Agrarian and rural issues"], - "geographic_subject_label" => ["Spain"], - "subject_label" => ["Agricultural development projects"], - "genre_pul_label" => ["Banners"], + "category" => ["Environment and ecology", "Tourism"], + "geographic_subject_label" => ["Venezuela"], + "subject_label" => ["National parks and reserves", "Advertising--Tourism"], + "genre_pul_label" => ["Pamphlets"], "language_label" => ["Spanish"], - "geographic_origin_label" => ["Spain"], - "box_barcode" => "00000000000000", + "geographic_origin_label" => ["Venezuela"], + "box_barcode" => "32101086454731", "box_physical_location" => "rcpxr", - "box_physical_number" => "1", ## MISSING - "thumbnail_base" => "https://libimagestest.princeton.edu/loris/plum/st%2F72%2F2h%2Fc0%2F3g-intermediate_file.jp2" + "box_physical_number" => "57", ## MISSING + "thumbnail_base" => "https://libimages1.princeton.edu/loris/figgy_prod/c6%2Fb4%2Fbe%2Fc6b4beb0d65b4d979adcd74ceba30e92%2Fintermediate_file.jp2" ) end context "when there's no valid manifest" do before do - allow(converter).to receive(:open).with("https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest").and_return("{}") + allow(converter).to receive(:open).with("https://figgy.princeton.edu/concern/ephemera_folders/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef/manifest").and_return("{}") end it "works, but doesn't set the thumbnail" do output = converter.output diff --git a/spec/indexers/reindexer_spec.rb b/spec/indexers/reindexer_spec.rb index c103395f..80afd4d2 100644 --- a/spec/indexers/reindexer_spec.rb +++ b/spec/indexers/reindexer_spec.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true require 'rails_helper' -require 'vcr' RSpec.describe Reindexer do - vcr_options = { - record: :new_episodes, # See https://www.relishapp.com/vcr/vcr/v/1-6-0/docs/record-modes - cassette_name: 'reindexer', - serialize_with: :json - } let(:reindexer) { described_class.new } let(:solr) { Blacklight.default_index.connection } - it "pulls in all objects from Solr and indexes them", vcr: vcr_options do + before do + VCR.turn_off! + stub_plum_catalog(records: ["b9e8325e-baf2-45e4-b32c-5e5b3755c8ef"]) + end + after do + VCR.turn_on! + end + it "pulls in all objects from Solr and indexes them" do reindexer.index! - expect(solr.get("select", params: { q: "Test Folder 1" })["response"]["numFound"]).to eq 1 + expect(solr.get("select", params: { q: "Caripe. Jardín turístico de Monagas." })["response"]["numFound"]).to eq 1 end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ffe0c289..1d793d45 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -49,3 +49,4 @@ # https://relishapp.com/rspec/rspec-rails/docs config.infer_spec_type_from_file_location! end +WebMock.disable_net_connect!(allow_localhost: true) diff --git a/spec/services/plum_event_processor_spec.rb b/spec/services/plum_event_processor_spec.rb index e12575d8..51f0d53f 100644 --- a/spec/services/plum_event_processor_spec.rb +++ b/spec/services/plum_event_processor_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe PlumEventProcessor, vcr: { cassette_name: "plum_events", allow_playback_repeats: true } do +RSpec.describe PlumEventProcessor do subject(:processor) { described_class.new(event) } let(:event) do { @@ -11,14 +11,19 @@ "collection_slugs" => collection_slugs } end - let(:id) { "sx920fz824" } + let(:id) { "b9e8325e-baf2-45e4-b32c-5e5b3755c8ef" } let(:collection_slugs) { [LAE.config["collection"]["slug"]] } - let(:url) { "https://hydra-dev.princeton.edu/concern/ephemera_folders/sx920fz824/manifest" } + let(:url) { "https://figgy.princeton.edu/concern/ephemera_folders/b9e8325e-baf2-45e4-b32c-5e5b3755c8ef/manifest" } let(:solr) { Blacklight.default_index.connection } before do + stub_plum_jsonld(record: "b9e8325e-baf2-45e4-b32c-5e5b3755c8ef") + VCR.turn_off! solr.delete_by_id("sx920fz824") solr.commit end + after do + VCR.turn_on! + end context "when given an unknown event" do let(:type) { "AWFULBADTHINGSHAPPENED" } it "returns false" do @@ -28,7 +33,7 @@ context "when given a creation event" do let(:type) { "CREATED" } context "and it's not for a folder" do - let(:url) { "https://hydra-dev.princeton.edu/concern/ephemera_box/sx920fz824/manifest" } + let(:url) { "https://figgy.princeton.edu/concern/ephemera_box/sx920fz824/manifest" } it "returns false" do expect(processor.process).to eq false end @@ -41,7 +46,7 @@ end it "indexes that resource" do expect(processor.process).to eq true - output = solr.get("select", params: { q: "id:sx920fz824", qt: "document" }) + output = solr.get("select", params: { q: "id:b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", qt: "document" }) expect(output["response"]["numFound"]).to eq 1 end end @@ -55,47 +60,47 @@ } end it "deletes that resource" do - solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld")).read).output, params: { softCommit: true }) + solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld").gsub("concern/ephemera_folders", "catalog")).read).output, params: { softCommit: true }) expect(processor.process).to eq true - output = solr.get("select", params: { q: "id:sx920fz824", qt: "document" }) + output = solr.get("select", params: { q: "id:b9e8325e-baf2-45e4-b32c-5e5b3755c8ef", qt: "document" }) expect(output["response"]["numFound"]).to eq 0 end end context "when given an update event" do let(:type) { "UPDATED" } it "updates that resource" do - solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld")).read).output, params: { softCommit: true }) + solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld").gsub("concern/ephemera_folders", "catalog")).read).output, params: { softCommit: true }) allow(PlumJsonldConverter).to receive(:new).and_return(instance_double(PlumJsonldConverter, output: { id: id, title_display: "Fake Thing" }.stringify_keys)) allow(solr).to receive(:add).and_call_original expect(processor.process).to eq true - output = solr.get("select", params: { q: "id:sx920fz824", qt: "document" }) + output = solr.get("select", params: { q: "id:#{id}", qt: "document" }) expect(output["response"]["numFound"]).to eq 1 expect(output["response"]["docs"][0]["title_display"]).to eq ["Fake Thing"] expect(solr).to have_received(:add) end context "when it's no longer accessible" do it "deletes it" do - solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld")).read).output, params: { softCommit: true }) - stub_request(:get, url.gsub("/manifest", ".jsonld")).to_return(body: "{}", headers: { "Content-Type" => "application/json+ld" }) + solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld").gsub("concern/ephemera_folders", "catalog")).read).output, params: { softCommit: true }) + stub_request(:get, url.gsub("/manifest", ".jsonld").gsub("concern/ephemera_folders", "catalog")).to_return(body: "{}", headers: { "Content-Type" => "application/json+ld" }) expect(processor.process).to eq true - output = solr.get("select", params: { q: "id:sx920fz824", qt: "document" }) + output = solr.get("select", params: { q: "id:#{id}", qt: "document" }) expect(output["response"]["numFound"]).to eq 0 end end context "when it's removed from the collection" do let(:collection_slugs) { [] } it "deletes it" do - solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld")).read).output, params: { softCommit: true }) + solr.add(PlumJsonldConverter.new(jsonld: open(url.gsub("/manifest", ".jsonld").gsub("concern/ephemera_folders", "catalog")).read).output, params: { softCommit: true }) expect(processor.process).to eq true - output = solr.get("select", params: { q: "id:sx920fz824", qt: "document" }) + output = solr.get("select", params: { q: "id:#{id}", qt: "document" }) expect(output["response"]["numFound"]).to eq 0 end end diff --git a/spec/support/stub_plum_catalog.rb b/spec/support/stub_plum_catalog.rb new file mode 100644 index 00000000..1de3bc6f --- /dev/null +++ b/spec/support/stub_plum_catalog.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true +module PlumStubbing + def stub_plum_catalog(records:) + records.each do |record| + stub_plum_jsonld(record: record) + end + stub_request(:get, "https://figgy.princeton.edu/catalog.json?f[human_readable_type_sim][]=Ephemera+Folder&f[ephemera_project_ssim][]=Latin+American+Ephemera&page=1") + .to_return( + body: + { + response: + { + docs: records.map do |record| + JSON.parse(file_fixture("plum_records/#{record}.json").read) + end, + facets: [ + ], + pages: { + current_page: 1, + next_page: nil, + prev_page: nil, + total_pages: 1, + limit_value: records.length, + offset_value: 0, + total_count: records.length, + first_page?: true, + last_page?: true + } + } + }.to_json + ) + end + + def stub_plum_jsonld(record:) + stub_request(:get, "https://figgy.princeton.edu/catalog/#{record}.jsonld") + .to_return( + body: file_fixture("plum_records/#{record}.jsonld").read + ) + stub_request(:get, "https://figgy.princeton.edu/concern/ephemera_folders/#{record}/manifest") + .to_return( + body: file_fixture("plum_records/#{record}.manifest.json").read + ) + end +end + +RSpec.configure do |config| + config.include PlumStubbing +end