Skip to content

Instantly share code, notes, and snippets.

@ghukill
Last active February 12, 2018 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghukill/ca3c1c11a46f7c5e96ae95513a937353 to your computer and use it in GitHub Desktop.
Save ghukill/ca3c1c11a46f7c5e96ae95513a937353 to your computer and use it in GitHub Desktop.
Combine Bootstrap
[
{
"model": "core.oaiendpoint",
"pk": 1,
"fields": {
"name": "Wayne Ouroboros",
"endpoint": "http://digital.library.wayne.edu/api/oai",
"verb": "ListRecords",
"metadataPrefix": "mods",
"scope_type": "setList",
"scope_value": "wayne:collectionramsey"
}
},
{
"model": "core.oaiendpoint",
"pk": 2,
"fields": {
"name": "Wayne REPOX",
"endpoint": "http://metadata.library.wayne.edu/repox/OAIHandler",
"verb": "ListRecords",
"metadataPrefix": "MODS",
"scope_type": "setList",
"scope_value": "wsudor_dpla"
}
},
{
"model": "core.transformation",
"pk": 1,
"fields": {
"name": "WSUDOR MODS to Service Hub profile",
"payload": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<xsl:stylesheet \r\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"2.0\" \r\n xmlns:mods=\"http://www.loc.gov/mods/v3\">\r\n <xsl:output method=\"xml\" indent=\"yes\"/>\r\n \r\n <xsl:template match=\"/\">\r\n <mods:mods>\r\n <xsl:call-template name=\"titleInfo\"/>\r\n <xsl:call-template name=\"subject\"/>\r\n <xsl:call-template name=\"abstract\"/>\r\n <xsl:call-template name=\"location\"/>\r\n <xsl:call-template name=\"date\"/>\r\n <xsl:call-template name=\"type\"/>\r\n <xsl:call-template name=\"physicalD\"/>\r\n <xsl:call-template name=\"URLs\"/>\r\n <xsl:call-template name=\"host\"/>\r\n <xsl:call-template name=\"otherversion\"/>\r\n <xsl:call-template name=\"sourceDesc\"/>\r\n <xsl:call-template name=\"credit\"/>\r\n <xsl:call-template name=\"generalNote\"/>\r\n <xsl:call-template name=\"record\"/>\r\n <xsl:call-template name=\"recordOr\"/>\r\n <xsl:call-template name=\"rights\"/>\r\n <xsl:call-template name=\"language\"/>\r\n <xsl:call-template name=\"name\"/>\r\n </mods:mods>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"titleInfo\">\r\n <xsl:for-each select=\"mods:mods/mods:titleInfo[not(@type)]\">\r\n <mods:titleInfo>\r\n <xsl:variable name=\"titleStrip\" select=\"normalize-space(mods:title)\"/>\r\n <xsl:choose>\r\n <xsl:when test=\"@type\">\r\n <xsl:attribute name=\"type\"><xsl:value-of select=\"@type\"/></xsl:attribute>\r\n <mods:title><xsl:value-of select=\"$titleStrip\"/></mods:title>\r\n </xsl:when>\r\n <xsl:otherwise>\r\n <mods:title><xsl:value-of select=\"$titleStrip\"/></mods:title>\r\n </xsl:otherwise>\r\n </xsl:choose>\r\n </mods:titleInfo>\r\n </xsl:for-each>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"subject\">\r\n <xsl:for-each select=\"*/mods:subject\">\r\n <mods:subject>\r\n <xsl:for-each select=\"./*\">\r\n <xsl:choose>\r\n <xsl:when test=\"contains(current(), '(Mich.)')\">\r\n <mods:geographic>\r\n <xsl:value-of select=\"replace(current(), '(Mich.)' , 'Michigan')\"/>\r\n </mods:geographic>\r\n </xsl:when>\r\n <xsl:when test=\"contains(current(), '(Detroit, Mich.)')\">\r\n <mods:geographic>\r\n <xsl:value-of select=\"replace(current(), '(Detroit, Mich.)' , 'Detroit, Michigan')\"/>\r\n </mods:geographic>\r\n </xsl:when>\r\n <xsl:otherwise>\r\n <xsl:copy-of select=\"current()\"/>\r\n </xsl:otherwise>\r\n </xsl:choose>\r\n \r\n <!-- <xsl:if test=\"not(contains(text(),'(Mich.)'))\">\r\n <xsl:copy-of select=\"current()\"/> \r\n </xsl:if> -->\r\n <!-- <xsl:variable name=\"element\" select=\"./*\"/>\r\n \r\n <xsl:copy-of select=\"replace(current(), 'History' , 'TEST!!!!!')\"></xsl:copy-of> \r\n <xsl:copy-of select=\"current()\"/> -->\r\n </xsl:for-each>\r\n </mods:subject>\r\n \r\n </xsl:for-each>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"abstract\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:abstract\">\r\n <mods:abstract><xsl:value-of select=\"*/mods:abstract\"/></mods:abstract>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n \r\n </xsl:template>\r\n\r\n <xsl:template name=\"location\">\r\n <xsl:for-each select=\"*/mods:originInfo/mods:place/mods:placeTerm[@type='text']\">\r\n <xsl:choose>\r\n <xsl:when test=\"contains(current(), '(Mich.)')\">\r\n <mods:subject>\r\n <mods:geographic>\r\n <xsl:value-of select=\"replace(current(), '(Mich.)' , 'Michigan')\"/>\r\n </mods:geographic>\r\n </mods:subject>\r\n </xsl:when>\r\n <xsl:when test=\"contains(current(), '(Detroit, Mich.)')\">\r\n <mods:subject>\r\n <mods:geographic>\r\n <xsl:value-of select=\"replace(current(), '(Detroit, Mich.)' , 'Detroit, Michigan')\"/>\r\n </mods:geographic>\r\n </mods:subject>\r\n </xsl:when>\r\n <xsl:otherwise>\r\n <mods:subject>\r\n <mods:geographic>\r\n <xsl:copy-of select=\"current()\"/>\r\n </mods:geographic>\r\n </mods:subject>\r\n </xsl:otherwise>\r\n </xsl:choose>\r\n \r\n </xsl:for-each>\r\n </xsl:template> \r\n \r\n <xsl:template name=\"date\">\r\n <mods:originInfo>\r\n <xsl:for-each select=\"mods:mods/mods:originInfo\">\r\n <xsl:choose>\r\n <xsl:when test=\"mods:dateIssued[@point='start']\">\r\n <xsl:variable name=\"start\"><xsl:value-of select=\"mods:dateIssued[@point='start']\"/></xsl:variable>\r\n <xsl:variable name=\"end\"><xsl:value-of select=\"mods:dateIssued[@point='end']\"/></xsl:variable>\r\n <mods:dateIssued><xsl:value-of select=\"concat($start,'-',$end)\"/></mods:dateIssued>\r\n </xsl:when>\r\n <xsl:otherwise>\r\n <mods:dateIssued><xsl:value-of select=\"mods:dateIssued\"/></mods:dateIssued>\r\n </xsl:otherwise>\r\n </xsl:choose>\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:originInfo/mods:publisher\">\r\n <mods:publisher><xsl:value-of select=\"*/mods:originInfo/mods:publisher\"/></mods:publisher>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n </xsl:for-each>\r\n </mods:originInfo>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"type\">\r\n <mods:typeOfResource><xsl:value-of select=\"*/mods:typeOfResource\"/></mods:typeOfResource>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"physicalD\">\r\n <mods:physicalDescription>\r\n <mods:form>\r\n <xsl:attribute name=\"authority\"><xsl:value-of select=\"*/mods:physicalDescription/mods:form/@authority\"/></xsl:attribute>\r\n <xsl:value-of select=\"*/mods:physicalDescription/mods:form\"/>\r\n </mods:form>\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:physicalDescription/mods:extent\">\r\n <mods:extent><xsl:value-of select=\"*/mods:physicalDescription/mods:extent\"/></mods:extent>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n </mods:physicalDescription>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"URLs\">\r\n <mods:location>\r\n <mods:url>\r\n <xsl:attribute name=\"usage\">primary</xsl:attribute>\r\n <xsl:value-of select=\"*/mods:location/mods:url[@usage='primary']\"/>\r\n </mods:url>\r\n </mods:location>\r\n <mods:location>\r\n <mods:url>\r\n <xsl:attribute name=\"access\">preview</xsl:attribute>\r\n <xsl:value-of select=\"*/mods:location/mods:url[@access='preview']\"/>\r\n </mods:url>\r\n </mods:location>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"host\">\r\n <mods:relatedItem type=\"host\">\r\n <mods:titleInfo>\r\n <mods:title>\r\n <xsl:value-of select=\"*/mods:relatedItem[@type='host']/mods:titleInfo/mods:title\"/>\r\n </mods:title>\r\n </mods:titleInfo>\r\n </mods:relatedItem>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"otherversion\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:relatedItem[@type='otherFormat']/mods:note[@type='originalVersion']\">\r\n <mods:note><xsl:value-of select=\"*/mods:relatedItem[@type='otherFormat']/mods:note[@type='originalVersion']\"/></mods:note>\r\n <!-- <mods:note><xsl:value-of select=\"concat('Original Version: ',*/mods:relatedItem[@type='otherFormat']/mods:note[@type='originalVersion'])\"/></mods:note>-->\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n \r\n </xsl:template>\r\n \r\n <xsl:template name=\"sourceDesc\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:note[@type='sourceOfDescription']\">\r\n <mods:note><xsl:value-of select=\"*/mods:note[@type='sourceOfDescription']\"/></mods:note>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n \r\n </xsl:template>\r\n \r\n <xsl:template name=\"credit\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:note[@type='creditLine']\">\r\n <mods:note><xsl:value-of select=\"*/mods:note[@type='creditLine']\"/></mods:note>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"generalNote\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:note[not(@type)]\">\r\n <mods:note><xsl:value-of select=\"*/mods:note[not(@type)]\"/></mods:note>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"record\">\r\n <xsl:choose>\r\n <xsl:when test=\"mods:mods/mods:recordInfo/mods:recordContentSource\">\r\n <mods:recordInfo>\r\n <xsl:for-each select=\"mods:mods/mods:recordInfo/mods:recordContentSource\">\r\n <xsl:copy-of select=\"current()\"/>\r\n </xsl:for-each> \r\n </mods:recordInfo>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"recordOr\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:recordInfo/mods:recordOrigin\">\r\n <mods:note><xsl:value-of select=\"*/mods:recordInfo/mods:recordOrigin\"/></mods:note>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"rights\">\r\n <mods:accessCondition type=\"use and reproduction\">\r\n <xsl:value-of select=\"*/mods:accessCondition\"/>\r\n </mods:accessCondition>\r\n </xsl:template>\r\n \r\n <xsl:template name=\"language\">\r\n <xsl:choose>\r\n <xsl:when test=\"*/mods:language/mods:languageTerm[@type='code']\">\r\n <mods:language>\r\n <mods:languageTerm type=\"code\">\r\n <xsl:value-of select=\"*/mods:language/mods:languageTerm[@type='code']\"/>\r\n </mods:languageTerm>\r\n </mods:language>\r\n </xsl:when>\r\n <xsl:otherwise/>\r\n </xsl:choose>\r\n \r\n </xsl:template>\r\n \r\n <xsl:template name=\"name\">\r\n <xsl:for-each select=\"mods:mods/mods:name\">\r\n <xsl:choose>\r\n <xsl:when test=\"mods:role/mods:roleTerm='creator' or mods:role/mods:roleTerm='writer' or mods:role/mods:roleTerm='Photographer' \r\n or mods:role/mods:roleTerm='Author' or mods:role/mods:roleTerm='Conceptor' or mods:role/mods:roleTerm='Illustrator'\">\r\n <mods:name>\r\n <xsl:attribute name=\"type\"><xsl:value-of select=\"@type\"/></xsl:attribute>\r\n <xsl:attribute name=\"authority\"><xsl:value-of select=\"@authority\"/></xsl:attribute>\r\n <mods:namePart><xsl:value-of select=\"mods:namePart\"></xsl:value-of></mods:namePart>\r\n <mods:role>\r\n <mods:roleTerm authority=\"marcrelator\">Creator</mods:roleTerm>\r\n </mods:role>\r\n </mods:name>\r\n </xsl:when>\r\n <xsl:when test=\"mods:role/mods:roleTerm='Contributor' or mods:role/mods:roleTerm='Translator'\">\r\n \r\n <mods:name>\r\n <xsl:attribute name=\"type\"><xsl:value-of select=\"@type\"/></xsl:attribute>\r\n <xsl:attribute name=\"authority\"><xsl:value-of select=\"@authority\"/></xsl:attribute>\r\n <mods:namePart><xsl:value-of select=\"mods:namePart\"></xsl:value-of></mods:namePart>\r\n <mods:role>\r\n <mods:roleTerm authority=\"marcrelator\">Contributor</mods:roleTerm>\r\n </mods:role>\r\n </mods:name>\r\n \r\n </xsl:when>\r\n <xsl:otherwise>\r\n <mods:name>\r\n <xsl:attribute name=\"type\"><xsl:value-of select=\"@type\"/></xsl:attribute>\r\n <xsl:attribute name=\"authority\"><xsl:value-of select=\"@authority\"/></xsl:attribute>\r\n <mods:namePart><xsl:value-of select=\"mods:namePart\"></xsl:value-of></mods:namePart>\r\n </mods:name>\r\n </xsl:otherwise>\r\n </xsl:choose>\r\n </xsl:for-each>\r\n </xsl:template>\r\n \r\n \r\n</xsl:stylesheet>",
"transformation_type": "xslt",
"filepath": "/home/combine/data/combine/transformations/c709b8b6baf64c3a93a32d1096815b6b.xsl"
}
},
{
"model": "core.validationscenario",
"pk": 1,
"fields": {
"name": "DPLA minimum",
"payload": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<schema xmlns=\"http://purl.oclc.org/dsdl/schematron\" xmlns:mods=\"http://www.loc.gov/mods/v3\">\r\n <ns prefix=\"mods\" uri=\"http://www.loc.gov/mods/v3\"/>\r\n <!-- Required top level Elements for all records record -->\r\n <pattern>\r\n <title>Required Elements for Each MODS record</title>\r\n <rule context=\"mods:mods\">\r\n <assert test=\"mods:titleInfo\">There must be a title element</assert>\r\n <assert test=\"count(mods:location/mods:url[@usage='primary'])=1\">There must be a url pointing to the item</assert>\r\n <assert test=\"count(mods:location/mods:url[@access='preview'])=1\">There must be a url pointing to a thumnail version of the item</assert>\r\n <assert test=\"count(mods:accessCondition[@type='use and reproduction'])=1\">There must be a rights statement</assert>\r\n </rule>\r\n </pattern>\r\n \r\n <!-- Additional Requirements within Required Elements -->\r\n <pattern>\r\n <title>Subelements and Attributes used in TitleInfo</title>\r\n <rule context=\"mods:mods/mods:titleInfo\">\r\n <assert test=\"*\">TitleInfo must contain child title elements</assert>\r\n </rule>\r\n <rule context=\"mods:mods/mods:titleInfo/*\">\r\n <assert test=\"normalize-space(.)\">The title elements must contain text</assert>\r\n </rule>\r\n </pattern>\r\n \r\n <pattern>\r\n <title>Additional URL requirements</title>\r\n <rule context=\"mods:mods/mods:location/mods:url\">\r\n <assert test=\"normalize-space(.)\">The URL field must contain text</assert>\r\n </rule> \r\n </pattern>\r\n \r\n</schema>",
"validation_type": "sch",
"filepath": "/home/combine/data/combine/validation/file_47fe16744f1644b6bf6c6d7623bdfe3f.sch",
"default_run": true
}
},
{
"model": "core.validationscenario",
"pk": 2,
"fields": {
"name": "Date checker (python)",
"payload": "import re\r\n\r\n\r\ndef test_check_dateIssued_format(record, test_message=\"check mods:dateIssued is YYYY-MM-DD or YYYY or YYYY-YYYY\"):\r\n\r\n\t# get dateIssued elements\r\n\tdateIssued_elements = record.xml.xpath('//mods:dateIssued', namespaces=record.nsmap)\r\n\r\n\t# if found, check format \r\n\tif len(dateIssued_elements) > 0:\r\n\r\n\t\t# loop through values and check\r\n\t\tfor dateIssued in dateIssued_elements: \r\n\t\t\r\n\t\t\t# check format\r\n\t\t\tif dateIssued.text is not None:\r\n\t\t\t\tmatch = re.match(r'^([0-9]{4}-[0-9]{2}-[0-9]{2})|([0-9]{4})|([0-9]{4}-[0-9]{4})$', dateIssued.text)\r\n\t\t\telse:\r\n\t\t\t\t# allow None values to pass test \r\n\t\t\t\treturn True\r\n\r\n\t\t\t# match found, continue\r\n\t\t\tif match:\r\n\t\t\t\tcontinue\r\n\t\t\telse:\r\n\t\t\t\treturn False\r\n\r\n\t\t# if all matches, return True\r\n\t\treturn True\r\n\r\n\t# if none found, return True indicating passed test due to omission\r\n\telse:\r\n\t\treturn True",
"validation_type": "python",
"filepath": "/home/combine/data/combine/validation/file_376d2353bbdb4ddcbb82191ebafad649.py",
"default_run": true
}
},
{
"model": "core.organization",
"pk": 2,
"fields": {
"name": "AnalysisOrganizationf8ed4bfcefc4dbf87b588a5de9b7cc95",
"description": "For the explicit use of aggregating Analysis jobs",
"timestamp": "2018-02-12T14:51:57.048Z",
"for_analysis": true
}
},
{
"model": "core.organization",
"pk": 5,
"fields": {
"name": "Example Organization",
"description": "Highest level of organization",
"timestamp": "2018-02-12T16:52:09.461Z",
"for_analysis": false
}
},
{
"model": "core.recordgroup",
"pk": 2,
"fields": {
"organization": 2,
"name": "AnalysisRecordGroupf660bb4826bea8b63fd773d27d687cfd",
"description": "For the explicit use of aggregating Analysis jobs",
"timestamp": "2018-02-12T14:51:57.057Z",
"publish_set_id": null,
"for_analysis": true
}
},
{
"model": "core.recordgroup",
"pk": 5,
"fields": {
"organization": 5,
"name": "Example Record Group 1",
"description": null,
"timestamp": "2018-02-12T16:52:21.215Z",
"publish_set_id": null,
"for_analysis": false
}
},
{
"model": "core.recordgroup",
"pk": 6,
"fields": {
"organization": 5,
"name": "Example Record Group 2",
"description": null,
"timestamp": "2018-02-12T16:52:26.985Z",
"publish_set_id": null,
"for_analysis": false
}
}
]
@ghukill
Copy link
Author

ghukill commented Feb 12, 2018

To import into Combine, from the Combine VM:

  • make sure in combine conda environment: source activate combine
  • save this json file somewhere on the Combine VM filesystem
  • navigate to /opt/combine
  • load into DB via Django:
./manage.py loaddata PATH_TO_JSON_FILE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment