Skip to content

Commit 28cae09

Browse files
jamsdenclaude
andcommitted
fix: parse SPARQL JSON response from LQE Jena-backed incoming links
LQE with Jena store returns SPARQL JSON format (results.bindings) instead of the REST API format (queryResults). Support both: detect response format and parse accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 060c854 commit 28cae09

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

LDMClient.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,26 @@ export default class LDMClient extends OSLCClient {
310310
throw new Error(`LQE incoming-links error: ${data.error}`);
311311
}
312312

313-
const results = data?.queryResults || [];
314-
return results.map(r => ({
315-
sourceURL: r.sourceUrl || '',
316-
linkType: r.linkType || '',
317-
targetURL: r.targetUrl || ''
318-
}));
313+
// REST API format (LQE 7.1.0+ with relational store)
314+
if (data?.queryResults) {
315+
return data.queryResults.map(r => ({
316+
sourceURL: r.sourceUrl || '',
317+
linkType: r.linkType || '',
318+
targetURL: r.targetUrl || ''
319+
}));
320+
}
321+
322+
// SPARQL JSON format (LQE with Jena store)
323+
// Variables: sURL (source), linkType, tURL (target), indLinkType
324+
if (data?.results?.bindings) {
325+
return data.results.bindings.map(b => ({
326+
sourceURL: b.sURL?.value || '',
327+
linkType: b.linkType?.value || '',
328+
targetURL: b.tURL?.value || ''
329+
}));
330+
}
331+
332+
return [];
319333
} catch (error) {
320334
const status = error?.response?.status;
321335
const msg = error?.response?.data?.error || error?.message || 'Unknown error';

0 commit comments

Comments
 (0)