Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 6x 6x 1x 1x 5x 5x 5x 5x 5x 5x 5x 3x 3x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { SparqlResultsController } from '@src/views/webviews';
import { getConfig } from '@src/utilities/vscode/config';
export const executeDescribeQuery = {
id: 'mentor.command.executeDescribeQuery',
handler: async (documentUri: vscode.Uri | string, resourceIri: string, graphUris?: string[]) => {
const document = vscode.workspace.textDocuments.find(doc => doc.uri.toString() === documentUri.toString());
if (!document) {
console.warn(`Unable to retrieve document for URI: ${documentUri.toString()}`);
return;
}
const template = getConfig().get<string>('sparql.describeQueryTemplate');
Iif(!template) {
vscode.window.showErrorMessage('Describe query template is not defined in the configuration: mentor.sparql.describeQueryTemplate');
return;
}
const fromClauses = getFromClauses(graphUris);
const query = template
.replace(/\{\{resourceIri\}\}/g, resourceIri)
.replace(/\{\{fromClauses\}\}/g, fromClauses);
const controller = container.resolve<SparqlResultsController>(ServiceToken.SparqlResultsController);
await controller.executeQuery(document, query);
}
};
function getFromClauses(graphUris?: string[]): string {
if (!graphUris || graphUris.length === 0) {
return '';
} else {
return graphUris.map(uri => `\nFROM <${uri}>`).join('');
}
} |