diff --git a/src/SPARQLIngest.ts b/src/SPARQLIngest.ts index 40989b1..72db8c1 100644 --- a/src/SPARQLIngest.ts +++ b/src/SPARQLIngest.ts @@ -110,6 +110,7 @@ export async function sparqlIngest( // Variable that will hold the full query to be executed let query; + let queryType; if (config.changeSemantics) { if (transactionMembers.length > 0) { @@ -128,10 +129,13 @@ export async function sparqlIngest( // Assemble corresponding SPARQL UPDATE query if (ctv.object.value === config.changeSemantics.createValue) { query = CREATE(store, ng); + queryType = "CREATE"; } else if (ctv.object.value === config.changeSemantics.updateValue) { query = UPDATE(store, ng); + queryType = "UPDATE"; } else if (ctv.object.value === config.changeSemantics.deleteValue) { query = DELETE(store, [memberIRI.value], config.memberShapes, ng); + queryType = "DELETE"; } else { throw new Error(`[sparqlIngest] Unrecognized change type value: ${ctv.object.value}`); } @@ -159,6 +163,7 @@ export async function sparqlIngest( } await Promise.all(outputPromises); + console.log(`[sparqlIngest] Executed ${queryType} on remote SPARQL server ${config.graphStoreUrl}`); } } else { throw new Error(`[sparqlIngest] No member IRI found in received RDF data: \n${rawQuads}`); diff --git a/src/Utils.ts b/src/Utils.ts index 63fe0fe..6249055 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -3,8 +3,10 @@ import { Store, DataFactory as DF } from "n3"; export function sanitizeQuads(store: Store): void { for (const q of store.getQuads(null, null, null, null)) { - if (q.object.termType === "Literal") { - if (/\+\d+/.test(q.object.value)) { + // There is an issue with triples like +30. + // Virtuoso doesn't accept the implicit integer type including the + sign. + if (q.object.termType === "Literal" && q.object.datatype.value === XSD.integer) { + if (/\+\d+/.test(q.object.value) && q.object.value.startsWith("+")) { store.removeQuad(q); store.addQuad(q.subject, q.predicate, DF.literal(q.object.value.substring(1), DF.namedNode(XSD.integer)), q.graph); }