Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlittman committed Aug 26, 2020
1 parent af0b090 commit 51ae408
Show file tree
Hide file tree
Showing 26 changed files with 1,748 additions and 1,556 deletions.
45 changes: 31 additions & 14 deletions __tests__/TemplatesBuilder.test.js
Expand Up @@ -29,20 +29,24 @@ describe('TemplatesBuilder', () => {

it('builds common property template properties', async () => {
const rdf = `<> <http://sinopia.io/vocabulary/hasClass> <http://id.loc.gov/ontologies/bibframe/Uber1> .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b1_c14n0 .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b1_c14n1 .
<> <http://sinopia.io/vocabulary/hasResourceId> <resourceTemplate:testing:uber1> .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "sinopia:template:resource" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/ResourceTemplate> .
<> <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1"@eng .
<http://sinopia.io/vocabulary/cardinality/repeatable> <http://www.w3.org/2000/01/rdf-schema#label> "repeatable" .
<http://sinopia.io/vocabulary/cardinality/required> <http://www.w3.org/2000/01/rdf-schema#label> "required" .
<http://sinopia.io/vocabulary/propertyAttribute/repeatable> <http://www.w3.org/2000/01/rdf-schema#label> "repeatable" .
<http://sinopia.io/vocabulary/propertyAttribute/required> <http://www.w3.org/2000/01/rdf-schema#label> "required" .
<http://sinopia.io/vocabulary/propertyAttribute/required> <http://www.w3.org/2000/01/rdf-schema#label> "ordered" .
<http://sinopia.io/vocabulary/propertyType/literal> <http://www.w3.org/2000/01/rdf-schema#label> "literal" .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasCardinality> <http://sinopia.io/vocabulary/cardinality/repeatable> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasCardinality> <http://sinopia.io/vocabulary/cardinality/required> .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b1_c14n0 .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasPropertyAttribute> <http://sinopia.io/vocabulary/propertyAttribute/repeatable> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasPropertyAttribute> <http://sinopia.io/vocabulary/propertyAttribute/required> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasPropertyAttribute> <http://sinopia.io/vocabulary/propertyAttribute/ordered> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasPropertyType> <http://sinopia.io/vocabulary/propertyType/literal> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasRemark> "A repeatable literal."@eng .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasRemarkUrl> <http://access.rdatoolkit.org/2.4.2.html> .
_:b1_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b1_c14n0 <http://sinopia.io/vocabulary/hasPropertyUri> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b1_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/PropertyTemplate> .
_:b1_c14n0 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, property2"@eng .`
const dataset = await datasetFromN3(rdf)
Expand All @@ -54,6 +58,7 @@ _:b1_c14n0 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, propert
uri: 'http://id.loc.gov/ontologies/bibframe/uber/template1/property1',
required: true,
repeatable: true,
ordered: true,
remark: 'A repeatable literal.',
remarkUrl: 'http://access.rdatoolkit.org/2.4.2.html',
defaults: [],
Expand All @@ -66,15 +71,17 @@ _:b1_c14n0 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, propert

it('builds literal property template', async () => {
const rdf = `<> <http://sinopia.io/vocabulary/hasClass> <http://id.loc.gov/ontologies/bibframe/Uber1> .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b2_c14n0 .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b1_c14n1 .
<> <http://sinopia.io/vocabulary/hasResourceId> <resourceTemplate:testing:uber1> .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "sinopia:template:resource" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/ResourceTemplate> .
<> <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1"@eng .
<http://sinopia.io/vocabulary/propertyType/literal> <http://www.w3.org/2000/01/rdf-schema#label> "literal" .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b2_c14n0 .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:b2_c14n0 <http://sinopia.io/vocabulary/hasLiteralAttributes> _:b2_c14n1 .
_:b2_c14n0 <http://sinopia.io/vocabulary/hasPropertyType> <http://sinopia.io/vocabulary/propertyType/literal> .
_:b2_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b2_c14n0 <http://sinopia.io/vocabulary/hasPropertyUri> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b2_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/PropertyTemplate> .
_:b2_c14n0 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, property2"@eng .
_:b2_c14n1 <http://sinopia.io/vocabulary/hasDefault> "default1"@eng .
Expand All @@ -89,6 +96,7 @@ _:b2_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/
uri: 'http://id.loc.gov/ontologies/bibframe/uber/template1/property1',
required: false,
repeatable: false,
ordered: false,
remark: null,
remarkUrl: null,
defaults: [
Expand All @@ -104,12 +112,14 @@ _:b2_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/

it('builds URI property template', async () => {
const rdf = `<> <http://sinopia.io/vocabulary/hasClass> <http://id.loc.gov/ontologies/bibframe/Uber1> .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b3_c14n3 .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b1_c14n1 .
<> <http://sinopia.io/vocabulary/hasResourceId> <resourceTemplate:testing:uber1> .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "sinopia:template:resource" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/ResourceTemplate> .
<> <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1"@eng .
<http://sinopia.io/vocabulary/propertyType/uri> <http://www.w3.org/2000/01/rdf-schema#label> "uri" .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b3_c14n3 .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:b3_c14n0 <http://sinopia.io/vocabulary/hasUri> <http://sinopia.io/uri1> .
_:b3_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/Uri> .
_:b3_c14n0 <http://www.w3.org/2000/01/rdf-schema#label> "Test uri1"@eng .
Expand All @@ -120,7 +130,7 @@ _:b3_c14n2 <http://sinopia.io/vocabulary/hasDefault> _:b3_c14n1 .
_:b3_c14n2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/UriPropertyTemplate> .
_:b3_c14n3 <http://sinopia.io/vocabulary/hasPropertyType> <http://sinopia.io/vocabulary/propertyType/uri> .
_:b3_c14n3 <http://sinopia.io/vocabulary/hasUriAttributes> _:b3_c14n2 .
_:b3_c14n3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b3_c14n3 <http://sinopia.io/vocabulary/hasPropertyUri> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b3_c14n3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/PropertyTemplate> .
_:b3_c14n3 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, property2"@eng .`
const dataset = await datasetFromN3(rdf)
Expand All @@ -132,6 +142,7 @@ _:b3_c14n3 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, propert
uri: 'http://id.loc.gov/ontologies/bibframe/uber/template1/property1',
required: false,
repeatable: false,
ordered: false,
remark: null,
remarkUrl: null,
defaults: [
Expand All @@ -147,18 +158,20 @@ _:b3_c14n3 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, propert

it('builds nested resource property template', async () => {
const rdf = `<> <http://sinopia.io/vocabulary/hasClass> <http://id.loc.gov/ontologies/bibframe/Uber1> .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b4_c14n1 .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b1_c14n1 .
<> <http://sinopia.io/vocabulary/hasResourceId> <resourceTemplate:testing:uber1> .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "sinopia:template:resource" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/ResourceTemplate> .
<> <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1"@eng .
<http://sinopia.io/vocabulary/propertyType/resource> <http://www.w3.org/2000/01/rdf-schema#label> "nested resource" .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b4_c14n1 .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:b4_c14n0 <http://sinopia.io/vocabulary/hasResourceTemplateId> <resourceTemplate:testing:uber2> .
_:b4_c14n0 <http://sinopia.io/vocabulary/hasResourceTemplateId> <resourceTemplate:testing:uber3> .
_:b4_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/ResourcePropertyTemplate> .
_:b4_c14n1 <http://sinopia.io/vocabulary/hasPropertyType> <http://sinopia.io/vocabulary/propertyType/resource> .
_:b4_c14n1 <http://sinopia.io/vocabulary/hasResourceAttributes> _:b4_c14n0 .
_:b4_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b4_c14n1 <http://sinopia.io/vocabulary/hasPropertyUri> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b4_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/PropertyTemplate> .
_:b4_c14n1 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, property2"@eng .`
const dataset = await datasetFromN3(rdf)
Expand All @@ -170,6 +183,7 @@ _:b4_c14n1 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, propert
uri: 'http://id.loc.gov/ontologies/bibframe/uber/template1/property1',
required: false,
repeatable: false,
ordered: false,
remark: null,
remarkUrl: null,
defaults: [],
Expand All @@ -185,21 +199,23 @@ _:b4_c14n1 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, propert

it('builds lookup property template', async () => {
const rdf = `<> <http://sinopia.io/vocabulary/hasClass> <http://id.loc.gov/ontologies/bibframe/Uber1> .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b5_c14n1 .
<> <http://sinopia.io/vocabulary/hasPropertyTemplate> _:b1_c14n1 .
<> <http://sinopia.io/vocabulary/hasResourceId> <resourceTemplate:testing:uber1> .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "sinopia:template:resource" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/ResourceTemplate> .
<> <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1"@eng .
<http://sinopia.io/vocabulary/propertyType/lookup> <http://www.w3.org/2000/01/rdf-schema#label> "lookup" .
<urn:discogs> <http://www.w3.org/2000/01/rdf-schema#label> "Discogs" .
<urn:ld4p:qa:agrovoc> <http://www.w3.org/2000/01/rdf-schema#label> "AGROVOC (QA)" .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b5_c14n1 .
_:b1_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:b5_c14n0 <http://sinopia.io/vocabulary/hasAuthority> <urn:discogs> .
_:b5_c14n0 <http://sinopia.io/vocabulary/hasAuthority> <urn:ld4p:qa:agrovoc> .
_:b5_c14n0 <http://sinopia.io/vocabulary/hasDefault> _:b5_c14n2 .
_:b5_c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/LookupPropertyTemplate> .
_:b5_c14n1 <http://sinopia.io/vocabulary/hasLookupAttributes> _:b5_c14n0 .
_:b5_c14n1 <http://sinopia.io/vocabulary/hasPropertyType> <http://sinopia.io/vocabulary/propertyType/uri> .
_:b5_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b5_c14n1 <http://sinopia.io/vocabulary/hasPropertyUri> <http://id.loc.gov/ontologies/bibframe/uber/template1/property1> .
_:b5_c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sinopia.io/vocabulary/PropertyTemplate> .
_:b5_c14n1 <http://www.w3.org/2000/01/rdf-schema#label> "Uber template1, property2"@eng .
_:b5_c14n2 <http://sinopia.io/vocabulary/hasUri> <http://sinopia.io/uri1> .
Expand All @@ -215,6 +231,7 @@ _:b5_c14n2 <http://www.w3.org/2000/01/rdf-schema#label> "URI1"@eng .`
uri: 'http://id.loc.gov/ontologies/bibframe/uber/template1/property1',
required: false,
repeatable: false,
ordered: false,
remark: null,
remarkUrl: null,
defaults: [{ uri: 'http://sinopia.io/uri1', label: 'URI1' }],
Expand Down
Expand Up @@ -82,6 +82,7 @@
"uri": "http://id.loc.gov/ontologies/bibframe/uber/template2/property1",
"required": false,
"repeatable": true,
"ordered": false,
"defaults": [],
"remark": "A repeatable literal",
"remarkUrl": null,
Expand Down

0 comments on commit 51ae408

Please sign in to comment.