Fail to write change history when using ADS transaction.

78 views
Skip to first unread message

Jorrit Dorman

unread,
Feb 26, 2025, 9:33:11 AMFeb 26
to TopBraid Suite Users
Hi,

I have an ADS script in which I get an array of triples from the current graph, and I want to insert them in another graph. I use the following:
graph.transaction(
   targetGraph,
   "Changes history message",
   function addTriples() {
      graph.addTriples(resultSet);
   }
);

This works as intended. The target Graph is updated with the resultSet. However I do not see this in the change history of the target Graph.

If I reverse it, and from the targetGraph start a script like this:
const resultSet = graph.withDataGraph(
   sourceGraph,
   function getTriples() {
      return graph.construct(sparqlQuery);
   }
);
graph.transaction(
   null,
   "Changes history message",
   function addTriples() {
      graph.addTriples(resultSet);
   }
);

then I do get the change history. Is it as inteded that I do not get an entry in the change history when writing from another graph? Is there something to I can do to get the changes?

Holger Knublauch

unread,
Feb 26, 2025, 1:06:56 PMFeb 26
to topbrai...@googlegroups.com
The change history is only activated when the URI of the graph includes the user name. In your case, does it, or is just something like urn:x-evn-master:geo ?

One way of getting such graphs is to call tbs.queryGraph()

Holger


--
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
To post to this group, send email to topbrai...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/topbraid-users/360c4e85-30f3-482d-b7f7-20f5cbee5b58n%40googlegroups.com.

Jorrit Dorman

unread,
Feb 27, 2025, 5:45:18 AMFeb 27
to TopBraid Suite Users
Thanks Holger, that seems to work.

I've made it like this, but I was wondering if there is a more streamlined way to do this? Also, is there documentation available about the tbs functions?
const targetGraph <urn:x-evn-master:test> ;

const targetUserGraph = graph.withDataGraph(
   targetGraph,
   function getUserGraph() {
      return tbs.queryGraph();
   }
);

graph.transaction(
   targetUserGraph,
   "change message"
   function addTriples() {
      graph.addTriples(res);
   }
);

Holger Knublauch

unread,
Feb 27, 2025, 5:53:44 AMFeb 27
to topbrai...@googlegroups.com

On Feb 27, 2025, at 11:45, Jorrit Dorman <jor...@gmail.com> wrote:

Thanks Holger, that seems to work.

I've made it like this, but I was wondering if there is a more streamlined way to do this? Also, is there documentation available about the tbs functions?
const targetGraph <urn:x-evn-master:test> ;

const targetUserGraph = graph.withDataGraph(
   targetGraph,
   function getUserGraph() {
      return tbs.queryGraph();
   }
);

Looks generally Ok but could be written more compact as

const targetUserGraph = graph.withDataGraph(targetGraph, tbs.queryGraph)

There is no documentation on the TBS functions as an HTML page. Instead, you can just use auto-complete like this

PastedGraphic-1.png

to reach the documentation of each function. Also you can see most functions when you go to Reports > Web Services Swagger.

Holger


Jorrit Dorman

unread,
Feb 28, 2025, 11:09:36 AMFeb 28
to TopBraid Suite Users
Thanks! I'll check it out

Valentin Chialda (vali fpv)

unread,
Aug 9, 2025, 4:34:17 AMAug 9
to TopBraid Suite Users
Hi Jorrit, Holger

I'm looking for a similar approach. For each taxonomy modification (e.g. in labels) I want to trigger that update and append the "action" to another taxonomy (in my case <urn:x-evn-master:events_store_taxonomy> )  that would have the source taxonomy label, who edited, date, etc (basically keeping a history of each taxo changes in a separate taxonomy for further external process). 

I'm new to ADS scripting inside EDG Sudio and without much documentation I end up creating a ttl File, adding my code as text strings under dash:js """ and finally included that file under a common ontology, which is further included in all my taxonomies, so whenever a taxonomy gets edited that CommitScript is triggered.  I'm not sure that's the normal development practice with ADS or writing the code as strings there's no code completion and I relate mostly on console logs with a Trial and error programming approach.

So the question is what's the best approach to go with the development if I need to get the changes of a taxo using commitScript or similar?

Thank you in advance!!

