invoking EDG services (such as publish to Explorer) within ADS

192 views
Skip to first unread message

Rob Atkinson

unread,
May 2, 2022, 1:22:55 AM5/2/22
to TopBraid Suite Users

hi

havent been able to find in the docs or examples, but suspect I may be missing something.

I have a DataGraph I want to publish to two different explorer instances - but with different data in each.  Some other things may happen - custom review steps - so its going to be in ADS.

So I need an ADS script capable of (say) cloning and modifying an asset collection then pushing the two graphs to two different Explorer instances.  Looking at the calls the endpoint and username is picked up from the server config - for a default location.

How should one invoke such services in ADS - is it a matter of building up my own utility library on top of jquery or does something else exist?

Is there any advice re respecting permissions of the user, or allowing the script to do something i dont want the user to do normally ? 

Cheers
Rob



Holger Knublauch

unread,
May 2, 2022, 3:13:10 AM5/2/22
to topbrai...@googlegroups.com

Hi Rob,

assuming you're on 7.2, ADS now supports a new API that includes functions like tbs.createAssetCollection which you could theoretically use to create a clone which you later tbs.deleteAssetCollection().


On 2022-05-02 3:22 pm, Rob Atkinson wrote:

hi

havent been able to find in the docs or examples, but suspect I may be missing something.

I have a DataGraph I want to publish to two different explorer instances - but with different data in each.  Some other things may happen - custom review steps - so its going to be in ADS.

So I need an ADS script capable of (say) cloning and modifying an asset collection then pushing the two graphs to two different Explorer instances.  Looking at the calls the endpoint and username is picked up from the server config - for a default location.

How should one invoke such services in ADS - is it a matter of building up my own utility library on top of jquery or does something else exist?

Publishing to Explorer is not part of that API (yet). ADS can make generic web API calls using IO.http() in case you want to simulate the network traffic that you see, e.g. to invoke the sendProjects service by hand. That's not an elegant solution, but from what I see a necessary hack for now. I am not 100% up to date on the web services but will follow-up here if my colleagues have a better idea.



Is there any advice re respecting permissions of the user, or allowing the script to do something i dont want the user to do normally ?

ADS scripts cannot switch users, so you'd need to invoke this from a user with sufficient permissions.

Holger



Cheers
Rob



--
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/1a94dfe9-4d1b-4ed6-946d-75adc72e2ed7n%40googlegroups.com.

Holger Knublauch

unread,
May 2, 2022, 4:49:23 AM5/2/22
to topbrai...@googlegroups.com


On 2022-05-02 5:13 pm, Holger Knublauch wrote:

Hi Rob,

assuming you're on 7.2, ADS now supports a new API that includes functions like tbs.createAssetCollection which you could theoretically use to create a clone which you later tbs.deleteAssetCollection().


On 2022-05-02 3:22 pm, Rob Atkinson wrote:

hi

havent been able to find in the docs or examples, but suspect I may be missing something.

I have a DataGraph I want to publish to two different explorer instances - but with different data in each.  Some other things may happen - custom review steps - so its going to be in ADS.

So I need an ADS script capable of (say) cloning and modifying an asset collection then pushing the two graphs to two different Explorer instances.  Looking at the calls the endpoint and username is picked up from the server config - for a default location.

How should one invoke such services in ADS - is it a matter of building up my own utility library on top of jquery or does something else exist?

Publishing to Explorer is not part of that API (yet). ADS can make generic web API calls using IO.http() in case you want to simulate the network traffic that you see, e.g. to invoke the sendProjects service by hand. That's not an elegant solution, but from what I see a necessary hack for now. I am not 100% up to date on the web services but will follow-up here if my colleagues have a better idea.

Maybe try graph.swp('teamwork:PublishProjectToNamedExplorer', { ... })

HTH
Holger

Rob Atkinson

unread,
May 2, 2022, 7:52:41 PM5/2/22
to TopBraid Suite Users
Thanks Holger

I'm still on 7.1 for now - though after project initial build will have option to upgrade to 7.2 :-(

for the "supported in 7.2" API 

