Skip to content

Commit

Permalink
Add feature to compile a catalog of all datasets / catalogs and load …
Browse files Browse the repository at this point in the history
…into blazegraph
  • Loading branch information
bherr2 committed Oct 28, 2023
1 parent 7b1cf67 commit 77d3327
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/finalizing/build-blazegraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export function buildBlazegraphJournal(context) {
}
}

const catalog = resolve(context.deploymentHome, 'catalog.ttl');
sparqlUpdate += `LOAD <file://${catalog}> INTO GRAPH <${context.lodIri}>;\n`;

const loadScript = resolve(context.deploymentHome, 'blazegraph.load.rq');
writeFileSync(loadScript, sparqlUpdate);
update(loadScript, journal);
Expand Down
2 changes: 2 additions & 0 deletions src/finalizing/finalize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { buildBlazegraphJournal } from './build-blazegraph.js';
import { createCatalogs } from './create-catalogs.js';
import { deriveLatest } from './derive-latest.js';
import { mergeCatalogs } from './merge-catalogs.js';
import { miscFiles } from './misc-files.js';

/**
Expand All @@ -14,6 +15,7 @@ export function finalize(context) {
miscFiles(context);
deriveLatest(context);
createCatalogs(context);
mergeCatalogs(context);
if (!context.skipDb) {
buildBlazegraphJournal(context);
}
Expand Down
15 changes: 15 additions & 0 deletions src/finalizing/merge-catalogs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { resolve } from 'path';
import sh from 'shelljs';
import { mergeTurtles } from '../utils/blazegraph.js';
import { reifyTurtle } from '../utils/reify.js';

export function mergeCatalogs(context) {
const graphs = listMetadataGraphs(context);
const catalogPath = resolve(context.deploymentHome, 'catalog.ttl');
mergeTurtles(catalogPath, undefined, graphs);
reifyTurtle(catalogPath, context.lodIri);
}

function listMetadataGraphs(context) {
return sh.exec(`find ${resolve(context.deploymentHome)} -name metadata.ttl`).split('\n');
}
2 changes: 1 addition & 1 deletion src/utils/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function reifyCatalog(context, graphName, catalog) {
reifyTurtle(inputPath, graphName);
}

function reifyTurtle(inputPath, graphName) {
export function reifyTurtle(inputPath, graphName) {
const basePath = inputPath.slice(0, inputPath.lastIndexOf('.'));
for (const [extension, type] of Object.entries(FORMATS)) {
convert(inputPath, `${basePath}.${extension}`, type, graphName);
Expand Down

0 comments on commit 77d3327

Please sign in to comment.