Skip to content

Commit 45a390b

Browse files
committed
update vocabularies
1 parent 7fc68df commit 45a390b

File tree

6 files changed

+55
-55
lines changed

6 files changed

+55
-55
lines changed

lib/bald/__init__.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ def check_uri(self, uri):
283283
return result
284284

285285

286-
class Subject(object):
287-
_rdftype = 'bald__Subject'
286+
class Resource(object):
287+
_rdftype = 'bald__Resource'
288288
def __init__(self, baseuri, relative_id, attrs=None, prefixes=None,
289289
aliases=None, alias_graph=None):
290290
"""
291-
A subject of metadata statements.
291+
A resource of metadata statements.
292292
293293
attrs: an dictionary of key value pair attributes
294294
"""
@@ -491,7 +491,7 @@ def _graph_elem_attrs(self, remaining_attrs):
491491
if is_http_uri(vuri):
492492
vstr = self.link_template
493493
vstr = vstr.format(url=vuri, key=val)
494-
elif isinstance(val, Subject):
494+
elif isinstance(val, Resource):
495495
vstr = ''
496496
else:
497497
vstr = '{key}'.format(key=val)
@@ -519,7 +519,7 @@ def _graph_elem_attrs(self, remaining_attrs):
519519

520520
def viewgraph(self):
521521
"""
522-
Return html to render the Subject as a graph diagram, using the JointJS engine.
522+
Return html to render the Resource as a graph diagram, using the JointJS engine.
523523
524524
"""
525525

@@ -555,7 +555,7 @@ def rdfnode(self, graph):
555555
for obj in objs:
556556

557557
rdfpred = self.unpack_predicate(attr)
558-
if isinstance(obj, Subject):
558+
if isinstance(obj, Resource):
559559
if obj.identity is None:
560560
rdfobj = obj.rdfnode(graph)
561561
else:
@@ -582,7 +582,7 @@ def rdfnode(self, graph):
582582
elif isinstance(objs, list):
583583
list_items.append(rdfobj)
584584
# recurse and build the related objects
585-
if isinstance(obj, Subject) and obj.identity is not None:
585+
if isinstance(obj, Resource) and obj.identity is not None:
586586
obj_ref = rdflib.URIRef(obj.identity)
587587
if not ((obj_ref, None, None) in graph):
588588
node = obj.rdfnode(graph)
@@ -595,11 +595,11 @@ def rdfnode(self, graph):
595595

596596
def rdfgraph(self):
597597
"""
598-
Return an rdflib.Graph representing the Subject.
598+
Return an rdflib.Graph representing the Resource.
599599
600600
"""
601601
graph = rdflib.Graph()
602-
graph.bind('bald', 'http://binary-array-ld.net/latest/')
602+
graph.bind('bald', 'http://def.binary-array-ld.net/development/')
603603
graph.bind('this', self.baseuri + '/')
604604
for prefix_name in self.prefixes():
605605

@@ -623,11 +623,11 @@ def rdfgraph(self):
623623
return graph
624624

625625

626-
class Reference(Subject):
626+
class Reference(Resource):
627627
_rdftype = 'bald__Reference'
628628

629629

630-
class Array(Subject):
630+
class Array(Resource):
631631
_rdftype = 'bald__Array'
632632

633633
@property
@@ -662,7 +662,7 @@ def graph_elems(self):
662662
return instances, links
663663

664664

665-
class Container(Subject):
665+
class Container(Resource):
666666
_rdftype = 'bald__Container'
667667

668668
def graph_elems(self):
@@ -786,7 +786,7 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
786786

787787
# check that default set is handled, i.e. bald__ and rdf__
788788
if 'bald__' not in prefixes:
789-
prefixes['bald__'] = "http://binary-array-ld.net/latest/"
789+
prefixes['bald__'] = "http://def.binary-array-ld.net/development/"
790790