Valentin




Holger Knublauch

unread,
Aug 9, 2025, 4:40:24 AMAug 9
to topbrai...@googlegroups.com

On Aug 7, 2025, at 12:20, Valentin Chialda (vali fpv) <valentin...@gmail.com> wrote:

Hi Jorrit, Holger

I'm looking for a similar approach. For each taxonomy modification (e.g. in labels) I want to trigger that update and append the "action" to another taxonomy (in my case <urn:x-evn-master:events_store_taxonomy> )  that would have the source taxonomy label, who edited, date, etc (basically keeping a history of each taxo changes in a separate taxonomy for further external process). 

As this sounds like a modification to another asset collection, you cannot use ChangeScript, but CommitScript sounds right.


I'm new to ADS scripting inside EDG Sudio and without much documentation I end up creating a ttl File, adding my code as text strings under dash:js """ and finally included that file under a common ontology, which is further included in all my taxonomies, so whenever a taxonomy gets edited that CommitScript is triggered.  I'm not sure that's the normal development practice with ADS or writing the code as strings there's no code completion and I relate mostly on console logs with a Trial and error programming approach.

My normal practice is to use the Script Editor panel in Studio for ADS development. This supports auto-complete, mouse-over-help and even has a step-through debugger.

PastedGraphic-1.png


Please let us know if you’re stuck, e.g. by sending us what you have so far and maybe we can help further.

HTH
Holger

Valentin Chialda (vali fpv)

unread,
Aug 13, 2025, 1:29:28 AMAug 13
to TopBraid Suite Users
Thank you Holger!

I've just tried to use the script editor, although it won't execute transactions. Without transaction though (just using graph.addTriples with the data below), the code execute without errors or any other messages in the consoles but there's no output in the collection either.

Below is the code that I've used in the file:





<http://ibm.tvm.org/changescripts/taxonomycommitscript#TaxonomyCommitScript>

  a dash:CommitScript ;

  dash:js """console.log('Commit Script is running...');


// Get the current collection being edited

//const currentGraph = graph;

//const currentGraphURI = currentGraph.dataGraphURI;



const targetUserGraph = graph.withDataGraph('urn:x-evn-master:events_store_taxonomy', tbs.queryGraph);


// Define the existing ConceptScheme URI

let conceptSchemeURI = "http://www.ibm.com/standards/vocabulary/taxonomies/events_store_taxonomy/Events_root";


// Generate URIs for the new top concepts

let topConcept1URI = "http://www.ibm.com/standards/vocabulary/taxonomies/events_store_taxonomy/Events_root/newtest";


graph.transaction(

   targetUserGraph,

   "add top concepts to Events_root",

   function addTopConcepts() {

      let res = [

         [topConcept1URI, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/2004/02/skos/core#Concept"],

         [topConcept1URI, "http://www.w3.org/2000/01/rdf-schema#label", "Business Events"],

         [topConcept1URI, "http://www.w3.org/2004/02/skos/core#prefLabel", "Business Events"],

         [topConcept1URI, "http://www.w3.org/2004/02/skos/core#inScheme", conceptSchemeURI],

         [topConcept1URI, "http://www.w3.org/2004/02/skos/core#topConceptOf", conceptSchemeURI],

         [conceptSchemeURI, "http://www.w3.org/2004/02/skos/core#hasTopConcept", topConcept1URI]

      ];

      

      graph.addTriples(res);

   }

);



console.log('Commit Script finished.');

""" ;

  rdfs:comment """This CommitScript captures taxonomy edit events and stores them in the events_store_taxonomy.

It extracts the editor information from the graph URI, generates event metadata, and inserts

the event data using SPARQL INSERT queries. The script creates Events_Concept instances

with all required properties including taxo_id, graph_uri, timestamp, and editor information.


Note that this gets only executed when changes have really been asserted, i.e. unlike ChangeScripts they will not execute when the user merely does a Preview or a change gets rejected due to constraint violations.


To try this out, include/owl:import this file into any asset collection and make some changes.""" ;

  rdfs:label "Taxonomy Event Capture Commit Script" ;

.


Holger Knublauch

unread,
Aug 13, 2025, 1:41:33 AMAug 13
to topbrai...@googlegroups.com

