diff --git a/i7Import/configs/islandora7_import_sample.config b/i7Import/configs/islandora7_import_sample.config index 6c00d0e..5b70f73 100644 --- a/i7Import/configs/islandora7_import_sample.config +++ b/i7Import/configs/islandora7_import_sample.config @@ -1,5 +1,5 @@ -solr_base_url: 'http://localhost:8080/solr' -islandora_base_url: 'http://localhost:8000' +solr_base_url: 'http://solr.islandora.dev/solr/#/' +islandora_base_url: 'https://islandora.dev/' csv_output_path: 'islandora7_metadata.csv' obj_directory: '/tmp/objs' log_file_path: 'islandora_content.log' @@ -12,4 +12,5 @@ collections: - islandora:collection1 - random:collection7 solr_filters: - 'some_solr_field_ms': 'some_value' \ No newline at end of file + 'some_solr_field_ms': 'some_value' +debug: True \ No newline at end of file diff --git a/i7Import/get_islandora_7_content.py b/i7Import/get_islandora_7_content.py index 70102a7..e997fff 100755 --- a/i7Import/get_islandora_7_content.py +++ b/i7Import/get_islandora_7_content.py @@ -36,7 +36,6 @@ filemode='a', format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S') - if args.metadata_solr_request: metadata_solr_request = utils.get_metadata_solr_request(args.metadata_solr_request) else: diff --git a/i7Import/i7ImportUtilities.py b/i7Import/i7ImportUtilities.py index 275f21a..8c39439 100644 --- a/i7Import/i7ImportUtilities.py +++ b/i7Import/i7ImportUtilities.py @@ -8,6 +8,7 @@ import os from rich.console import Console from rich.table import Table +import urllib.parse class i7ImportUtilities: @@ -140,7 +141,6 @@ def get_default_metadata_solr_request(self): filtered_field_list.insert(0, standard_field) fields_param = ','.join(filtered_field_list) query = f"{self.config['solr_base_url']}/select?q=PID:{self.config['namespace']}*&wt=csv&start={self.config['start']}&rows={self.config['rows']}&fl={fields_param}" - if self.config['collection']: collection = self.config['collection'] query = f'{query}&fq=RELS_EXT_isMemberOfCollection_uri_s: "info:fedora/{collection}"' @@ -148,8 +148,10 @@ def get_default_metadata_solr_request(self): model = self.config['content_model'] query = f'{query}&fq=RELS_EXT_hasModel_uri_s:"info:fedora/{model}"' if self.config['solr_filters']: - for key, value in self.config['solr_filters'].items(): - query = f'{query}&fq={key}:"{value}"' + keys = list(self.config['solr_filters'].keys()) + for key in keys: + value = urllib.parse.quote(self.config['solr_filters'][key]) + query = f'{query}&fq={key}:{value}' fedora_prefix = 'RELS_EXT_isMemberOfCollection_uri_s:"info\:fedora/' if self.config['collections']: collections = self.config['collections'] @@ -159,7 +161,6 @@ def get_default_metadata_solr_request(self): fq_string = "&fq=" + ' or '.join(fedora_collections) query = f'{query}{fq_string}' - # Get the populated CSV from Solr, with the object namespace and field list filters applied. return query @@ -213,6 +214,34 @@ def print_config(self): for k, v in value.items(): new_value += f"{k}: {v}\n" value = new_value + if str(type(value)) == '': + new_value = '' + for item in value: + new_value += f"{item}\n" + value = new_value table.add_row(key, str(value)) console = Console() - console.print(table) \ No newline at end of file + console.print(table) + + def test_config(self): + query = f"{self.config['solr_base_url']}/select?q=PID:{self.config['namespace']}*&wt=csv&rows=1000000" + if self.config['collection']: + collection = self.config['collection'] + query = f'{query}&fq=RELS_EXT_isMemberOfCollection_uri_s: "info:fedora/{collection}"' + if self.config['content_model']: + model = self.config['content_model'] + query = f'{query}&fq=RELS_EXT_hasModel_uri_s:"info:fedora/{model}"' + if self.config['solr_filters']: + keys = list(self.config['solr_filters'].keys()) + for key in keys: + value = urllib.parse.quote(self.config['solr_filters'][key]) + query = f'{query}&fq={key}:{value}' + fedora_prefix = 'RELS_EXT_isMemberOfCollection_uri_s:"info\:fedora/' + if self.config['collections']: + collections = self.config['collections'] + fedora_collections = [] + for collection in collections: + fedora_collections.append(f'{fedora_prefix}"{collection}"') + fq_string = "&fq=" + ' or '.join(fedora_collections) + query = f'{query}{fq_string}' + self.print_config()