Skip to content

Commit

Permalink
Pull in refs fix from integration into rel/1.0.X
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPlante committed Jan 21, 2021
2 parents 38066dc + fd13007 commit c8e49dc
Show file tree
Hide file tree
Showing 23 changed files with 732 additions and 508 deletions.
2 changes: 1 addition & 1 deletion docker/jqfromsrc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apt-get update && \
WORKDIR /root
RUN git clone http://github.com/stedolan/jq.git jq-dev && \
cd jq-dev && \
git checkout 6306ac89667cf35f47ddc40aa0630546c57e387f && \
git checkout 80052e5275ae8c45b20411eecdd49c945a64a412 && \
git submodule update --init && \
autoreconf -fi && \
./configure --with-oniguruma=builtin && \
Expand Down
20 changes: 12 additions & 8 deletions jq/pod2nerdm.jq
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ include "urldecode";

# the base NERDm JSON schema namespace
#
def nerdm_schema: "https://data.nist.gov/od/dm/nerdm-schema/v0.3#";
def nerdm_schema: "https://data.nist.gov/od/dm/nerdm-schema/v0.4#";

# the base NERDm JSON schema namespace
# the NERDm pub schema extension namespace
#
def nerdm_pub_schema: "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#";

# the NERDm bib schema extension namespace
#
def nerdm_pub_schema: "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#";
def nerdm_bib_schema: "https://data.nist.gov/od/dm/nerdm-schema/bib/v0.4#";

# the NERDm context location
#
def nerdm_context: "https://data.nist.gov/od/dm/nerdm-pub-context.jsonld";

# where the Datacite Document Reference types are defined
#
def dciteRefType: nerdm_schema + "/definitions/DCiteReference";
def dciteRefType: nerdm_bib_schema + "/definitions/DCiteReference";

# the resource identifier provided on the command line
#
Expand Down Expand Up @@ -174,7 +178,7 @@ def ansc_coll_paths:
def cvtref: {
"@type": ["deo:BibliographicReference"],
"@id": ("#ref:" + (. | urlpath | sub("^/"; ""))),
"refType": "IsReferencedBy",
"refType": "IsSupplementTo",
"location": .,
"_extensionSchemas": [ dciteRefType ]
};
Expand Down Expand Up @@ -230,7 +234,7 @@ def dist2download:
.["filepath"] = ( .downloadURL | filepath ) |
.["@type"] = [ "nrdp:DataFile", "nrdp:DownloadableFile", "dcat:Distribution" ] |
.["@id"] = (. | componentID("cmps/")) |
.["_extensionSchemas"] = [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/DataFile" ] |
.["_extensionSchemas"] = [ nerdm_pub_schema + "/definitions/DataFile" ] |
if .format then .format = { description: .format } else . end
;

Expand All @@ -244,7 +248,7 @@ def dist2checksum:
.["filepath"] = ( .downloadURL | filepath ) |
.["@type"] = [ "nrdp:ChecksumFile", "nrdp:DownloadableFile", "dcat:Distribution" ] |
.["@id"] = (. | componentID("cmps/")) |
.["_extensionSchemas"] = [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/ChecksumFile" ] |
.["_extensionSchemas"] = [ nerdm_pub_schema + "/definitions/ChecksumFile" ] |
.["mediaType"] = "text/plain" |
.["algorithm"] = { "@type": "Thing", tag: (.filepath|extension) } |
if .description then . else .["description"] = "SHA-256 checksum value for "+(.filepath|basename|remove_extension) end |
Expand Down Expand Up @@ -284,7 +288,7 @@ def dist2inaccess:
def dist2accesspage:
.["@type"] = [ "nrdp:AccessPage", "dcat:Distribution" ] |
.["@id"] = (. | componentID("#")) |
.["_extensionSchemas"] = [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/AccessPage" ] |
.["_extensionSchemas"] = [ nerdm_pub_schema + "/definitions/AccessPage" ] |
if .format then .format = { description: .format } else . end
;

Expand Down
24 changes: 12 additions & 12 deletions jq/tests/test_pod2nerdm.jqt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#
include "pod2nerdm"; nerdm_schema
null
"https://data.nist.gov/od/dm/nerdm-schema/v0.3#"
"https://data.nist.gov/od/dm/nerdm-schema/v0.4#"

#--------------
# testing nerdm_schema()
#
include "pod2nerdm"; nerdm_pub_schema
null
"https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#"
"https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#"

#--------------
# testing nerdm_context()
Expand All @@ -31,7 +31,7 @@ null
#
include "pod2nerdm"; dciteRefType
null
"https://data.nist.gov/od/dm/nerdm-schema/v0.3#/definitions/DCiteReference"
"https://data.nist.gov/od/dm/nerdm-schema/bib/v0.4#/definitions/DCiteReference"

#--------------
# testing resid()
Expand Down Expand Up @@ -91,7 +91,7 @@ include "pod2nerdm"; pdrLandingPageURL
#
include "pod2nerdm"; map(cvtref)
[ "http://goob.net/doc1.txt", "https://goob.gov/doc2.txt" ]
[{ "@type": ["deo:BibliographicReference"],"@id":"#ref:doc1.txt", "refType": "IsReferencedBy", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/v0.3#/definitions/DCiteReference" ], "location": "http://goob.net/doc1.txt"}, { "@type": ["deo:BibliographicReference"],"@id":"#ref:doc2.txt", "refType": "IsReferencedBy", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/v0.3#/definitions/DCiteReference" ], "location": "https://goob.gov/doc2.txt"}]
[{ "@type": ["deo:BibliographicReference"],"@id":"#ref:doc1.txt", "refType": "IsSupplementTo", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/bib/v0.4#/definitions/DCiteReference" ], "location": "http://goob.net/doc1.txt"}, { "@type": ["deo:BibliographicReference"],"@id":"#ref:doc2.txt", "refType": "IsSupplementTo", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/bib/v0.4#/definitions/DCiteReference" ], "location": "https://goob.gov/doc2.txt"}]

#---------------
# testing filepath()
Expand Down Expand Up @@ -220,14 +220,14 @@ include "pod2nerdm"; map(componentID("#"))
#
include "pod2nerdm"; dist2download
{"describedBy": "http://data.nist.gov/srd/srd_data/srd13_janaf-data-defs.json", "downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json", "mediaType": "application/json","title": "Titanium Boride" }
{"describedBy": "http://data.nist.gov/srd/srd_data/srd13_janaf-data-defs.json", "downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json","mediaType": "application/json", "title": "Titanium Boride", "filepath":"srd13_B-101.json", "@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/srd13_B-101.json","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/DataFile"]}
{"describedBy": "http://data.nist.gov/srd/srd_data/srd13_janaf-data-defs.json", "downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json","mediaType": "application/json", "title": "Titanium Boride", "filepath":"srd13_B-101.json", "@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/srd13_B-101.json","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/DataFile"]}

#--------------
# testing dist2checksum()
#
include "pod2nerdm"; dist2checksum
{"downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json.sha256", "title": "Checksum for srd13_B-101.json" }
{"downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json.sha256","mediaType": "text/plain", "description": "SHA-256 checksum value for srd13_B-101.json", "title": "Checksum for srd13_B-101.json", "filepath":"srd13_B-101.json.sha256", "algorithm": {"@type": "Thing","tag": "sha256"},"@type": ["nrdp:ChecksumFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/srd13_B-101.json.sha256","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/ChecksumFile"]}
{"downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json.sha256","mediaType": "text/plain", "description": "SHA-256 checksum value for srd13_B-101.json", "title": "Checksum for srd13_B-101.json", "filepath":"srd13_B-101.json.sha256", "algorithm": {"@type": "Thing","tag": "sha256"},"@type": ["nrdp:ChecksumFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/srd13_B-101.json.sha256","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/ChecksumFile"]}

#--------------
# testing dist2hidden()
Expand All @@ -248,7 +248,7 @@ include "pod2nerdm"; dist2inaccess
#
include "pod2nerdm"; dist2accesspage
{"accessURL": "https://doi.org/10.18434/T42C7D","title": "A Library to Enable the Modeling of Optical Imaging of Finite Multi-Line Arrays"}
{"accessURL": "https://doi.org/10.18434/T42C7D","title": "A Library to Enable the Modeling of Optical Imaging of Finite Multi-Line Arrays","@type": [ "nrdp:AccessPage", "dcat:Distribution" ],"@id":"#10.18434/T42C7D","_extensionSchemas":["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/AccessPage"]}
{"accessURL": "https://doi.org/10.18434/T42C7D","title": "A Library to Enable the Modeling of Optical Imaging of Finite Multi-Line Arrays","@type": [ "nrdp:AccessPage", "dcat:Distribution" ],"@id":"#10.18434/T42C7D","_extensionSchemas":["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/AccessPage"]}

#--------------
# testing dist2comp()
Expand All @@ -267,7 +267,7 @@ include "pod2nerdm"; dist2comp
#
include "pod2nerdm"; dist2comp
{"describedBy": "http://data.nist.gov/srd/srd_data/srd13_janaf-data-defs.json", "downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json", "mediaType": "application/json","title": "Titanium Boride" }
{"describedBy": "http://data.nist.gov/srd/srd_data/srd13_janaf-data-defs.json", "downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json","mediaType": "application/json", "title": "Titanium Boride", "filepath":"srd13_B-101.json", "@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/srd13_B-101.json","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/DataFile"]}
{"describedBy": "http://data.nist.gov/srd/srd_data/srd13_janaf-data-defs.json", "downloadURL": "http://data.nist.gov/srd/srd_data/srd13_B-101.json","mediaType": "application/json", "title": "Titanium Boride", "filepath":"srd13_B-101.json", "@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/srd13_B-101.json","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/DataFile"]}

#--------------
# testing dist2comp()
Expand All @@ -277,7 +277,7 @@ include "pod2nerdm"; dist2comp
#
include "pod2nerdm"; dist2comp
{"accessURL": "http://www.nsrl.nist.gov/Downloads.htm","conformsTo": "http://www.nsrl.nist.gov/Documents/Data-Formats-of-the-NSRL-Reference-Data-Set-16.pdf","downloadURL": "http://www.nsrl.nist.gov/RDS/rds_2.50/RDS_250.iso","format": "ISO 9660 disk image","mediaType": "application/zip" }
{"accessURL": "http://www.nsrl.nist.gov/Downloads.htm","conformsTo": "http://www.nsrl.nist.gov/Documents/Data-Formats-of-the-NSRL-Reference-Data-Set-16.pdf","downloadURL": "http://www.nsrl.nist.gov/RDS/rds_2.50/RDS_250.iso","format": { "description": "ISO 9660 disk image"},"mediaType": "application/zip", "filepath":"RDS_250.iso", "@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/RDS_250.iso","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/DataFile"] }
{"accessURL": "http://www.nsrl.nist.gov/Downloads.htm","conformsTo": "http://www.nsrl.nist.gov/Documents/Data-Formats-of-the-NSRL-Reference-Data-Set-16.pdf","downloadURL": "http://www.nsrl.nist.gov/RDS/rds_2.50/RDS_250.iso","format": { "description": "ISO 9660 disk image"},"mediaType": "application/zip", "filepath":"RDS_250.iso", "@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"],"@id":"cmps/RDS_250.iso","_extensionSchemas": ["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/DataFile"] }

#--------------
# testing dist2comp()
Expand All @@ -287,7 +287,7 @@ include "pod2nerdm"; dist2comp
#
include "pod2nerdm"; dist2comp
{"accessURL": "http://webbook.nist.gov/chemistry/","description": "Landing page for the NIST Chemistry WebBook.","mediaType": "text/html"}
{ "accessURL": "http://webbook.nist.gov/chemistry/","description": "Landing page for the NIST Chemistry WebBook.","mediaType": "text/html","@type": ["nrdp:AccessPage","dcat:Distribution"],"@id":"#chemistry/","_extensionSchemas":["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/AccessPage"]}
{ "accessURL": "http://webbook.nist.gov/chemistry/","description": "Landing page for the NIST Chemistry WebBook.","mediaType": "text/html","@type": ["nrdp:AccessPage","dcat:Distribution"],"@id":"#chemistry/","_extensionSchemas":["https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/AccessPage"]}

# testing dist2comp()
#
Expand Down Expand Up @@ -389,13 +389,13 @@ include "pod2nerdm"; select_comp_type("nrdp:Subcollection"; "foo/bar")
#
include "pod2nerdm"; create_subcoll_for
"a/b/foo"
{"@id": "cmps/a/b/foo", "@type": ["nrdp:Subcollection"], "filepath": "a/b/foo", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/Subcollection" ]}
{"@id": "cmps/a/b/foo", "@type": ["nrdp:Subcollection"], "filepath": "a/b/foo", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/Subcollection" ]}

# testing insert_subcoll_comps
#
include "pod2nerdm"; insert_subcoll_comps
[{ "title": "Titanium Boride", "filepath": "foo/srd13_B-101.json","@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"]},{ "title": "foo", "filepath": "foo", "@type": [ "nrdp:Subcollection"]},{"title": "Titanium Boride","filepath": "foo/bar/srd13_B-101.json","@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"]},{ "title": "foo bar goo", "filepath": "foo/bar/goo", "@type": ["nrdp:Subcollection"]}]
[{"@id": "cmps/foo/bar", "@type": ["nrdp:Subcollection"], "filepath": "foo/bar", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/Subcollection" ]},{ "title": "Titanium Boride", "filepath": "foo/srd13_B-101.json","@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"]},{ "title": "foo", "filepath": "foo", "@type": [ "nrdp:Subcollection"]},{"title": "Titanium Boride","filepath": "foo/bar/srd13_B-101.json","@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"]},{ "title": "foo bar goo", "filepath": "foo/bar/goo", "@type": ["nrdp:Subcollection"]}]
[{"@id": "cmps/foo/bar", "@type": ["nrdp:Subcollection"], "filepath": "foo/bar", "_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/Subcollection" ]},{ "title": "Titanium Boride", "filepath": "foo/srd13_B-101.json","@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"]},{ "title": "foo", "filepath": "foo", "@type": [ "nrdp:Subcollection"]},{"title": "Titanium Boride","filepath": "foo/bar/srd13_B-101.json","@type": ["nrdp:DataFile","nrdp:DownloadableFile","dcat:Distribution"]},{ "title": "foo bar goo", "filepath": "foo/bar/goo", "@type": ["nrdp:Subcollection"]}]



Expand Down
13 changes: 7 additions & 6 deletions jq/tests/test_podds2resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import os, unittest, json, subprocess as subproc, types, pdb
import ejsonschema as ejs

nerdm = "https://data.nist.gov/od/dm/nerdm-schema/v0.3#"
nerdmpub = "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#"
nerdm = "https://data.nist.gov/od/dm/nerdm-schema/v0.4#"
nerdmpub = "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#"
nerdmbib = "https://data.nist.gov/od/dm/nerdm-schema/bib/v0.4#"
datadir = os.path.join(os.path.dirname(__file__), "data")
janaffile = os.path.join(datadir, "janaf_pod.json")
corrfile = os.path.join(datadir, "CORR-DATA.json")
Expand All @@ -29,7 +30,7 @@ def test_context(self):

def test_schema(self):
self.assertEquals(self.out['_schema'],
"https://data.nist.gov/od/dm/nerdm-schema/v0.3#")
"https://data.nist.gov/od/dm/nerdm-schema/v0.4#")
def test_extsch(self):