791791
if 'rdf__' not in prefixes:
792792
prefixes['rdf__'] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -934,7 +934,7 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
934934
var = Array(baseuri, name, sattrs, prefixes=prefixes,
935935
aliases=aliases, alias_graph=aliasgraph)
936936
else:
937-
var = Subject(baseuri, name, sattrs, prefixes=prefixes,
937+
var = Resource(baseuri, name, sattrs, prefixes=prefixes,
938938
aliases=aliases, alias_graph=aliasgraph)
939939
root_container.attrs['bald__contains'].add(var)
940940

@@ -944,7 +944,7 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
944944
reference_prefixes = dict()
945945
reference_graph = copy.copy(aliasgraph)
946946

947-
response = cache['http://binary-array-ld.net/latest']
947+
response = cache['http://def.binary-array-ld.net/development']
948948
reference_graph.parse(data=response.text, format='xml')
949949

950950
# # reference_graph.parse('http://binary-array-ld.net/latest?_format=ttl')
@@ -959,7 +959,7 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
959959

960960
# refs_ = reference_graph.query(qstr)
961961

962-
qstr = ('prefix bald: <http://binary-array-ld.net/latest/> '
962+
qstr = ('prefix bald: <http://def.binary-array-ld.net/development/> '
963963
'prefix skos: <http://www.w3.org/2004/02/skos/core#> '
964964
'prefix owl: <http://www.w3.org/2002/07/owl#> '
965965
'select ?s '
@@ -969,7 +969,7 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
969969
'filter(?rtype = owl:Class) '
970970
'}')
971971

972-
qstr = ('prefix bald: <http://binary-array-ld.net/latest/> '
972+
qstr = ('prefix bald: <http://def.binary-array-ld.net/development/> '
973973
'prefix skos: <http://www.w3.org/2004/02/skos/core#> '
974974
'prefix owl: <http://www.w3.org/2002/07/owl#> '
975975
'select ?s '
@@ -982,15 +982,15 @@ def load_netcdf(afilepath, baseuri=None, alias_dict=None, cache=None):
982982

983983
non_ref_prefs = [str(ref[0]) for ref in list(refs)]
984984

985-
qstr = ('prefix bald: <http://binary-array-ld.net/latest/> '
985+
qstr = ('prefix bald: <http://def.binary-array-ld.net/development/> '
986986
'prefix skos: <http://www.w3.org/2004/02/skos/core#> '
987987
'prefix owl: <http://www.w3.org/2002/07/owl#> '
988988
'select ?s '
989989
'where { '
990-
' {?s rdfs:range bald:Subject .} '
990+
' {?s rdfs:range bald:Resource .} '
991991
' UNION '
992992
' {?s rdfs:range ?as . '
993-
' ?as rdfs:subClassOf bald:Subject .} '
993+
' ?as rdfs:subClassOf bald:Resource .} '
994994
'}')
995995

996996
refs = reference_graph.query(qstr)
@@ -1121,21 +1121,21 @@ def validate(root_container, sval=None, cache=None, uris_resolve=False):
11211121
if sval is None:
11221122
sval = bv.StoredValidation()
11231123

1124-
root_val = bv.ContainerValidation(subject=root_container, httpcache=cache,
1124+
root_val = bv.ContainerValidation(resource=root_container, httpcache=cache,
11251125
uris_resolve=uris_resolve)
11261126
sval.stored_exceptions += root_val.exceptions()
1127-
for subject in root_container.attrs.get('bald__contains', set()):
1128-
if isinstance(subject, Array):
1129-
array_val = bv.ArrayValidation(subject, httpcache=cache,
1127+
for resource in root_container.attrs.get('bald__contains', set()):
1128+
if isinstance(resource, Array):
1129+
array_val = bv.ArrayValidation(resource, httpcache=cache,
11301130
uris_resolve=uris_resolve)
11311131
sval.stored_exceptions += array_val.exceptions()
1132-
elif isinstance(subject, Container):
1133-
sval = validate(subject, sval=sval, cache=cache,
1132+
elif isinstance(resource, Container):
1133+
sval = validate(resource, sval=sval, cache=cache,
11341134
uris_resolve=uris_resolve)
1135-
elif isinstance(subject, Subject):
1136-
subject_val = bv.SubjectValidation(subject, httpcache=cache,
1135+
elif isinstance(resource, Resource):
1136+
resource_val = bv.ResourceValidation(resource, httpcache=cache,
11371137
uris_resolve=uris_resolve)
1138-
sval.stored_exceptions += subject_val.exceptions()
1138+
sval.stored_exceptions += resource_val.exceptions()
11391139

11401140
return sval
11411141

lib/bald/tests/integration/HTML/multi_array_reference.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@
177177
var file://CDL/multi_array_reference.cdl = instance('file://CDL/multi_array_reference.cdl:<a xlink:href="http://binary-array-ld.net/latest/Container" xlink:show=new text-decoration="underline">bald__Container</a>', ['<a xlink:href="http://binary-array-ld.net/latest/contains" xlink:show=new text-decoration="underline">bald__contains</a>: |'], '#878800');
178178
var file://CDL/multi_array_reference.cdl/data_variable1 = instance('file://CDL/multi_array_reference.cdl/data_variable1:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |', '<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 11, 17', 'long_name: Gerald', 'obtype: <a xlink:href="http://codes.wmo.int/common/observation-type/METCE/2013/SamplingObservation" xlink:show=new text-decoration="underline">metce__SamplingObservation</a>'], '#878800');
179179
var file://CDL/multi_array_reference.cdl/data_variable2 = instance('file://CDL/multi_array_reference.cdl/data_variable2:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |', '<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 11, 17', 'long_name: Imelda', 'obtype: <a xlink:href="http://codes.wmo.int/common/observation-type/METCE/2013/SamplingObservation" xlink:show=new text-decoration="underline">metce__SamplingObservation</a>'], '#878800');
180-
var file://CDL/multi_array_reference.cdl/list_collection = instance('file://CDL/multi_array_reference.cdl/list_collection:<a xlink:href="http://binary-array-ld.net/latest/Subject" xlink:show=new text-decoration="underline">bald__Subject</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |'], '#878800');
181-
var file://CDL/multi_array_reference.cdl/location_reference_system = instance('file://CDL/multi_array_reference.cdl/location_reference_system:<a xlink:href="http://binary-array-ld.net/latest/Subject" xlink:show=new text-decoration="underline">bald__Subject</a>', ['pcode: 4897'], '#878800');
180+
var file://CDL/multi_array_reference.cdl/list_collection = instance('file://CDL/multi_array_reference.cdl/list_collection:<a xlink:href="http://binary-array-ld.net/latest/Resource" xlink:show=new text-decoration="underline">bald__Resource</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |'], '#878800');
181+
var file://CDL/multi_array_reference.cdl/location_reference_system = instance('file://CDL/multi_array_reference.cdl/location_reference_system:<a xlink:href="http://binary-array-ld.net/latest/Resource" xlink:show=new text-decoration="underline">bald__Resource</a>', ['pcode: 4897'], '#878800');
182182
var file://CDL/multi_array_reference.cdl/location_variable = instance('file://CDL/multi_array_reference.cdl/location_variable:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |', '<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 11, 17'], '#878800');
183183
var file://CDL/multi_array_reference.cdl/pdim0 = instance('file://CDL/multi_array_reference.cdl/pdim0:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 11'], '#878800');
184184
var file://CDL/multi_array_reference.cdl/pdim1 = instance('file://CDL/multi_array_reference.cdl/pdim1:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 17'], '#878800');
185-
var file://CDL/multi_array_reference.cdl/set_collection = instance('file://CDL/multi_array_reference.cdl/set_collection:<a xlink:href="http://binary-array-ld.net/latest/Subject" xlink:show=new text-decoration="underline">bald__Subject</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |'], '#878800');
185+
var file://CDL/multi_array_reference.cdl/set_collection = instance('file://CDL/multi_array_reference.cdl/set_collection:<a xlink:href="http://binary-array-ld.net/latest/Resource" xlink:show=new text-decoration="underline">bald__Resource</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |'], '#878800');
186186
link(file://CDL/multi_array_reference.cdl, file://CDL/multi_array_reference.cdl/data_variable1, 'bald__contains', 'top', true);
187187
link(file://CDL/multi_array_reference.cdl, file://CDL/multi_array_reference.cdl/data_variable2, 'bald__contains', 'top', true);
188188
link(file://CDL/multi_array_reference.cdl, file://CDL/multi_array_reference.cdl/list_collection, 'bald__contains', 'top', true);

lib/bald/tests/integration/TTL/ProcessChain0300.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
this:step2 ;
1818
bald:isPrefixedBy "prefix_list" .
1919

20-
this:gfsmos_process_chain a bald:Subject ;
20+
this:gfsmos_process_chain a bald:Resource ;
2121
this:OM_Process "(step1 step2)" .
2222

23-
this:step1 a bald:Subject ;
23+
this:step1 a bald:Resource ;
2424
this:LE_ProcessStep <https://codes.nws.noaa.gov/NumericalWeatherPrediction/Models/GFS13> ;
2525
this:LE_Source <https://codes.nws.noaa.gov/DataAssimilation/Methods/GDAS13> .
2626

27-
this:step2 a bald:Subject ;
27+
this:step2 a bald:Resource ;
2828
this:LE_ProcessStep <https://codes.nws.noaa.gov/StatisticalPostProcessing/Methods/GFSMOS05> ;
2929
this:LE_Source <https://codes.nws.noaa.gov/NumericalWeatherPrediction/Models/GFS13> .
3030

lib/bald/tests/integration/TTL/multi_array_reference.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
this:set_collection ;
1818
bald:isPrefixedBy "prefix_list" .
1919

20-
this:list_collection a bald:Subject ;
20+
this:list_collection a bald:Resource ;
2121
bald:references ( this:data_variable1 this:data_variable2 ) .
2222

2323
this:pdim0 a bald:Array ;
@@ -26,11 +26,11 @@ this:pdim0 a bald:Array ;
2626
this:pdim1 a bald:Array ;
2727
bald:shape ( 17 ) .
2828

29-
this:set_collection a bald:Subject ;
29+
this:set_collection a bald:Resource ;
3030
bald:references this:data_variable1,
3131
this:data_variable2 .
3232

33-
this:location_reference_system a bald:Subject ;
33+
this:location_reference_system a bald:Resource ;
3434
this:pcode "4897" .
3535

3636
this:data_variable1 a bald:Array ;

lib/bald/tests/integration/TTL/point_template.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
NetCDF:history "This file was created on 2016-09-22T18:16:06.590413Z" ;
8080
NetCDF:title "Oceanographic and surface meteorological data collected from the cordell bank monitoring station by the National Centers for Environmental Information (NCEI) in the Cordell Bank National Marine Sanctuary from 2015-03-25 to 2015-03-25" .
8181

82-
this:instrument1 a bald:Subject ;
82+
this:instrument1 a bald:Resource ;
8383
this:accuracy "" ;
8484
this:calibration_date "2016-03-25" ;
8585
this:make_model "SBE-37" ;
@@ -89,7 +89,7 @@ this:instrument1 a bald:Subject ;
8989
CFTerms:comment "serial number and calibration dates are bogus" ;
9090
NetCDF:long_name "Seabird 37 Microcat" .
9191

92-
this:platform1 a bald:Subject ;
92+
this:platform1 a bald:Resource ;
9393
this:call_sign "" ;
9494
this:ices_code "" ;
9595
this:imo_code "" ;
@@ -153,7 +153,7 @@ this:temp a bald:Array ;
153153
NetCDF:valid_max 100.0 ;
154154
NetCDF:valid_min 0.0 .
155155

156-
this:crs a bald:Subject ;
156+
this:crs a bald:Resource ;
157157
this:epsg_code "EPSG:4326" ;
158158
this:grid_mapping_name "latitude_longitude" ;
159159
this:inverse_flattening 298.257223563 ;

lib/bald/validation.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def exceptions(self):
6161
# class ValidationSet(Validation):?
6262

6363

64-
class SubjectValidation(Validation):
65-
def __init__(self, subject, httpcache=None, uris_resolve=False):
66-
self.subject = subject
64+
class ResourceValidation(Validation):
65+
def __init__(self, resource, httpcache=None, uris_resolve=False):
66+
self.resource = resource
6767
if isinstance(httpcache, bald.HttpCache):
6868
self.cache = httpcache
6969
else:
@@ -95,26 +95,26 @@ def _check_uri(uri, exceptions):
9595
return exceptions
9696

9797
#''' Skip checking prefixes as whole graphs could be big!
98-
for pref, uri in self.subject.prefixes().items():
98+
for pref, uri in self.resource.prefixes().items():
9999
exceptions = _check_uri(uri, exceptions)
100100
#'''
101-
for alias, uri in self.subject.aliases.items():
101+
for alias, uri in self.resource.aliases.items():
102102
exceptions = _check_uri(uri, exceptions)
103-
for attr, value in self.subject.attrs.items():
103+
for attr, value in self.resource.attrs.items():
104104
att = ''
105105
if isinstance(attr, six.string_types):
106-
att = self.subject.unpack_predicate(attr)
106+
att = self.resource.unpack_predicate(attr)
107107
if self.cache.is_http_uri(att):
108108
exceptions = _check_uri(att, exceptions)
109109
if isinstance(value, six.string_types):
110-
val = self.subject.unpack_rdfobject(value, att)
110+
val = self.resource.unpack_rdfobject(value, att)
111111
if self.cache.is_http_uri(val):
112112
exceptions = _check_uri(val, exceptions)
113113
return exceptions
114114

115115
def check_attr_domain_range(self, exceptions):
116-
for attr, value in self.subject.attrs.items():
117-
uri = self.subject.unpack_predicate(attr)
116+
for attr, value in self.resource.attrs.items():
117+
uri = self.resource.unpack_predicate(attr)
118118
# if self.cache.is_http_uri(uri) and self.cache.check_uri(uri):
119119
# # thus we have a payload
120120
# # go rdf
@@ -145,8 +145,8 @@ def check_attr_domain_range(self, exceptions):
145145
# has an rdf:type which is the same as the one required by
146146
# the object property constraint
147147
# The value may be a URI or it may be a reference to another
148-
# subject within the file.
149-
# therefore subjects in the file have to be typed?!?
148+
# resource within the file.
149+
# therefore resources in the file have to be typed?!?
150150

151151
# import pdb; pdb.set_trace()
152152
# if qres.domains != rdflib.term.URIRef(value):
@@ -155,13 +155,13 @@ def check_attr_domain_range(self, exceptions):
155155
return exceptions
156156

157157

158-
class ContainerValidation(SubjectValidation):
158+
class ContainerValidation(ResourceValidation):
159159

160160
def __init__(self, **kwargs):
161161
super(ContainerValidation, self).__init__(**kwargs)
162162

163163

164-
class ArrayValidation(SubjectValidation):
164+
class ArrayValidation(ResourceValidation):
165165
def __init__(self, array, httpcache=None, uris_resolve=False):
166166
self.array = array
167167
super(ArrayValidation, self).__init__(array, httpcache, uris_resolve)

0 commit comments

Comments
 (0)