I guess my best guess would be to create a proxy function to mirror this 7.2 function.

 tbs.createAssetCollection

is there a way to get access to details without a 7.2 install?


and for general service invocation...

looking for documentation on these i can find graph.swp in the scriptAPI 


but I need then to dive further into

 @param {?object} [params] - name-value pairs for the arguments of the element, typically as GraphNodes

so I went looking for the Teamwork functions reference - I notice a lot of the different doc entry points have been cleaned up (a Good Thing) so I'll start with a quick question as to where I would find such documentation now?

in this case teamwork:PublishProjectToNamedExplorer  

- so how does this relate to https://sop.dev.bdr.gov.au/edg/tbl/sendProjects  - which seems to be tbladmin.sendProjects() - i guess a function in the react bundle that does something under the hood to invoke that service?  I that function itself based on a generic service call we could use without raw jquery  ?



 /**
     * Runs an SWP element with a provided set of parameters.
     * This can not be used in read-only mode and should be used by experienced TopBraid users only.
     * 
     * NOTE: This function is likely going to be deleted in future versions.  Instead users are encouraged to explicitly
     * mark the SWP scripts that they want to call, using ui:scriptFunctionReadOnly and then use the generated functions.
     * Meanwhile this function here is kept to simplify experiments.
     * 
     * @param {string} viewClass - the qname of the view class in the ui:graph, e.g. 'ex:MyElement'
     * @param {?object} [params] - name-value pairs for the arguments of the element, typically as GraphNodes
     * @returns {string} the SWP response as a string
     */
    swp(viewClass, params) {
        return __jenaData.swp(viewClass, params);
    },

Holger Knublauch

unread,
May 2, 2022, 8:04:52 PM5/2/22
to topbrai...@googlegroups.com


On 2022-05-03 9:52 am, Rob Atkinson wrote:
Thanks Holger

I'm still on 7.1 for now - though after project initial build will have option to upgrade to 7.2 :-(

for the "supported in 7.2" API 

I guess my best guess would be to create a proxy function to mirror this 7.2 function.

 tbs.createAssetCollection

is there a way to get access to details without a 7.2 install?

Essentially it's a wrapper around the SWP element teamwork:createProject with a bit of syntactic sugar. You can see that in use when you look at the network traffic when you manually create an asset collection.


and for general service invocation...

looking for documentation on these i can find graph.swp in the scriptAPI 


but I need then to dive further into

 @param {?object} [params] - name-value pairs for the arguments of the element, typically as GraphNodes

so I went looking for the Teamwork functions reference - I notice a lot of the different doc entry points have been cleaned up (a Good Thing) so I'll start with a quick question as to where I would find such documentation now?

The most comprehensive documentation for SWP elements is to just open them in the editor, i.e. with TopBraid EDG Studio just open teamwork.ui.ttlx and you'll see

So it would be something like

graph.swp('teamwork:PublishProjectToNamedExplorer', { projectGraph: 'urn:x-evn-master:mygraph', userName: 'robXY', ... })

The ui:prototype above may answer your other questions.

Holger


Rob Atkinson

unread,
May 2, 2022, 11:02:23 PM5/2/22
to topbrai...@googlegroups.com
thanks holger

I guess I'm looking for a future-proof pattern for those wrappers so I can write my own using the same libraries and coding styles.  :-)

I have been looking at the ui.ttlx as normal - they dont give a lot of useful examples for the parameters though and its experimentation sometimes to work out what form things are in sometimes and the hidden assumptions about import closures.
_______________________________________________________
 
kind regards
Rob Atkinson
Lead Ontologist, Knowledge Architect at SURROUND Australia Pty Ltd
Address   Level 9, Nishi Building, 2 Phillip Law Street; New Acton Canberra Australia 2601
Phone     +61 419 202 973
Email      rob.at...@surroundaustralia.comWebsite   https://www.surroundaustralia.com

Enhancing Intelligence Within Organisations

delivering evidence that connects decisions to outcomes

Copyrights:

