Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update links handling for Aardvark transform #115

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/fixtures/aardvark/aardvark_record_all_fields.jsonl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id": "mit:123", "dcat_bbox": "ENVELOPE(-111.1, -104.0, 45.0, 40.9)", "dcat_keyword_sm": ["Country"], "dcat_theme_sm": ["Political boundaries"], "dct_accessRights_s": "Access note", "dct_alternative_sm": ["Alternate title"], "dct_creator_sm": ["Smith, Jane", "Smith, John"], "dct_description_sm": ["A description"], "dct_format_s": "Shapefile", "dct_identifier_sm": ["abc123"], "dct_issued_s": "2003-10-23", "dct_language_sm": ["eng"], "dct_license_sm": ["http://license.license", "http://another_license.another_license"], "dct_publisher_sm": ["ML InfoMap (Firm)"], "dct_references_s": "{\"https://schema.org/downloadUrl\": [{\"label\": \"Source Metadata\", \"protocol\": \"Download\", \"url\": \"https://example.com/GISPORTAL_GISOWNER01_BOSTONWATER95.source.fgdc.xml\"}, {\"label\": \"Normalized Metadata\", \"protocol\": \"Download\", \"url\": \"https://example.com/GISPORTAL_GISOWNER01_BOSTONWATER95.normalized.aardvark.json\"}, {\"label\": \"Data Zipfile\", \"protocol\": \"Download\", \"url\": \"https://example.com/GISPORTAL_GISOWNER01_BOSTONWATER95.zip\"}]}", "dct_rights_sm": ["Some person has the rights"], "dct_rightsHolder_sm": ["The person with the rights", "Another person with the rights"], "dct_spatial_sm": ["Some city, Some country"], "dct_subject_sm": ["Geography", "Earth"], "dct_temporal_sm": ["1943", "1979"], "dct_title_s": "Test title 1", "gbl_dateRange_drsim": ["[1943 TO 1946]"], "gbl_displayNote_sm": ["Danger: This text will be displayed in a red box","Info: This text will be displayed in a blue box","Tip: This text will be displayed in a green box","Warning: This text will be displayed in a yellow box","This is text without a tag and it will be assigned default 'note' style"], "gbl_indexYear_im": [1943,1944,1945,1946], "gbl_resourceClass_sm": ["Dataset"], "gbl_resourceType_sm": ["Vector data"], "gbl_suppressed_b": false, "locn_geometry": "ENVELOPE(-111.1, -104.0, 45.0, 40.9)", "schema_provider_s": "MIT"}
{"id": "mit:123", "dcat_bbox": "ENVELOPE(-111.1, -104.0, 45.0, 40.9)", "dcat_keyword_sm": ["Country"], "dcat_theme_sm": ["Political boundaries"], "dct_accessRights_s": "Access note", "dct_alternative_sm": ["Alternate title"], "dct_creator_sm": ["Smith, Jane", "Smith, John"], "dct_description_sm": ["A description"], "dct_format_s": "Shapefile", "dct_identifier_sm": ["abc123"], "dct_issued_s": "2003-10-23", "dct_language_sm": ["eng"], "dct_license_sm": ["http://license.license", "http://another_license.another_license"], "dct_publisher_sm": ["ML InfoMap (Firm)"], "dct_references_s": "{\"http://schema.org/downloadUrl\": [{\"label\": \"Source Metadata\", \"url\": \"https://cdn.dev1.mitlibrary.net/geo/public/GISPORTAL_GISOWNER01_BOSTONWATER95.source.fgdc.xml\"}, {\"label\": \"Aardvark Metadata\", \"url\": \"https://cdn.dev1.mitlibrary.net/geo/public/GISPORTAL_GISOWNER01_BOSTONWATER95.normalized.aardvark.json\"}, {\"label\": \"Data\", \"url\": \"https://cdn.dev1.mitlibrary.net/geo/public/GISPORTAL_GISOWNER01_BOSTONWATER95.zip\"}], \"http://schema.org/url\": [{\"label\": \"Website\", \"url\": \"https://search.libraries.mit.edu/record/gismit:GISPORTAL_GISOWNER01_BOSTONWATER95\"}]}", "dct_rights_sm": ["Some person has the rights"], "dct_rightsHolder_sm": ["The person with the rights", "Another person with the rights"], "dct_spatial_sm": ["Some city, Some country"], "dct_subject_sm": ["Geography", "Earth"], "dct_temporal_sm": ["1943", "1979"], "dct_title_s": "Test title 1", "gbl_dateRange_drsim": ["[1943 TO 1946]"], "gbl_displayNote_sm": ["Danger: This text will be displayed in a red box","Info: This text will be displayed in a blue box","Tip: This text will be displayed in a green box","Warning: This text will be displayed in a yellow box","This is text without a tag and it will be assigned default 'note' style"], "gbl_indexYear_im": [1943,1944,1945,1946], "gbl_resourceClass_sm": ["Dataset"], "gbl_resourceType_sm": ["Vector data"], "gbl_suppressed_b": false, "locn_geometry": "ENVELOPE(-111.1, -104.0, 45.0, 40.9)", "schema_provider_s": "MIT"}
19 changes: 14 additions & 5 deletions tests/sources/json/test_aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,29 @@ def test_aardvark_get_identifiers_success(aardvark_record_all_fields):
def test_aardvark_get_links_success(aardvark_record_all_fields):
assert MITAardvark.get_links(next(aardvark_record_all_fields), "123") == [
timdex.Link(
url="https://example.com/GISPORTAL_GISOWNER01_BOSTONWATER95.source.fgdc.xml",
url="https://cdn.dev1.mitlibrary.net/geo/public"
"/GISPORTAL_GISOWNER01_BOSTONWATER95.source.fgdc.xml",
kind="Download",
text="Source Metadata",
),
timdex.Link(
url="https://example.com/GISPORTAL_GISOWNER01_BOSTONWATER95."
url="https://cdn.dev1.mitlibrary.net/geo/public"
"/GISPORTAL_GISOWNER01_BOSTONWATER95."
"normalized.aardvark.json",
kind="Download",
text="Normalized Metadata",
text="Aardvark Metadata",
),
timdex.Link(
url="https://example.com/GISPORTAL_GISOWNER01_BOSTONWATER95.zip",
url="https://cdn.dev1.mitlibrary.net/geo/public"
"/GISPORTAL_GISOWNER01_BOSTONWATER95.zip",
kind="Download",
text="Data Zipfile",
text="Data",
),
timdex.Link(
url="https://search.libraries.mit.edu/record/gismit"
":GISPORTAL_GISOWNER01_BOSTONWATER95",
kind="Website",
text="Website",
),
]

Expand Down
10 changes: 9 additions & 1 deletion transmogrifier/sources/json/aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,15 @@ def get_links(source_record: dict, source_record_id: str) -> list[timdex.Link]:
timdex.Link(
url=link.get("url"), kind="Download", text=link.get("label")
)
for link in links_object.get("https://schema.org/downloadUrl")
for link in links_object.get("http://schema.org/downloadUrl", [])
]
)
links.extend(
[
timdex.Link(
url=link.get("url"), kind="Website", text=link.get("label")
)
for link in links_object.get("http://schema.org/url", [])
]
)
except ValueError:
Expand Down
Loading