Calling tbs:loadRemoteResources

25 views
Skip to first unread message

Marie Valadez

unread,
May 8, 2024, 6:15:11 PMMay 8
to TopBraid Suite Users
Hello! 

I found some documentation about tbs:loadRemoteResource which can be used to programmatically load the remote resource which is similar to pushing the button in UI to reload (https://archive.topquadrant.com/doc/7.8/user_guide/remote/index.html?highlight=loadremoteresource). However, I can't seem to find an example of how to call this in a dash:js script. I would like to reload certain assets so that they can be found when doing a SPARQL query. We have a data graph setup as the remote asset (graph 1) which is imported by another data graph in EDG (graph 2). It is from graph 2 that I would like to reload the remote asset and be able to retrieve it in SPARQL queries. I tried calling 
tbs.loadRemoteResources(false, true, 600, 1000000, 10, false, null, true, null, ['http://example.com/CON_123456'])  from the script editor to test it out but no luck. 
I tried different variations of the last argument such as http://example.com/CON_123456 and <http://example.com/CON_123456> with and without enclosing in brackets. I do see it says experimental so maybe it isn't fully implemented yet?

Was thinking maybe I need to call the remote graph first somehow but not entirely sure. Would appreciate the help!

Thanks!

Holger Knublauch

unread,
May 9, 2024, 3:37:35 AMMay 9
to 'Luis Enrique Ramos García' via TopBraid Suite Users
Hi Marie,

the syntax of that function in JS requires a JS object as its sole argument. So it would look like

tbs.loadRemoteResources({
forced: true,
resources: [ graph.namedNode('http://example.com/CON_123456') ]
})

You can see these definitions when you hover with the mouse over the function:

PastedGraphic-1.png

or press Ctrl-space inside the curly brackets:

PastedGraphic-2.png


Also note that 8.0 has just come out where the support for remote data graphs has been promoted from beta to production quality.

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 on the web visit https://groups.google.com/d/msgid/topbraid-users/2b1693d1-96e1-4f76-aad1-06b95888006fn%40googlegroups.com.

Marie Valadez

unread,
May 9, 2024, 10:46:39 AMMay 9
to topbrai...@googlegroups.com
Hello Holger, 

Thanks for the response. I followed your instructions and tried using the code within the ScriptEditor and from within an ExploreAction. However, in both cases I returned the same error message. 
image.png 
Here is what I did from within the ScriptEditor: 
tbs.loadRemoteResources({
forced: true,
maxDepth: 5,
maxSeconds: 600,
resources: [ graph.namedNode('http://example.com/CON_123456')]
})

Also tried:
tbs.loadRemoteResources({
forced: true,
maxDepth: 5,
maxSeconds: 600,
resources: [ graph.namedNode({qname: 'ex:CON_123456'})]
})

After receiving the error, thought maybe it doesn't work in the ScriptEditor so tried as a resource action.
ex:ConLoadResource
  a dash:ExploreAction ;
  dash:actionGroup ex:ExploreActionsGroup ;
  dash:actionIconClass "fa-solid fa-list" ;
  dash:js """tbs.loadRemoteResources({
    forced: true,
    maxDepth: 5,
    maxSeconds: 600,

    resources: [ graph.namedNode('http://example.com/CON_123456')]
})""" ;
  rdfs:label "Test Load Resource" ;
  sh:order 1 ;
.

Any tips on how to get this working to be used within an Explore Action, Modify Action, Batch Action, and script constraints? Is there some additional context that I am missing for it to be applied?

Thank you!

Marie

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/BiNugp_Ygr4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/CFC575C1-E461-4753-AB81-4F58617070D3%40topquadrant.com.

Holger Knublauch

unread,
May 9, 2024, 10:50:05 AMMay 9
to 'Luis Enrique Ramos García' via TopBraid Suite Users
Sorry I didn’t notice that the value of resources is supposed to be a space-separated list of URIs only. So instead of that array of NamedNodes, just try a single string with spaces in between URIs…

Holger



On 9 May 2024, at 4:46 PM, Marie Valadez <meval...@gmail.com> wrote:

Hello Holger, 

Thanks for the response. I followed your instructions and tried using the code within the ScriptEditor and from within an ExploreAction. However, in both cases I returned the same error message. 
<PastedGraphic-1.png>

or press Ctrl-space inside the curly brackets:

Marie Valadez

unread,
May 9, 2024, 3:33:51 PMMay 9
to TopBraid Suite Users
That did the trick. Thank you Holger!

Marie Valadez

unread,
May 9, 2024, 4:28:54 PMMay 9
to TopBraid Suite Users
Is there a way to trigger this reload automatically when a user selects an instance. I tried adding a dash:ResourceService to the class Concept through the property dash:resourceService. I was hoping when a user clicked an instance of Concept that the UI would automatically trigger to reload that instance so they wouldn't have to manually trigger it themselves. However, doesn't seem to be working. I can get it working in the ScriptEditor but failing when putting it in the Ontology. Maybe I am misunderstanding the capability of the dash:ResourceService. 

ex:Concept  a sh:NodeShape ;
 dash:resourceService ex:ReloadRemoteDataInstance;
...

ex:ReloadRemoteDataInstance
  a dash:ResourceService ;

  dash:js """
tbs.loadRemoteResources({
    forced: true,
    maxDepth: 2,
    maxSeconds: 100,
    recursive: true,
    resources: focusNode.uri
})
""" ;
  rdfs:comment "Reloads a remote data instance when selected in the EDG UI" ;
  rdfs:label "Reload Remote Data Instances" ;
  sh:order 0 ;



Holger Knublauch

unread,
May 10, 2024, 3:49:16 AMMay 10
to 'Luis Enrique Ramos García' via TopBraid Suite Users

On 9 May 2024, at 10:28 PM, Marie Valadez <meval...@gmail.com> wrote:

Is there a way to trigger this reload automatically when a user selects an instance.

This already happens from the user interface. When the user navigates to a new resource with the Form Panel, all declared properties of that resource will be loaded from the SPARQL endpoint.


I tried adding a dash:ResourceService to the class Concept through the property dash:resourceService. I was hoping when a user clicked an instance of Concept that the UI would automatically trigger to reload that instance so they wouldn't have to manually trigger it themselves. However, doesn't seem to be working. I can get it working in the ScriptEditor but failing when putting it in the Ontology. Maybe I am misunderstanding the capability of the dash:ResourceService. 

ex:Concept  a sh:NodeShape ;
 dash:resourceService ex:ReloadRemoteDataInstance;
...

ex:ReloadRemoteDataInstance
  a dash:ResourceService ;
  dash:js """
tbs.loadRemoteResources({
    forced: true,
    maxDepth: 2,
    maxSeconds: 100,
    recursive: true,
    resources: focusNode.uri
})
""" ;
  rdfs:comment "Reloads a remote data instance when selected in the EDG UI" ;
  rdfs:label "Reload Remote Data Instances" ;
  sh:order 0 ;

These scripts would need to be triggered by some other service. So if you have a custom web application with something like a form panel, that would need to call that service before it can query the triples for it.

Holger


Reply all
Reply to author
Forward
0 new messages