let graphURI = 'urn:x-evn-master:test';
graph.withDataGraph(graphURI, () => {
let usedURIs = graph.withDataGraph(graphURI + '.tch', () => {
return graph.select(`
SELECT DISTINCT ?uri
WHERE {
?t teamwork:subject|teamwork:predicate|teamwork:object ?uri .
FILTER isIRI(?uri) .
}`).bindings.map(b => b.uri.uri);
});
console.log('Found ' + usedURIs.length);
let orphans = graph.withDataGraph(dataset.withImports(graphURI), () =>
graph.select(`SELECT ?subject WHERE { ?subject a owl:Class. FILTER isIRI(?subject) }`))
.bindings
.map(b => b.subject)
.filter(subject => !usedURIs.includes(subject.uri));
orphans.forEach((orphan) => {
console.log('Orphan is ' + orphan.uri);
let triples = graph.triples(orphan, null, null);
graph.transaction(graphURI + '.tch', 'Create dummy change for ' + orphan.uri, () => {
let uuid = graph.eval('STRUUID()');
let change = graph.namedNode('urn:x-change:' + uuid);
console.log('Change: ' + change.uri);
graph.update(`
INSERT {
$change rdf:type teamwork:Change ;
rdfs:comment "Dummy change entry for ${orphan.uri}";
dcterms:created ?now ;
sioc:has_creator <urn:x-tb-users:Anonymous4>;
teamwork:status teamwork:Committed .
}
WHERE {
BIND (NOW() AS ?now) .
}`, {
change: change
});
triples.forEach(triple => {
triple.change = change;
graph.update(`
INSERT {
$change teamwork:added [
teamwork:object $object ;
teamwork:predicate $predicate ;
teamwork:subject $subject ;
]
} WHERE {}`, triple);
});
});
});
return orphans; // Return the list of orphans after processing
});
it shows result in the change history but nothing gets added, the change is empty.