SPARQL/GraphQL to fetch Change History

109 views
Skip to first unread message

deviredd...@gmail.com

unread,
Sep 3, 2021, 5:46:53 AM9/3/21
to TopBraid Suite Users
Hi,
   We are looking to generate reports on change history of a taxonomy from TopBraid EDG. I see that there is a view(please check the attachment) in EDG that shows change history of the taxonomy. Now my question is that is there an out of box service to fetch those change history details or could you please share the SPARQL/GraphQL that is used for the "Change History" view in EDG UI? Could some one please help?

Thanks,
Sanjeev
Change History.PNG

David Price

unread,
Sep 3, 2021, 7:34:37 AM9/3/21
to topbrai...@googlegroups.com
The change history graph can be queried using SPARQL. The graph name is is the EDG identier for the graph plus .tch (e.g. urn:x-evn-master:my_schema.tch ).

SELECT *
WHERE {
    GRAPH <urn:x-evn-master: my_schema.tch >
  { ?s ?p ?o . }
}

will find everything and from their you can see the data available to query.

The key classes are teamwork:Tag and teamwork:Change and the link between them is ?change teamwork:tag ?tag . 

The link to actual changes made is via ?change teamwork:added ?added . and ?change teamwork:deleted ?deleted .

Make a SPARQL query to deliver whatever you need based on those, and then save your SPARQL query which will make a service available via an HTTP link.

Cheers,
David

--
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 on the web visit https://groups.google.com/d/msgid/topbraid-users/08254afa-c076-468d-9cea-573eb5fad4d0n%40googlegroups.com.
<Change History.PNG>


deviredd...@gmail.com

unread,
Sep 3, 2021, 10:50:23 AM9/3/21
to TopBraid Suite Users
Thanks David for your response.

When I run the above SPARQL then I see some values under Subject/Object column as <@118b602b-d663-4152-ac2c-628d36c9e2d6>. What kind/type of values are those? Why am I asking is that when I use them in another SPARQL(as below) then no results are returned. May be I am referring/using to them in a wrong way. Could you please give an example on this?

SELECT *
WHERE {
    GRAPH <urn:x-evn-master:geo.tch>
    {
    <@118b602b-d663-4152-ac2c-628d36c9e2d6> ?p ?o .
}
}

Thanks,
Sanjeev

David Price

unread,
Sep 3, 2021, 11:07:50 AM9/3/21
to topbrai...@googlegroups.com
Sounds like those are blank nodes (i.e. anonymous).

Start with something more focused like

?tag a teamwork:Tag .
?tag ?tagp ?tago .

and then

?tag a teamwork:Tag .
?change teamwork:tag ?tag . 
?change a  teamwork:Change .
?change ?chgp ?chgo .

and see what’s related to the tag (i.e. workflow) and individual changes.

Cheers,
David

deviredd...@gmail.com

unread,
Sep 6, 2021, 9:20:27 AM9/6/21
to TopBraid Suite Users
The classes teamwork:Tag & teamwork:tag don't return any results. The class teamwork:Change returns some results but getting the actual change details is depending on those blank nodes (ex: <@8c7d6ecd-b8cf-44e6-9b4a-cfc3e60974d9>, Please check the attached screenshot). Actually what I am trying to do is that I updated a node/class(Antarctica) in the taxonomy(Geography Taxonomy) and trying to get the change log for that.

SPARQLs:
1) SELECT *

WHERE {
    GRAPH <urn:x-evn-master:geo.tch>
    {
        ?tag a teamwork:Tag .
        ?tag ?tagp ?tago .
    }
}

Output: No results

2) SELECT *

WHERE {
    GRAPH <urn:x-evn-master:geo.tch>
    {
        ?tag a teamwork:Tag .
        ?change teamwork:tag ?tag .
        ?change a  teamwork:Change .
        ?change ?chgp ?chgo .
    }
}

Output: No results

3)SELECT *

WHERE {
    GRAPH <urn:x-evn-master:geo.tch>
    {
        ?change a  teamwork:Change .
        ?change ?chgp ?chgo .
    }
}
Output: Returns some results.


Thanks,
Sanjeev
Geo_Antarctica.PNG

David Price

unread,
Sep 6, 2021, 10:10:22 AM9/6/21
to topbrai...@googlegroups.com
Hi,

Tags are workflows/working copies, so I guess you’re not using them.

Blank nodes are perfectly normal in the result of a query. You just don't put them into SPARQL when writing a new query. It’s only the data at the other end of something with a blank node subject that is of interest. Just leave the places with blank node values as ?<something> in a single larger query and move on to find the items of interest via their predicate (aka property 

e.g. so to find what was added by a change:

?change teamwork:added ?added .
?added teamwork:subject <http://example/something>
?added teamwork:predicate skos:prefLabel 
?added teamwork:object “Antartica_Updated”.

Where ?added is a variable that just happens to result in a blank node if returned. Don’t return the blank node, just return the data of interest.

The above tells you that:

 <http://example/something> skos:prefLabel “Antartica_Updated” .