SURROUND Australia Pty Ltd is the copyright owner of all 
original content and attachments.
All rights reserved. 
Confidentiality Notice:
The contents of this e-mail are confidential to the ordinary user 
of the e-mail address to which it is addressed, and may also be 
privileged. If you are not the addressee of this e-mail, you may 
not copy, forward, disclose, or otherwise use it or any part of it 
or its attachments in any form whatsoever. If you have received 
this e-mail in error, please e-mail the sender by replying to this 
message.



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/7Lla6sBnK28/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/ce16892d-622a-d192-b8f1-695042de6e80%40topquadrant.com.

Holger Knublauch

unread,
May 2, 2022, 11:11:17 PM5/2/22
to topbrai...@googlegroups.com

The main future-proof pattern would be to use the tbs namespace introduced with 7.2. Where this is not possible (such as here), viewing the SWP and looking at their source code remains the best bet for users with sufficient skills. It's a bit like an open source project, in that sense.

With 7.2 we have introduced the ability to define API functions that are backed by SWP scripts, such as

tbs:createAssetCollection
  a ui:JSONService ;
  dash:apiStatus dash:Stable ;
  dash:canWrite true ;
  dash:contextFree true ;
  spin:constraint [
      a spl:Argument ;
      spl:optional true ;
      spl:predicate arg:defaultNamespace ;
      spl:valueType xsd:string ;
      rdfs:comment "The default namespace that shall be used for new resources." ;
    ] ;
  spin:constraint [
      a spl:Argument ;
      spl:optional true ;
      spl:predicate arg:description ;
      spl:valueType xsd:string ;
      rdfs:comment "The human-readable description of the new asset collection." ;
    ] ;
  spin:constraint [
      a spl:Argument ;
      spl:optional true ;
      spl:predicate arg:id ;
      spl:valueType xsd:string ;
      rdfs:comment """An optional internal identifier of the asset collection. If none is provided then the system will auto-generate an id from the name.

If you do provide an id, note that it must follow strict naming conventions: it must start with a letter and then consist only of letters, digits or the underscore. The letters are typically lower-case.""" ;
    ] ;
  spin:constraint [
      a spl:Argument ;
      spl:predicate arg:name ;
      spl:valueType xsd:string ;
      rdfs:comment "The human-readable name of the asset collection." ;
    ] ;
  spin:constraint [
      a spl:Argument ;
      spl:predicate arg:typeLabel ;
      spl:valueType xsd:string ;
      rdfs:comment "The (singular) label of the collection type, e.g. 'Ontology'." ;
    ] ;
  ui:prototype """
<ui:group let:projectType="{= tbs:assetCollectionTypeWithLabel(?typeLabel) }">
    <ui:if ui:condition="{= (!bound(?typeLabel)) || (!bound(?projectType)) }">
        <ui:throw ui:message="Cannot resolve asset collection type with label {= ?typeLabel }" ui:statusCode="{= 400 }"/>
    </ui:if>
    <ui:else let:owlImports="{#
            SELECT (GROUP_CONCAT(?import) AS ?result)
            WHERE {
                GRAPH ui:graph {
                    ?projectType teamwork:owlImports ?import .
                } .
            } }">
        <teamwork:createProject arg:comment="{= ?description }" arg:defaultNamespace="{= ?defaultNamespace }" arg:name="{= ?name }" arg:owlImports="{= ?owlImports }" arg:projectType="{= ?projectType }" id="{= ?id }">
            <ui:group let:projectGraph="{= tbs:assetCollectionURI(?graphId) }">
                <teamwork:CreateProjectPlugins arg:projectGraph="{= ?projectGraph }" arg:teamGraph="{= teamwork:teamGraph(?projectGraph) }"/>
            </ui:group>
            <ui:return ui:result="{= ?graphId }"/>
        </teamwork:createProject>
    </ui:else>
</ui:group>
"""^^ui:Literal ;
  ui:responseValueType xsd:string ;
  rdfs:comment "Creates a new asset collection of a given type. The new collection will have the current user as manager and no other role assignments." ;
  rdfs:label "create asset collection" ;
  rdfs:subClassOf ui:JSONServices ;
.

which then get exposed as Web services and ADS built-ins, see https://www.topquadrant.com/doc/7.2/ext/points.html#ext-services-swp

