Skip to content

Commit

Permalink
fix: allow more than one alternate name; improve integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdevalk committed Dec 3, 2024
1 parent 97fcb91 commit 98bc7d6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 47 deletions.
2 changes: 2 additions & 0 deletions packages/api/src/objects/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export class HeritageObjectFetcher {
FILTER(LANG(?typeName) = "${options.locale}")
}
# For BC: data providers ought to use the same thesauri
OPTIONAL {
?type rdfs:label ?typeName
FILTER(LANG(?typeName) = "" || LANG(?typeName) = "${options.locale}")
Expand Down Expand Up @@ -215,6 +216,7 @@ export class HeritageObjectFetcher {
FILTER(LANG(?materialName) = "${options.locale}")
}
# For BC: data providers ought to use the same thesauri
OPTIONAL {
?material rdfs:label ?materialName
FILTER(LANG(?materialName) = "" || LANG(?materialName) = "${options.locale}")
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/research-guides/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Event, Place, Term, Thing} from '../definitions';
export type Citation = Thing & {url?: string};

export type ResearchGuide = Thing & {
alternateName?: string;
alternateNames?: string[];
abstract?: string;
text?: string;
encodingFormat?: string;
Expand Down
112 changes: 71 additions & 41 deletions packages/api/src/research-guides/fetcher.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ describe('getTopLevels', () => {
encodingFormat: 'text/markdown',
seeAlso: [
{
id: 'https://guides.example.org/subset1',
name: '1. Name',
id: 'https://guides.example.org/subset3',
name: '3. Name',
seeAlso: [
{
id: 'https://guides.example.org/guide3',
name: 'Sources',
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
seeAlso: [
{
id: 'https://guides.example.org/guide5',
Expand All @@ -45,13 +45,17 @@ describe('getTopLevels', () => {
],
},
{
id: 'https://guides.example.org/guide1',
name: 'Doing research',
id: 'https://guides.example.org/guide7',
name: 'Kunsthandel Van Lier',
seeAlso: [
{
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
seeAlso: [
{
id: 'https://guides.example.org/guide1',
name: 'Doing research',
},
{
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
Expand All @@ -60,43 +64,47 @@ describe('getTopLevels', () => {
},
],
},
{
id: 'https://guides.example.org/guide2',
name: 'How can I use the data hub for my research?',
},
],
},
{
id: 'https://guides.example.org/subset2',
name: '2. Name',
id: 'https://guides.example.org/subset1',
name: '1. Name',
seeAlso: [
{
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
id: 'https://guides.example.org/guide1',
name: 'Doing research',
seeAlso: [
{
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
seeAlso: [
{
id: 'https://guides.example.org/guide5',
name: 'Trade',
id: 'https://guides.example.org/guide1',
name: 'Doing research',
},
{
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
},
],
},
],
},
{
id: 'https://guides.example.org/guide5',
name: 'Trade',
id: 'https://guides.example.org/guide2',
name: 'How can I use the data hub for my research?',
},
{
id: 'https://guides.example.org/guide3',
name: 'Sources',
seeAlso: [
{
id: 'https://guides.example.org/guide7',
name: 'Kunsthandel Van Lier',
id: 'https://guides.example.org/guide5',
name: 'Trade',
seeAlso: [
{
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
id: 'https://guides.example.org/guide7',
name: 'Kunsthandel Van Lier',
},
],
},
Expand All @@ -105,36 +113,46 @@ describe('getTopLevels', () => {
],
},
{
id: 'https://guides.example.org/subset3',
name: '3. Name',
id: 'https://guides.example.org/subset2',
name: '2. Name',
seeAlso: [
{
id: 'https://guides.example.org/guide7',
name: 'Kunsthandel Van Lier',
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
seeAlso: [
{
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
id: 'https://guides.example.org/guide1',
name: 'Doing research',
seeAlso: [
{
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
},
],
},
{
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
seeAlso: [
{
id: 'https://guides.example.org/guide5',
name: 'Trade',
},
],
},
],
},
{
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
id: 'https://guides.example.org/guide5',
name: 'Trade',
seeAlso: [
{
id: 'https://guides.example.org/guide5',
name: 'Trade',
id: 'https://guides.example.org/guide7',
name: 'Kunsthandel Van Lier',
seeAlso: [
{
id: 'https://guides.example.org/guide7',
name: 'Kunsthandel Van Lier',
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
},
],
},
Expand Down Expand Up @@ -207,7 +225,7 @@ describe('getById', () => {
expect(researchGuide).toStrictEqual({
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
alternateName: 'Navy',
alternateNames: ['Navy'],
abstract:
'Army and Navy personnel who operated in colonized territories collected objects in various ways during the colonial era.',
text: 'Dutch authority in the [Dutch East Indies](https://www.geonames.org/1643084/republic-of-indonesia.html), [Suriname](https://www.geonames.org/3382998/republic-of-suriname.html) and on the [Caribbean Islands](https://www.geonames.org/8505032/netherlands-antilles.html) relied heavily on the use of the military...',
Expand All @@ -231,6 +249,10 @@ describe('getById', () => {
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
},
{
id: 'https://guides.example.org/guide1',
name: 'Doing research',
},
]),
contentLocations: expect.arrayContaining([
{
Expand Down Expand Up @@ -275,7 +297,7 @@ describe('get with localized names', () => {
expect(researchGuide).toMatchObject({
id: 'https://guides.example.org/guide4',
name: 'Military and navy',
alternateName: 'Navy',
alternateNames: expect.arrayContaining(['Navy']),
abstract:
'Army and Navy personnel who operated in colonized territories collected objects in various ways during the colonial era.',
text: 'Dutch authority in the [Dutch East Indies](https://www.geonames.org/1643084/republic-of-indonesia.html), [Suriname](https://www.geonames.org/3382998/republic-of-suriname.html) and on the [Caribbean Islands](https://www.geonames.org/8505032/netherlands-antilles.html) relied heavily on the use of the military...',
Expand All @@ -284,6 +306,10 @@ describe('get with localized names', () => {
id: 'https://guides.example.org/guide6',
name: 'Royal Cabinet of Curiosities',
},
{
id: 'https://guides.example.org/guide1',
name: 'Doing research',
},
]),
contentLocations: [
{
Expand Down Expand Up @@ -314,7 +340,7 @@ describe('get with localized names', () => {
expect(researchGuide).toMatchObject({
id: 'https://guides.example.org/guide4',
name: 'Leger en Marine',
alternateName: 'Marine',
alternateNames: expect.arrayContaining(['Marine', 'Zeemacht']),
abstract:
'Leger- en marinepersoneel dat actief was in gekoloniseerde gebieden, verzamelde op verschillende manieren objecten tijdens het koloniale tijdperk.',
text: 'Het Nederlandse gezag in [Nederlands-Indië](https://www.geonames.org/1643084/republic-of-indonesia.html), [Suriname](https://www.geonames.org/3382998/republic-of-suriname.html) en op de [Caribische eilanden](https://www.geonames.org/8505032/netherlands-antilles.html) steunde in belangrijke mate op de inzet van het leger.',
Expand All @@ -323,6 +349,10 @@ describe('get with localized names', () => {
id: 'https://guides.example.org/guide6',
name: 'Koninklijk Kabinet van Zeldzaamheden',
},
{
id: 'https://guides.example.org/guide1',
name: 'Onderzoeken',
},
]),
contentLocations: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/research-guides/rdf-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ beforeAll(async () => {
ex:researchGuide2 a ex:CreativeWork ;
ex:name "Name 2" ;
ex:alternateName "Alternate name 2" ;
ex:alternateName "Alternate name 2", "Alternate name 3" ;
ex:abstract "Abstract 2" ;
ex:text "Text" ;
ex:encodingFormat "text/html" ;
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('createResearchGuide', () => {
expect(researchGuide).toStrictEqual({
id: 'https://example.org/researchGuide2',
name: 'Name 2',
alternateName: 'Alternate name 2',
alternateNames: ['Alternate name 2', 'Alternate name 3'],
abstract: 'Abstract 2',
text: 'Text',
encodingFormat: 'text/html',
Expand Down
7 changes: 4 additions & 3 deletions packages/api/src/research-guides/rdf-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ export function createResearchGuide(
stackSize = 1
) {
const name = onlyOne(getPropertyValues(researchGuideResource, 'ex:name'));
const alternateName = onlyOne(
getPropertyValues(researchGuideResource, 'ex:alternateName')
const alternateNames = getPropertyValues(
researchGuideResource,
'ex:alternateName'
);
const abstract = onlyOne(
getPropertyValues(researchGuideResource, 'ex:abstract')
Expand Down Expand Up @@ -106,7 +107,7 @@ export function createResearchGuide(
const researchGuideWithUndefinedValues: ResearchGuide = {
id: researchGuideResource.value,
name,
alternateName,
alternateNames,
abstract,
text,
encodingFormat,
Expand Down

0 comments on commit 98bc7d6

Please sign in to comment.