was added to the graph. Delete works in a similar way.

FWIW the little SPARQL I sent you was just so you couild query the data and see what data exists and what properties they have and write the SPARQL you need, it was not in any way a solution to your problem as only you know your requirements.

Cheers,
David

Irene Polikoff

unread,
Sep 7, 2021, 9:23:46 AM9/7/21
to topbrai...@googlegroups.com
For GraphQL, Go to Export -> GraphQL Queries and select “as Teamwork Graph” - this is the change history graph.



For examples on querying change history, see https://www.topquadrant.com/querying-topbraid-edg-with-graphql/

David already gave you some examples of SPARL queries. If you go to Server Administration -> Available Web Services and then check Teamworks SPIN Templates, you will see additional examples that have been templated. For example:



deviredd...@gmail.com

unread,
Sep 13, 2021, 6:30:53 AM9/13/21
to TopBraid Suite Users
Thanks Irene for your response. I have a question on getting human readable labels from the results of Change History GraphQL. I see that in SPARQL there is method "afn:localname" to get the local name(prefLabel) of a URI resource(skos:prefLabel ) but it is not the actual human readable label (preferred label) seen in EDG UI. Now my question is that, with GraphQL is there a way to get the human readable labels(as seen in EDG UI) of URI resources(Subject/Predicate/Object) in Change History results(please check the below screenshot)?

graphql_chage_history.PNG



Thanks,
Sanjeev

Holger Knublauch

unread,
Sep 13, 2021, 7:21:15 AM9/13/21
to topbrai...@googlegroups.com

On 2021-09-13 8:30 pm, deviredd...@gmail.com wrote:

Thanks Irene for your response. I have a question on getting human readable labels from the results of Change History GraphQL. I see that in SPARQL there is method "afn:localname" to get the local name(prefLabel) of a URI resource(skos:prefLabel ) but it is not the actual human readable label (preferred label) seen in EDG UI. Now my question is that, with GraphQL is there a way to get the human readable labels(as seen in EDG UI) of URI resources(Subject/Predicate/Object) in Change History results(please check the below screenshot)?

No, you can only get the comment of the change, e.g.

To get the labels of the resources (subject, predicate or object), you would need to do a join with the actual data graph, and that is not possible with the current GraphQL endpoint for the team graph. SPARQL would be better for that purpose. The GraphQL endpoint is further limited in that it only renders subject/predicate/object as strings, without further metadata such as the exact datatype.

Also keep in mind that resources may have been deleted, in which case even the main graph wouldn't have a suitable label anymore. That's also why the Change History panel only shows the Turtle source code of what has been changed - as this is the only reliable info that can be derived at that stage.

Holger



graphql_chage_history.PNG



Thanks,
Sanjeev
On Tuesday, September 7, 2021 at 6:53:46 PM UTC+5:30 Irene Polikoff wrote:
For GraphQL, Go to Export -> GraphQL Queries and select “as Teamwork Graph” - this is the change history graph.



For examples on querying change history, see https://www.topquadrant.com/querying-topbraid-edg-with-graphql/

David already gave you some examples of SPARL queries. If you go to Server Administration -> Available Web Services and then check Teamworks SPIN Templates, you will see additional examples that have been templated. For example:



On Sep 3, 2021, at 5:46 AM, deviredd...@gmail.com <deviredd...@gmail.com> wrote:

Hi,
   We are looking to generate reports on change history of a taxonomy from TopBraid EDG. I see that there is a view(please check the attachment) in EDG that shows change history of the taxonomy. Now my question is that is there an out of box service to fetch those change history details or could you please share the SPARQL/GraphQL that is used for the "Change History" view in EDG UI? Could some one please help?

Thanks,
Sanjeev

--
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 on the web visit https://groups.google.com/d/msgid/topbraid-users/08254afa-c076-468d-9cea-573eb5fad4d0n%40googlegroups.com.
<Change History.PNG>
--
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.

deviredd...@gmail.com

unread,
Sep 15, 2021, 5:37:51 AM9/15/21
to TopBraid Suite Users
Thanks Holger for your response. Could you please give a SPARQL example on joining actual data graph and teamwork graphs to get the labels of the resources (subject, predicate or object)?

Thanks,
Sanjeev

Holger Knublauch

unread,
Sep 15, 2021, 7:03:39 PM9/15/21
to topbrai...@googlegroups.com

This is for subject(s):

Here is a variation that does either added subject, predicate or object:

PREFIX teamwork: <http://topbraid.org/teamwork#>
PREFIX ui: <http://uispin.org/ui#>

SELECT DISTINCT ?resource ?label


WHERE {
      GRAPH <urn:x-evn-master:geo.tch> {
        ?change a teamwork:Change .

        ?change teamwork:added ?added .

        ?added teamwork:subject|teamwork:predicate|teamwork:object ?resource .
        FILTER isIRI(?resource)
      }
      BIND (ui:label(?resource) AS ?label)
}

HTH
Holger

Reply all
Reply to author
Forward
0 new messages