This repository has been archived by the owner on Dec 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
245 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Pipeline module to assign edm:object for Indiana Memory data | ||
""" | ||
|
||
import json | ||
from akara import response | ||
from akara.services import simple_service | ||
|
||
|
||
@simple_service('POST', | ||
'http://purl.org/la/dp/indiana_identify_object', | ||
'indiana_identify_object', | ||
'application/json') | ||
def indiana_identify_object(body, ctype_ignored): | ||
"""assign edm:object based on dc:source | ||
Per Indiana crosswalk, http://bit.ly/dpla-crosswalks | ||
dc:source lives in originalRecord.source | ||
""" | ||
try: | ||
record = json.loads(body) | ||
record['object'] = record['originalRecord']['source'] | ||
return json.dumps(record) | ||
except ValueError: | ||
prepare_error_response() | ||
return 'Unable to parse request body as JSON' | ||
except KeyError: | ||
prepare_error_response() | ||
return 'No originalRecord.source for determining object' | ||
|
||
def prepare_error_response(): | ||
"""Set HTTP response code and content type for an error""" | ||
response.code = 500 | ||
response.add_header('Content-Type', 'text/plain') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "indiana", | ||
"type": "oai_verbs", | ||
"endpoint_url": "https://digital.library.in.gov/OAI/Server", | ||
"contributor": { | ||
"@id": "http://dp.la/api/contributor/indiana", | ||
"name": "Indiana Memory" | ||
}, | ||
"enrichments_coll": [ | ||
"/set_context", | ||
"/validate_mapv3" | ||
], | ||
"enrichments_item": [ | ||
"/select-id", | ||
"/dpla_mapper?mapper_type=dublin_core", | ||
"/strip_html", | ||
"/indiana_identify_object", | ||
"/set_context", | ||
"/move_date_values?prop=sourceResource%2Fspatial&to_prop=sourceResource%2Fdate", | ||
"/shred?prop=sourceResource%2Fsubject%2CsourceResource%2Fspatial%2CsourceResource%2Ftype", | ||
"/cleanup_value", | ||
"/capitalize_value", | ||
"/enrich_earliest_date", | ||
"/enrich-subject", | ||
"/enrich_date", | ||
"/set_spec_type", | ||
"/enrich-type?send_rejects_to_format=true", | ||
"/enrich-format", | ||
"/enrich-type?default=image", | ||
"/enrich_location", | ||
"/geocode", | ||
"/enrich_language", | ||
"/set_prop?prop=sourceResource%2FstateLocatedIn&value=Indiana", | ||
"/enrich_location?prop=sourceResource%2FstateLocatedIn", | ||
"/unset_prop?prop=dataProvider", | ||
"/copy_prop?prop=sourceResource%2Fcontributor&to_prop=dataProvider", | ||
"/unset_prop?prop=sourceResource%2Fcontributor", | ||
"/copy_prop?prop=provider%2Fname&to_prop=dataProvider&skip_if_exists=True", | ||
"/validate_mapv3" | ||
], | ||
"thresholds": { | ||
"added": 5000, | ||
"changed": 1000, | ||
"deleted": 1000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
from distutils.core import setup | ||
|
||
setup( name = 'ingestion', | ||
version = '33.2.2', | ||
version = '33.2.3', | ||
description='DPLA Ingestion System', | ||
author='Digital Public Library of America', | ||
author_email='[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import json | ||
from server_support import server, H | ||
from dict_differ import assert_same_jsons | ||
|
||
|
||
def test_indiana_identify_object_from_source(): | ||
"""Indiana object is assigned from source""" | ||
request_data = { | ||
'originalRecord': {'source': 'http://thumbnail/url'} | ||
} | ||
expected_result = { | ||
'originalRecord': {'source': 'http://thumbnail/url'}, | ||
'object': 'http://thumbnail/url' | ||
} | ||
url = server() + 'indiana_identify_object' | ||
resp_meta, resp_body = H.request(url, 'POST', | ||
body=json.dumps(request_data)) | ||
assert resp_meta.status == 200 | ||
assert_same_jsons(expected_result, resp_body) |
Oops, something went wrong.