Skip to content

Commit 72d3b9f

Browse files
committed
fixing the metadata of all tests
1 parent 7537949 commit 72d3b9f

61 files changed

Lines changed: 4799 additions & 24 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ gem 'base64', '~> 0.3.0'
3939
gem 'debase', '~> 0.2.5.beta2'
4040

4141
gem 'ftr_ruby', '~> 0.1.4'
42+
43+
gem "triple_easy", "~> 0.1.0"
44+
45+
gem "fair_champion_harvester", "~> 0.1.4"
46+
47+
gem "http", "~> 6.0"

Gemfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ GEM
3131
scanf (~> 1.0)
3232
sxp (~> 2.0)
3333
unicode-types (~> 1.8)
34+
fair_champion_harvester (0.1.4)
3435
faraday (1.10.4)
3536
faraday-em_http (~> 1.0)
3637
faraday-em_synchrony (~> 1.0)
@@ -81,6 +82,9 @@ GEM
8182
concurrent-ruby (~> 1.0)
8283
hashdiff (1.2.1)
8384
htmlentities (4.4.2)
85+
http (6.0.2)
86+
http-cookie (~> 1.0)
87+
llhttp (~> 0.6.1)
8488
http-accept (1.7.0)
8589
http-cookie (1.1.0)
8690
domain_name (~> 0.5)
@@ -137,6 +141,7 @@ GEM
137141
sparql-client (~> 3.2, >= 3.2.2)
138142
yaml-ld (~> 0.0)
139143
lint_roller (1.1.0)
144+
llhttp (0.6.1)
140145
logger (1.7.0)
141146
matrix (0.4.3)
142147
metainspector (5.11.2)
@@ -375,6 +380,7 @@ GEM
375380
temple (0.10.4)
376381
thor (1.5.0)
377382
tilt (2.7.0)
383+
triple_easy (0.1.0)
378384
tux (0.3.0)
379385
ripl (>= 0.3.5)
380386
ripl-multi_line (>= 0.2.4)
@@ -411,7 +417,9 @@ DEPENDENCIES
411417
bcrypt
412418
debase (~> 0.2.5.beta2)
413419
dotenv (~> 2.8)
420+
fair_champion_harvester (~> 0.1.4)
414421
ftr_ruby (~> 0.1.4)
422+
http (~> 6.0)
415423
json (~> 2.7.1)
416424
json-canonicalization (~> 1.0.0)
417425
jsonpath (~> 1.1)
@@ -434,6 +442,7 @@ DEPENDENCIES
434442
sinatra (~> 2.2)
435443
sinatra-cross_origin
436444
swagger-blocks (~> 3.0.0)
445+
triple_easy (~> 0.1.0)
437446
tux
438447
webmock (~> 3.18)
439448
xml-simple (~> 1.1.8)

app/controllers/routes.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ def set_routes(classes: [])
3030
halt erb :listtests, layout: :listtests_layout
3131
end
3232

33-
# This is fixed here, but needs to be reflected in the Core Tests
34-
# # TODO - fix Core Tests to have the same behavior
35-
# # prefix 'community-tests' comes from basePath in the environment
36-
# then endpointPath in the DCAT is created by appending /assess/test/ to that, followed by ID
37-
# # we should do the same in the core tests
33+
3834
post "/#{basepath}/assess/test/:id" do
3935
content_type :json
4036
id = params[:id]

app/public/tests/html/harvesting.html

Lines changed: 279 additions & 0 deletions
Large diffs are not rendered by default.

app/tests/fc_data_authorization.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def self.fc_data_authorization_meta
66
testid: 'fc_data_authorization',
77
description: "Test a discovered data GUID for the ability to implement authentication and authorization in its resolution protocol. Currently passes InChI Keys, DOIs, Handles, and URLs. It also searches the metadata for the Dublin Core 'accessRights' property, which may point to a document describing the data access process. Recognition of other identifiers will be added upon request by the community.",
88