On Aug 11, 2025, at 09:16, Valentin Chialda (vali fpv) <valentin...@gmail.com> wrote:

Thank you Holger!

I've just tried to use the script editor, although it won't execute transactions.

In the upper right corner of the Script Editor, you should see a button to switch to writeable mode, which is allowing transactions and preview.

And have you tried replacing the array or arrays with an array of objects that have { subject: …, predicate: …, object: … } fields?

Holger


Valentin Chialda

unread,
Aug 14, 2025, 9:03:17 AMAug 14
to topbrai...@googlegroups.com
Hi Holger,
Thanks for your time!!

Yes, I've just tried using objects but without success. I'm sure I'm
missing some fundamental graph understanding or I'm doing something
wrong. My scope is to rewrite some old SWP to ADS to be able to
upgrade to EDG v8 from v7. I'm stuck at v7 (unsupported) and I have
some very old scripts (based on teamwork:CommitRule and
teamwork:EditRule) that need to be redone with ADS instead.
Anyway, I've enabled the checkbox to have the ability to save (like in
the screenshot) and there in the left side it's the taxonomy where I
need to create another node under ""Events root". I've added an array
of triples (objects this time) where I assumed I need to tell on each
triple what's the graph, who's the top concept, a label, a type .. and
so on.. But the same happens, no feedback on the console or anywhere
else.
The last complete code is:


const targetUserGraph =
graph.withDataGraph('urn:x-evn-master:events_store_taxonomy',
tbs.queryGraph);

// Define the existing ConceptScheme URI
let conceptSchemeURI =
"http://www.ibm.com/standards/vocabulary/taxonomies/events_store_taxonomy/Events_root";

// Generate URIs for the new top concepts
let topConcept1URI =
"http://www.ibm.com/standards/vocabulary/taxonomies/events_store_taxonomy/Events_root/ZZZ";

const targetUserGraph =
graph.withDataGraph('urn:x-evn-master:events_store_taxonomy',
tbs.queryGraph);


// Define the existing ConceptScheme URI
let conceptSchemeURI =
"http://www.ibm.com/standards/vocabulary/taxonomies/events_store_taxonomy/Events_root";


// Generate URIs for the new top concepts
let topConcept1URI =
"http://www.ibm.com/standards/vocabulary/taxonomies/events_store_taxonomy/Events_root/newtest";


graph.transaction(
targetUserGraph,
"add top concepts to Events_root",
function addTopConcepts() {

let res = [
{
subject: topConcept1URI,
predicate: "http://www.w3.org/2004/02/skos/core#topConceptOf",
object: conceptSchemeURI
},
{
subject: topConcept1URI,
predicate: "http://www.w3.org/2000/01/rdf-schema#label",
object: "Business Events"
},
{
subject: topConcept1URI,
predicate: "http://www.w3.org/2004/02/skos/core#inScheme",
object: conceptSchemeURI
},
{
subject: conceptSchemeURI,
predicate: "http://www.w3.org/2004/02/skos/core#hasTopConcept",
object: topConcept1URI
}
];

graph.addTriples(res);
}
);
--


Cu stima / Best wishes,

Valentin Chialda

T: +40 (0) 723 290 888
E: valentin...@gmail.com
image.png

Holger Knublauch

unread,
Aug 14, 2025, 9:25:14 AMAug 14
to topbrai...@googlegroups.com
The subjects and objects need to be named nodes, not strings, so use


I don’t see code that would print to the console?

In my local test the preview button then shows what would be added:

PastedGraphic-1.png

Holger


-- 
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
To post to this group, send email to topbrai...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.

Valentin Chialda

unread,
Aug 14, 2025, 10:27:21 AMAug 14
to topbrai...@googlegroups.com
Bingo,

Thanks a lot for the help !!!! 

I was able to add a new one. Now I'll try to get the current edited graph and add the relevant info similarly (using the ttl "file" and "commitScript").


image.png

You received this message because you are subscribed to a topic in the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/topbraid-users/3QxHt_UrCjA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/topbraid-users/5EB9E72A-05F3-4001-B420-5768E016B459%40topquadrant.com.


--


Cu stima / Best wishes,

Valentin Chialda


LinkedIn Instagram 
Reply all
Reply to author
Forward
0 new messages