Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt importer to the latest schema/ORM changes #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions importer/src/openLibrary/producer/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function processWork(json: any) {
links: [],
relationships: []
},
source: 'OpenLibrary'
externalSource: 'OpenLibrary'
};

// Set up aliases
Expand Down Expand Up @@ -125,7 +125,7 @@ function processWork(json: any) {
typeId: identifiers.openLibraryWorkId,
value: openLibraryWorkId
});
work.originId = openLibraryWorkId;
work.externalIdentifier = openLibraryWorkId;
}

if (!isNotDefined(json.authors) && (json.authors instanceof Array)) {
Expand Down Expand Up @@ -196,7 +196,7 @@ function processAuthor(json) {
originId: [],
relationships: []
},
source: 'OpenLibrary'
externalSource: 'OpenLibrary'
};

// Set up aliases
Expand Down Expand Up @@ -267,7 +267,7 @@ function processAuthor(json) {
const openLibraryAuthorId = json.key.split('/')[2];

// No identifier for OL author exists, so only setting up origin Id
author.originId = openLibraryAuthorId;
author.externalIdentifier = openLibraryAuthorId;

author.metadata.identifiers.push({
typeId: identifiers.openLibraryAuthorId,
Expand Down
6 changes: 3 additions & 3 deletions importer/src/openLibrary/producer/producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function readLine({base, id, queue}: {id: number; base: string; queue: ImportQue
// ➜ JSON - the complete record in JSON format
const record = line.split('\t');

const source = 'OpenLibrary';
const externalSource = 'OpenLibrary';
const json = JSON.parse(record[4]);
const OLType = record[0].split('/')[2] as OLEntityType;
const entityType = mapEntityType(OLType);
Expand All @@ -68,8 +68,8 @@ function readLine({base, id, queue}: {id: number; base: string; queue: ImportQue
data,
entityType,
lastEdited: lastEdited || data.lastEdited,
originId: originId || data.originId,
source
externalIdentifier: originId || data.externalIdentifier,
externalSource
};
const success = queue.push(entity);

Expand Down
2 changes: 1 addition & 1 deletion importer/src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {delay} from './helpers/utils.ts';
*/
export function queuedEntityRepresentation(entity: QueuedEntity): string {
const defaultAlias = entity.data?.alias?.find((alias) => alias.default) ?? entity.data?.alias?.[0];
return `'${defaultAlias?.name ?? '[unknown]'}' (${entity.entityType} ${entity.originId ?? '[unknown ID]'})`;
return `'${defaultAlias?.name ?? '[unknown]'}' (${entity.entityType} ${entity.externalIdentifier ?? '[unknown ID]'})`;
}


Expand Down
6 changes: 3 additions & 3 deletions importer/testdata/author.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Author",
"lastEdited": "2024-07-25",
"originId": "A1234",
"source": "Testdata"
"externalIdentifier": "A1234",
"externalSource": "Testdata"
}
6 changes: 3 additions & 3 deletions importer/testdata/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export const entity: QueuedEntity<ParsedAuthor> = {
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Author",
"lastEdited": "2024-07-25",
"originId": "A1234", // change this to import another dummy entity
"source": "Testdata"
"externalIdentifier": "A1234", // change this to import another dummy entity
"externalSource": "Testdata"
};
9 changes: 4 additions & 5 deletions importer/testdata/edition.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"default": true,
"primary": true
}],
"disambiguation": "import test",
"editionGroupBbid": "PLEASE-FILL-WITH-VALID-BBID",
"disambiguation": "import test, without edition group",
"formatId": 2,
"statusId": 1,
"releaseEvents": [{"date": "2024-04-23"}],
Expand All @@ -27,10 +26,10 @@
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Edition",
"lastEdited": "2024-07-24",
"originId": "E123",
"source": "Testdata"
"externalIdentifier": "E123",
"externalSource": "Testdata"
}
8 changes: 4 additions & 4 deletions importer/testdata/edition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const entity: QueuedEntity<ParsedEdition> = {
"primary": true
}],
"disambiguation": "import test",
"editionGroupBbid": "PLEASE-FILL-WITH-VALID-BBID", // has to exist
// "editionGroupBbid": "PLEASE-FILL-WITH-VALID-BBID",
"formatId": 2, // Hardcover
"statusId": 1, // Official
"releaseEvents": [{"date": "2024-04-23"}],
Expand All @@ -29,10 +29,10 @@ export const entity: QueuedEntity<ParsedEdition> = {
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Edition",
"lastEdited": "2024-07-24",
"originId": "E123", // change this to import another dummy entity
"source": "Testdata"
"externalIdentifier": "E123", // change this to import another dummy entity
"externalSource": "Testdata"
};
6 changes: 3 additions & 3 deletions importer/testdata/edition_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "EditionGroup",
"lastEdited": "2024-07-22",
"originId": "G123",
"source": "Testdata"
"externalIdentifier": "G123",
"externalSource": "Testdata"
}
6 changes: 3 additions & 3 deletions importer/testdata/edition_group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const entity: QueuedEntity<ParsedEditionGroup> = {
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "EditionGroup",
"lastEdited": "2024-07-22",
"originId": "G123", // change this to import another dummy entity
"source": "Testdata"
"externalIdentifier": "G123", // change this to import another dummy entity
"externalSource": "Testdata"
};
6 changes: 3 additions & 3 deletions importer/testdata/publisher.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Publisher",
"lastEdited": "2024-07-24",
"originId": "P123",
"source": "Testdata"
"externalIdentifier": "P123",
"externalSource": "Testdata"
}
6 changes: 3 additions & 3 deletions importer/testdata/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const entity: QueuedEntity<ParsedPublisher> = {
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Publisher",
"lastEdited": "2024-07-24",
"originId": "P123", // change this to import another dummy entity
"source": "Testdata"
"externalIdentifier": "P123", // change this to import another dummy entity
"externalSource": "Testdata"
};
6 changes: 3 additions & 3 deletions importer/testdata/series.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Series",
"lastEdited": "2024-07-24",
"originId": "S123",
"source": "Testdata"
"externalIdentifier": "S123",
"externalSource": "Testdata"
}
6 changes: 3 additions & 3 deletions importer/testdata/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export const entity: QueuedEntity<ParsedSeries> = {
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Series",
"lastEdited": "2024-07-24",
"originId": "S123", // change this to import another dummy entity
"source": "Testdata"
"externalIdentifier": "S123", // change this to import another dummy entity
"externalSource": "Testdata"
};
6 changes: 3 additions & 3 deletions importer/testdata/work.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Work",
"lastEdited": "2024-07-17",
"originId": "W123",
"source": "Testdata"
"externalIdentifier": "W123",
"externalSource": "Testdata"
}
6 changes: 3 additions & 3 deletions importer/testdata/work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const entity: QueuedEntity<ParsedWork> = {
}],
"relationships": []
},
"source": "Testdata"
"externalSource": "Testdata"
},
"entityType": "Work",
"lastEdited": "2024-07-17",
"originId": "W123", // change this to import another dummy entity
"source": "Testdata"
"externalIdentifier": "W123", // change this to import another dummy entity
"externalSource": "Testdata"
};