Skip to content

Commit

Permalink
feat: Store publisher e-mail (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer authored Nov 15, 2023
1 parent a40aa30 commit 8cbf3ee
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
27 changes: 22 additions & 5 deletions shacl/register.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,29 @@ reg:OrganizationShape
reg:OrganizationNameProperty,
# TODO
# Recommended properties
reg:SchemaAlternateNameProperty ;
reg:SchemaAlternateNameProperty ,
# TODO
# reg:SchemaSameAsProperty
# reg:SchemaSameAsProperty ;
[
sh:path schema:contactPoint ;
sh:class schema:ContactPoint ;
sh:minCount 0 ;
sh:node [
a sh:NodeShape ;
sh:targetClass schema:ContactPoint ;
sh:property [
sh:path schema:name ;
sh:minCount 1;
sh:message "ContactPoint moet een naam hebben"@nl, "ContactPoint must have a name"@en ;
] ,
[
sh:path schema:email ;
sh:minCount 1;
sh:message "ContactPoint moet een e-mailadres hebben"@nl, "ContactPoint must have an e-mail address"@en ;
]
] ;
sh:message "Een organisatie kan een ContactPoint hebben"@nl, "An organization should have a ContactPoint"@en ;
]
.

reg:PersonShape
Expand Down Expand Up @@ -118,9 +138,6 @@ reg:DateTimeShape a sh:NodeShape ;
sh:severity sh:Warning ;
.

# TODO
# reg:PublisherShape

#
# Property shapes
#
Expand Down
3 changes: 3 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ function schemaOrgQuery(prefix: string): string {
?${publisher} a ?organizationOrPerson ;
a ?publisherType ;
${prefix}:name ?${publisherName} .
OPTIONAL {
?${publisher} ${prefix}:contactPoint/${prefix}:email ?${publisherEmail} .
}
}
VALUES ?organizationOrPerson { ${prefix}:Organization ${prefix}:Person }
Expand Down
7 changes: 6 additions & 1 deletion test/datasets/dataset-schema-org-valid.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
"@type": "Organization",
"@id": "https://example.com/publisher",
"name": "Koninklijke Bibliotheek",
"sameAs": "https://ror.org/02w4jbg70"
"sameAs": "https://ror.org/02w4jbg70",
"contactPoint": {
"@type": "ContactPoint",
"name": "Datasets Manager",
"email": "[email protected]"
}
},
"creator": [
{
Expand Down
12 changes: 11 additions & 1 deletion test/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Fetch', () => {

expect(datasets).toHaveLength(1);
const dataset = datasets[0];
expect(dataset.size).toBe(25);
expect(dataset.size).toBe(26);
expect(
dataset.has(
factory.quad(
Expand Down Expand Up @@ -109,6 +109,16 @@ describe('Fetch', () => {
)
)
).toBe(true);
expect(
dataset.has(
factory.quad(
factory.namedNode('https://example.com/publisher'),
foaf('mbox'),
factory.literal('[email protected]'),
factory.namedNode('http://data.bibliotheken.nl/id/dataset/rise-alba')
)
)
).toBe(true);
expect(
dataset.has(
factory.quad(
Expand Down

0 comments on commit 8cbf3ee

Please sign in to comment.