Skip to content

Commit 79e63a3

Browse files
authored
Support Adding File Locations to the ORE (#29)
* Add a way to set prov:atLocation * Remove https * Add prov to test namespace
1 parent 71b8fcc commit 79e63a3

11 files changed

+78
-0
lines changed

lib_common/src/d1_common/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"dcterms": "http://purl.org/dc/terms/",
9191
"ore": "http://www.openarchives.org/ore/terms/",
9292
"foaf": "http://xmlns.com/foaf/0.1/",
93+
"prov": "http://www.w3.org/ns/prov#",
9394
}
9495
ORE_FORMAT_ID = "http://www.openarchives.org/ore/terms"
9596
ORE_SOFTWARE_ID = "DataONE.org Python ITK {}".format(VERSION)

lib_common/src/d1_common/resource_map.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
ore: <http://www.openarchives.org/ore/terms/>
4141
dcterms: <http://purl.org/dc/terms/>
4242
cito: <http://purl.org/spar/cito/>
43+
prov: <http://www.w3.org/ns/prov#>
4344
4445
Note:
4546
@@ -62,6 +63,7 @@
6263
DCTERMS = rdflib.Namespace(d1_common.const.ORE_NAMESPACE_DICT["dcterms"])
6364
CITO = rdflib.Namespace(d1_common.const.ORE_NAMESPACE_DICT["cito"])
6465
ORE = rdflib.Namespace(d1_common.const.ORE_NAMESPACE_DICT["ore"])
66+
PROV = rdflib.Namespace(d1_common.const.ORE_NAMESPACE_DICT["prov"])
6567

6668

6769
def createSimpleResourceMap(ore_pid, scimeta_pid, sciobj_pid_list):
@@ -425,6 +427,21 @@ def addDataDocuments(self, scidata_pid_list, scimeta_pid=None):
425427
self.setDocumentedBy(dpid, scimeta_pid)
426428
self.setDocuments(scimeta_pid, dpid)
427429