A possible approach then would be that users that need extra "stable" features can submit patches to tbs.ui.ttlx, e.g. to add the service to upload to explorer which wasn't on our radar yet - there are just so many different things you can do with EDG... We would put such patches into the next release (which would be every 3 months) as dash:Experimental and dash:Stable one version later, after which it will be handled with more backward-compatibility attention.

Holger

Rob Atkinson

unread,
May 2, 2022, 11:17:00 PM5/2/22
to topbrai...@googlegroups.com
Thanks - so what I'm hearing is install 7.2, generate an SWP API, go to the API script and copy the generated javascript...?  (I didnt see the generated API js example anywhere on first reading of the documents - only the data to drive it.) 

_______________________________________________________
 
kind regards
Rob Atkinson
Lead Ontologist, Knowledge Architect at SURROUND Australia Pty Ltd
Address   Level 9, Nishi Building, 2 Phillip Law Street; New Acton Canberra Australia 2601
Phone     +61 419 202 973
Email      rob.at...@surroundaustralia.comWebsite   https://www.surroundaustralia.com

Enhancing Intelligence Within Organisations

delivering evidence that connects decisions to outcomes

Copyrights:

SURROUND Australia Pty Ltd is the copyright owner of all 
original content and attachments.
All rights reserved. 
Confidentiality Notice:
The contents of this e-mail are confidential to the ordinary user 
of the e-mail address to which it is addressed, and may also be 
privileged. If you are not the addressee of this e-mail, you may 
not copy, forward, disclose, or otherwise use it or any part of it 
or its attachments in any form whatsoever. If you have received 
this e-mail in error, please e-mail the sender by replying to this 
message.


Holger Knublauch

unread,
May 3, 2022, 12:00:22 AM5/3/22
to topbrai...@googlegroups.com

In the example in the docs the ADS API would be a JavaScript function

    uiservice.ExampleJSONService('World')

to produce the Hello World JSON output. We are using the namespace tbs, e.g. tbs.createAssetCollection with the same mechanism.

Holger

Rob Atkinson

unread,
May 3, 2022, 12:23:41 AM5/3/22
to topbrai...@googlegroups.com
again thanks - and again let me clarify better 

i have stub functions as described already - its the content of the code I was seeking (if this can be exposed) - how the wrapper is written so it self-reports properly to the API and what request libraries (you mentioned IO.http) - so i dont choose one of the many other alternatives 


_______________________________________________________
 
kind regards
Rob Atkinson
Lead Ontologist, Knowledge Architect at SURROUND Australia Pty Ltd
Address   Level 9, Nishi Building, 2 Phillip Law Street; New Acton Canberra Australia 2601
Phone     +61 419 202 973
Email      rob.at...@surroundaustralia.comWebsite   https://www.surroundaustralia.com

Enhancing Intelligence Within Organisations

delivering evidence that connects decisions to outcomes

Copyrights:

SURROUND Australia Pty Ltd is the copyright owner of all 
original content and attachments.
All rights reserved. 
Confidentiality Notice:
The contents of this e-mail are confidential to the ordinary user 
of the e-mail address to which it is addressed, and may also be 
privileged. If you are not the addressee of this e-mail, you may 
not copy, forward, disclose, or otherwise use it or any part of it 
or its attachments in any form whatsoever. If you have received 
this e-mail in error, please e-mail the sender by replying to this 
message.


Holger Knublauch

unread,
May 3, 2022, 6:18:37 PM5/3/22
to topbrai...@googlegroups.com

Not sure what you mean. You can see the generated source code using the Script API Viewer panel. SWP-based ADS functions will internally simply use graph.swp().

Holger

Rob Atkinson

unread,
May 3, 2022, 7:46:02 PM5/3/22
to topbrai...@googlegroups.com
Round in circles.. need to install 7.2 for that
 and we get wrappers that dont explain the parameters or the graph closure requirements of the functions in sufficient depth.

 Will just have to resort to playing with low level HTTP calls 

knx7toxfhrFiAdEF.png
Reply all
Reply to author
Forward
0 new messages