9-
metric: 'https://doi.org/10.25504/FAIRsharing.VrP6sm',
9+
metric: 'https://w3id.org/fair-metrics/general/FM_A1-2_M_Auth',
1010
indicators: 'https://doi.org/10.25504/FAIRsharing.8e0027',
1111
type: 'http://edamontology.org/operation_2428',
1212
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
class FAIRTest
2+
def self.fc_data_authorization_meta
3+
{
4+
testversion: HARVESTER_VERSION + ':' + 'Tst-2.0.1',
5+
testname: 'OSTrails Core: Data Authorization',
6+
testid: 'fc_data_authorization',
7+
description: "Test a discovered data GUID for the ability to implement authentication and authorization in its resolution protocol. Currently passes InChI Keys, DOIs, Handles, and URLs. It also searches the metadata for the Dublin Core 'accessRights' property, which may point to a document describing the data access process. Recognition of other identifiers will be added upon request by the community.",
8+
9+
metric: 'https://w3id.org/fair-metrics/general/FM_A1-2_M_Auth',
10+
indicators: 'https://doi.org/10.25504/FAIRsharing.8e0027',
11+
type: 'http://edamontology.org/operation_2428',
12+
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
13+
keywords: ['FAIR Assessment', 'FAIR Principles'],
14+
themes: ['http://edamontology.org/topic_4012'],
15+
organization: 'OSTrails Project',
16+
org_url: 'https://ostrails.eu/',
17+
responsible_developer: 'Mark D Wilkinson',
18+
email: 'mark.wilkinson@upm.es',
19+
response_description: 'The response is "pass", "fail" or "indeterminate"',
20+
schemas: { 'resource_identifier' => ['string', 'the GUID being tested'] },
21+
organizations: [{ 'name' => 'OSTrails Project', 'url' => 'https://ostrails.eu/' }],
22+
individuals: [{ 'name' => 'Mark D Wilkinson', 'email' => 'mark.wilkinson@upm.es' }],
23+
creator: 'https://orcid.org/0000-0001-6960-357X',
24+
protocol: ENV.fetch('TEST_PROTOCOL', 'https'),
25+
host: ENV.fetch('TEST_HOST', 'localhost'),
26+
basePath: ENV.fetch('TEST_PATH', '/tests')
27+
}
28+
end
29+
30+
def self.fc_data_authorization(guid:)
31+
FtrRuby::Output.clear_comments
32+
33+
output = FtrRuby::Output.new(
34+
testedGUID: guid,
35+
meta: fc_data_authorization_meta
36+
)
37+
38+
output.comments << "INFO: TEST VERSION '#{fc_data_authorization_meta[:testversion]}'\n"
39+
40+
metadata = FAIRChampionHarvester::Core.resolveit(guid) # this is where the magic happens!
41+
42+
metadata.comments.each do |c|
43+
output.comments << c
44+
end
45+
46+
if metadata.guidtype == 'unknown'
47+
output.score = 'indeterminate'
48+
output.comments << "INDETERMINATE: The identifier #{guid} did not match any known identification system.\n"
49+
return output.createEvaluationResponse
50+
end
51+
52+
hash = metadata.hash
53+
54+
properties = FAIRChampionHarvester::Core.deep_dive_properties(hash)
55+
56+
output.comments << "INFO: Searching metadata for likely identifiers to the data record\n"
57+
id_hash = id_graph = nil # set to nil for now
58+
59+
properties.each do |keyval|
60+
key = nil
61+
value = nil
62+
(key, value) = keyval
63+
key = key.to_s
64+
65+
output.comments << "INFO: Searching hash-style metadata for keys indicating a pointer to data.\n"
66+
FAIRChampionHarvester::Utils::DATA_PREDICATES.each do |prop|
67+
prop =~ %r{.*[#/]([^#/]+)$}
68+
prop = Regexp.last_match(1)
69+
output.comments << "INFO: Searching for key: #{prop}.\n"
70+
next unless key == prop
71+
72+
output.comments << "INFO: found '#{prop}' in metadata. Setting data GUID to #{value} for next test.\n"
73+
warn "INFO: found '#{prop}' in metadata. Setting data GUID to #{value} for next test.\n"
74+
id_hash = value.to_s
75+
end
76+
end
77+
78+
if metadata.graph.size > 0 # have we found anything yet?
79+
output.comments << "INFO: Searching Linked Data metadata for predicates indicating a pointer to data.\n"
80+
id_graph = FAIRChampionHarvester::CommonQueries::GetDataIdentifier(graph: metadata.graph)
81+
warn "\n\nfound identifier #{id_graph} \n\n"
82+
end
83+
84+
if id_hash.nil? and id_graph.nil?
85+
output.comments << "FAILURE: No data identifier was found in the metadata record.\n"
86+
output.score = 'fail'
87+
return output.createEvaluationResponse
88+
end
89+
90+
metadata2 = FAIRChampionHarvester::Core.typeit(id_hash || id_graph)
91+
92+
if metadata2
93+
output.comments << "SUCCESS: The identifier #{@identifier} is recognized as a #{metadata2}, which is resolvable by an protocol that allows authorization/authentication.\n"
94+
output.score = 'pass'
95+
output.createEvaluationResponse
96+
else
97+
output.comments << "FAILURE: The identifier #{@identifier} did not match any known identification system.\n"
98+
output.score = 'fail'
99+
output.createEvaluationResponse
100+
end
101+
end
102+
103+
def self.fc_data_authorization_api
104+
api = FtrRuby::OpenAPI.new(meta: fc_data_authorization_meta)
105+
api.get_api
106+
end
107+
108+
def self.fc_data_authorization_about
109+
dcat = FtrRuby::DCAT_Record.new(meta: fc_data_authorization_meta)
110+
warn "basePath = #{fc_data_authorization_meta[:basePath]}"
111+
dcat.get_dcat
112+
end
113+
end

app/tests/fc_data_identifier_in_metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def self.fc_data_identifier_in_metadata_meta
55
testname: 'OSTrails Core: Data Identifier in Metadata',
66
testid: 'fc_data_identifier_in_metadata',
77
description: 'Test that the identifier of the data is an unambiguous element of the metadata. Tested options are schema:distribution, http://www.w3.org/ns/ldp#contains, iao:IAO_0000136, IAO:0000136,ldp:contains,foaf:primaryTopic,schema:distribution,schema:contentUrl,schema,mainEntity,schema:codeRepository,schema:distribution,schema:contentUrl, dcat:distribution, dcat:dataset,dcat:downloadURL,dcat:accessURL,sio:SIO_000332, sio:is-about, obo:IAO_0000136',
8-
metric: 'https://doi.org/10.25504/FAIRsharing.5Xy1dJ',
8+
metric: 'https://w3id.org/fair-metrics/general/FM_F3_M_MetaIdent',
99
indicators: 'https://doi.org/10.25504/FAIRsharing.820324',
1010
type: 'http://edamontology.org/operation_2428',
1111
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
class FAIRTest
2+
def self.fc_data_identifier_in_metadata_meta
3+
{
4+
testversion: HARVESTER_VERSION + ':' + 'Tst-2.0.1',
5+
testname: 'OSTrails Core: Data Identifier in Metadata',
6+
testid: 'fc_data_identifier_in_metadata',
7+
description: 'Test that the identifier of the data is an unambiguous element of the metadata. Tested options are schema:distribution, http://www.w3.org/ns/ldp#contains, iao:IAO_0000136, IAO:0000136,ldp:contains,foaf:primaryTopic,schema:distribution,schema:contentUrl,schema,mainEntity,schema:codeRepository,schema:distribution,schema:contentUrl, dcat:distribution, dcat:dataset,dcat:downloadURL,dcat:accessURL,sio:SIO_000332, sio:is-about, obo:IAO_0000136',
8+
metric: 'https://w3id.org/fair-metrics/general/FM_F3_M_MetaIdent',
9+
indicators: 'https://doi.org/10.25504/FAIRsharing.820324',
10+
type: 'http://edamontology.org/operation_2428',
11+
license: 'https://creativecommons.org/publicdomain/zero/1.0/',
12+
keywords: ['FAIR Assessment', 'FAIR Principles'],
13+
themes: ['http://edamontology.org/topic_4012'],
14+
organization: 'OSTrails Project',
15+
org_url: 'https://ostrails.eu/',
16+
responsible_developer: 'Mark D Wilkinson',
17+
email: 'mark.wilkinson@upm.es',
18+
response_description: 'The response is "pass", "fail" or "indeterminate"',
19+
schemas: { 'resource_identifier' => ['string', 'the GUID being tested'] },
20+
organizations: [{ 'name' => 'OSTrails Project', 'url' => 'https://ostrails.eu/' }],
21+
individuals: [{ 'name' => 'Mark D Wilkinson', 'email' => 'mark.wilkinson@upm.es' }],
22+
creator: 'https://orcid.org/0000-0001-6960-357X',
23+
protocol: ENV.fetch('TEST_PROTOCOL', 'https'),
24+
host: ENV.fetch('TEST_HOST', 'localhost'),
25+
basePath: ENV.fetch('TEST_PATH', '/tests')
26+
}
27+
end
28+
29+
def self.fc_data_identifier_in_metadata(guid:)
30+
FtrRuby::Output.clear_comments
31+
32+
output = FtrRuby::Output.new(
33+
testedGUID: guid,
34+
meta: fc_data_identifier_in_metadata_meta
35+
)
36+
output.comments << "INFO: TEST VERSION '#{fc_data_identifier_in_metadata_meta[:testversion]}'\n"
37+
38+
metadata = FAIRChampionHarvester::Core.resolveit(guid) # this is where the magic happens!
39+
40+
metadata.comments.each do |c|
41+
output.comments << c
42+
end
43+
44+
if metadata.guidtype == 'unknown'
45+
output.score = 'indeterminate'
46+
output.comments << "INDETERMINATE: The identifier #{guid} did not match any known identification system.\n"
47+
return output.createEvaluationResponse
48+
end
49+
50+
hash = metadata.hash
51+
graph = metadata.graph
52+
properties = FAIRChampionHarvester::Core.deep_dive_properties(hash)
53+
#############################################################################################################
54+
#############################################################################################################
55+
#############################################################################################################
56+
#############################################################################################################
57+
58+
output.comments << "INFO: Searching metadata for likely identifiers to the data record\n"
59+
identifier = nil
60+
61+
properties.each do |keyval|
62+
_ = nil
63+
(key, value) = keyval
64+
key = key.to_s
65+
66+
output.comments << "INFO: Searching hash-style metadata for keys indicating a pointer to data.\n"
67+
FAIRChampionHarvester::Utils::DATA_PREDICATES.each do |prop|
68+
prop =~ %r{.*[#/]([^#/]+)$}
69+
prop = ::Regexp.last_match(1)
70+
output.comments << "INFO: Searching for key: #{prop}.\n"
71+
if key == prop
72+
output.comments << "INFO: found '#{prop}' in metadata. Setting data GUID to #{value} for next test.\n"
73+
identifier = value.to_s
74+
end
75+
end
76+
end
77+
78+
if graph.size > 0 # have we found anything yet?
79+
output.comments << "INFO: Searching Linked Data metadata for predicates indicating a pointer to data.\n"
80+
identifier = FAIRChampionHarvester::CommonQueries::GetDataIdentifier(graph: graph)
81+
end
82+
83+
if identifier =~ /\w+/
84+
output.comments << "INFO: Now resolving #{identifier} to test its properties.\n"
85+
testIdentifier(guid: identifier, output: output) # this will add more comments and a score to @swagger
86+
else
87+
output.score = 'fail'
88+
output.comments << "INFO: Tested the following #{FAIRChampionHarvester::Utils::DATA_PREDICATES}(or their plain JSON hash-key equivalents)\n"
89+
output.comments << 'FAILURE: Was unable to locate the data identifier in the metadata using any (common) property/predicate reserved for this purpose.'
90+
end
91+
output.createEvaluationResponse
92+
end
93+
94+
def self.testIdentifier(guid:, output:)
95+
# This is verbatim from the gen2_metadata_identifier_persistence
96+
type = FAIRChampionHarvester::Core.typeit(guid) # this is where the magic happens!
97+
98+
output.comments << "INFO: The data guid (#{guid}) is detected as a #{type}.\n"
99+
100+
if !type
101+
output.comments << "FAILURE: The GUID identifier of the data #{guid} did not match any known identification system.\n"
102+
output.score = 'fail'
103+
elsif type == 'uri'
104+
output.comments << "INFO: The data GUID appears to be a URL. Testing known URL persistence schemas (purl, oclc, fdlp, purlz, w3id, ark, doi(as URL)).\n"
105+
if (guid =~ /(purl)\./) or (guid =~ /(oclc)\./) or (guid =~ /(fdlp)\./) or (guid =~ /(purlz)\./) or (guid =~ /(w3id)\./) or (guid =~ /(ark):/) or (guid =~ /(doi.org)/)
106+
output.comments << "SUCCESS: The GUID conforms with #{::Regexp.last_match(1)}, which is known to be persistent.\n"
107+
output.score = 'pass'
108+
else
109+
output.comments << "FAILURE: The GUID does not conform with any known permanent-URL system.\n"
110+
output.score = 'fail'
111+
end
112+
else
113+
output.comments << "SUCCESS: The GUID of the data is a #{type}, which is known to be persistent.\n"
114+
output.score = 'pass'
115+
end
116+
end
117+
118+
def self.fc_data_identifier_in_metadata_api
119+
api = FtrRuby::OpenAPI.new(meta: fc_data_identifier_in_metadata_meta)
120+
api.get_api
121+
end
122+
123+
def self.fc_data_identifier_in_metadata_about
124+
dcat = FtrRuby::DCAT_Record.new(meta: fc_data_identifier_in_metadata_meta)
125+
dcat.get_dcat
126+
end
127+
end

app/tests/fc_data_kr_language_strong.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def self.fc_data_kr_language_strong_meta
55
testname: 'OSTrails Core: Data Knowlege Representation Language (Strict Test)',
66
testid: 'fc_data_kr_language_strong',
77
description: "Test if the data uses a formal language broadly applicable for knowledge representation. This particular test takes a broad view of what defines a 'knowledge representation language'; in this evaluation, a knowledge representation language is interpreted as one in which terms are semantically-grounded in ontologies. Any form of ontologically-grounded linked data will pass this test. ",
8-
metric: 'https://doi.org/10.25504/FAIRsharing.l8fVBn',
8+
metric: 'https://w3id.org/fair-metrics/general/FM_I1_M_FormLangSemantic',
99
indicators: 'https://doi.org/10.25504/FAIRsharing.ec5648',
1010
type: 'http://edamontology.org/operation_2428',
1111
license: 'https://creativecommons.org/publicdomain/zero/1.0/',

0 commit comments

Comments
 (0)