430+
def setAtLocation(self, pid, location):
431+
"""Establishes a triple relationship between a pid and a file path.
432+
433+
``pid`` atLocation ``location``.
434+
435+
Args:
436+
pid: str
437+
PID of the object whose location is being described
438+
location: str
439+
The on-disk location of the object
440+
"""
441+
self._check_initialized()
442+
resoure_map_member = self.getObjectByPid(pid)
443+
self.add((resoure_map_member, PROV.atLocation, rdflib.term.Literal(location)))
444+
428445
def getResourceMapPid(self):
429446
"""Returns:
430447

lib_common/src/d1_common/tests/test_resource_map.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,9 @@ def test_1180(self, mn_client_v2, tricky_identifier_dict):
459459

460460
for agg_pid in ore.getAggregatedScienceMetadataPids():
461461
assert unicode_pid in agg_pid
462+
463+
def test_1190(self, mn_client_v2):
464+
ore = self._create()
465+
ore.addResource("resource1_pid")
466+
ore.setAtLocation("resource1_pid", "scripts/data_cleaning")
467+
self.sample.assert_equals(ore, "set_at_location", mn_client_v2)

test_utilities/src/d1_test/test_docs/sample/test_resource_map_add_data_documents_by_mn_v2.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@prefix dcterms: <http://purl.org/dc/terms/> .
44
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
55
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
67
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
78
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
89
@prefix xml: <http://www.w3.org/XML/1998/namespace> .

test_utilities/src/d1_test/test_docs/sample/test_resource_map_add_metadata_document_by_mn_v2.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@prefix dcterms: <http://purl.org/dc/terms/> .
44
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
55
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
67
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
78
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
89
@prefix xml: <http://www.w3.org/XML/1998/namespace> .

test_utilities/src/d1_test/test_docs/sample/test_resource_map_add_resource_mn_v2.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@prefix dcterms: <http://purl.org/dc/terms/> .
44
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
55
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
67
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
78
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
89
@prefix xml: <http://www.w3.org/XML/1998/namespace> .

test_utilities/src/d1_test/test_docs/sample/test_resource_map_init_mn_v2.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@prefix dcterms: <http://purl.org/dc/terms/> .
44
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
55
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
67
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
78
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
89
@prefix xml: <http://www.w3.org/XML/1998/namespace> .

test_utilities/src/d1_test/test_docs/sample/test_resource_map_serialize_mn_v2.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@prefix dcterms: <http://purl.org/dc/terms/> .
44
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
55
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
67
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
78
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
89
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@prefix cito: <http://purl.org/spar/cito/> .
2+
@prefix dc: <http://purl.org/dc/elements/1.1/> .
3+
@prefix dcterms: <http://purl.org/dc/terms/> .
4+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
5+
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
7+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
8+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
9+
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
10+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
11+
12+
<https://cn.dataone.org/cn/v2/resolve/ore_pid> a ore:ResourceMap ;
13+
dcterms:creator "DataONE.org Python ITK[VERSION]" ;
14+
dcterms:identifier "ore_pid" ;
15+
ore:describes <https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> .
16+
17+
ore:Aggregation rdfs:label "Aggregation" ;
18+
rdfs:isDefinedBy ore: .
19+
20+
<https://cn.dataone.org/cn/v2/resolve/resource1_pid> dcterms:identifier "resource1_pid" ;
21+
ore:isAggregatedBy <https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> ;
22+
prov:atLocation "scripts/data_cleaning" .
23+
24+
<https://cn.dataone.org/cn/v2/resolve/data2_pid> dcterms:identifier "data2_pid" ;
25+
cito:isDocumentedBy <https://cn.dataone.org/cn/v2/resolve/meta_pid> ;
26+
ore:isAggregatedBy <https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> .
27+
28+
<https://cn.dataone.org/cn/v2/resolve/data3_pid> dcterms:identifier "data3_pid" ;
29+
cito:isDocumentedBy <https://cn.dataone.org/cn/v2/resolve/meta_pid> ;
30+
ore:isAggregatedBy <https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> .
31+
32+
<https://cn.dataone.org/cn/v2/resolve/data_pid> dcterms:identifier "data_pid" ;
33+
cito:isDocumentedBy <https://cn.dataone.org/cn/v2/resolve/meta_pid> ;
34+
ore:isAggregatedBy <https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> .
35+
36+
<https://cn.dataone.org/cn/v2/resolve/meta_pid> dcterms:identifier "meta_pid" ;
37+
cito:documents <https://cn.dataone.org/cn/v2/resolve/data2_pid>,
38+
<https://cn.dataone.org/cn/v2/resolve/data3_pid>,
39+
<https://cn.dataone.org/cn/v2/resolve/data_pid> ;
40+
ore:isAggregatedBy <https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> .
41+
42+
<https://cn.dataone.org/cn/v2/resolve/ore_pid#aggregation> a ore:Aggregation ;
43+
ore:aggregates <https://cn.dataone.org/cn/v2/resolve/data2_pid>,
44+
<https://cn.dataone.org/cn/v2/resolve/data3_pid>,
45+
<https://cn.dataone.org/cn/v2/resolve/data_pid>,
46+
<https://cn.dataone.org/cn/v2/resolve/meta_pid>,
47+
<https://cn.dataone.org/cn/v2/resolve/resource1_pid> .

test_utilities/src/d1_test/test_docs/sample/test_resource_map_set_documented_by_mn_v2.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@prefix dcterms: <http://purl.org/dc/terms/> .
44
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
55
@prefix ore: <http://www.openarchives.org/ore/terms/> .
6+
@prefix prov: <http://www.w3.org/ns/prov#> .
67
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
78
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
89
@prefix xml: <http://www.w3.org/XML/1998/namespace> .

0 commit comments

Comments
 (0)