exts = self.out['_extensionSchemas']
Expand Down Expand Up @@ -101,13 +102,13 @@ def test_references(self):
self.assertIsInstance(refs[0]['@type'], list)
self.assertIsInstance(refs[0]['@type'][0], types.StringTypes)
self.assertEquals(refs[0]['@type'], ["deo:BibliographicReference"])
self.assertEquals(refs[0]['refType'], "IsReferencedBy")
self.assertEquals(refs[0]['refType'], "IsSupplementTo")
self.assertEquals(refs[0]['location'],
"http://www.nist.gov/data/PDFfiles/jpcrdS1V14.pdf")

exts = refs[0]['_extensionSchemas']
self.assertEquals(len(exts), 1)
self.assertIn(nerdm+"/definitions/DCiteReference", exts)
self.assertIn(nerdmbib+"/definitions/DCiteReference", exts)

def test_hierarchy(self):
self.assertIn("dataHierarchy", self.out,
Expand Down Expand Up @@ -142,7 +143,7 @@ def test_context(self):

def test_schema(self):
self.assertEquals(self.out['_schema'],
"https://data.nist.gov/od/dm/nerdm-schema/v0.3#")
"https://data.nist.gov/od/dm/nerdm-schema/v0.4#")
def test_extsch(self):

exts = self.out['_extensionSchemas']
Expand Down
8 changes: 4 additions & 4 deletions model/examples/hitsc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": "https://data.nist.gov/od/dm/nerdm-pub-context.jsonld",
"_schema": "https://data.nist.gov/od/dm/nerdm-schema/v0.3#",
"_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.3#/definitions/DataPublication" ],
"_schema": "https://data.nist.gov/od/dm/nerdm-schema/v0.4#",
"_extensionSchemas": [ "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.4#/definitions/DataPublication" ],

"@type": [ "nrdp:Database", "nrdp:SRD", "nrdp:PublishedDataResource" ],
"@id": "ark:/88434/sdp0fjspek353",
Expand Down Expand Up @@ -48,12 +48,12 @@
],
"references": [
{
"@type": "deo:BibliographicReference",
"@type": [ "npg:Article", "schema:Article" ],
"refType": "IsDocumentedBy",
"label": "User Manual",
"location": "https://srdata.nist.gov/CeramicDataPortal/Manual/HtsHelper",
"_extensionSchemas": [
"https://data.nist.gov/od/dm/nerdm-schema/v0.3#/definitions/DCiteReference"
"https://data.nist.gov/od/dm/nerdm-schema/bib/v0.4#/definitions/DCiteReference"
]
}
],
Expand Down
Loading

0 comments on commit c8e49dc

Please sign in to comment.