Looking for Documentation and examples for ADS and ScriptEditor

24 views
Skip to first unread message

Hamid Abdirad

unread,
Sep 16, 2022, 1:44:12 AMSep 16
to TopBraid Suite Users
Hi all,
I am wondering if there is a better set of guides for using ADS and ScriptEditor, especially for creating assets based on custom ontologies included in Data Graphs. 
I looked at the following and API guide, but they did not help me much:
 
More specifically, I am trying to use graph.add to create and persist triples but I do not know how to use classes from a custom ontology inside arguments.

Let's say I have included custom ontology1 and it has Thing > SampleObject as public classes. Using the ADS in my data graph, how can I create a new asset that is a SampleObject:
graph.add(URI, rdf.type, WHAT_TO_PUT_HERE?) 

I tried things like ontology1.SampleObject, but it does not show as an asset. Looking at the preview of the script run, it is not being consider a valid triple. 

Thank you,
Hamid

Holger Knublauch

unread,
Sep 16, 2022, 1:50:47 AMSep 16
to topbrai...@googlegroups.com
Hi Hamid,

did you set these properties for your namespace in the ontology?

Script API generation options

For example if your namespace has the prefix "myprefix" then set generate prefix constants to "myprefix" and you SHOULD be able to write things like

let newAsset = graph.namedNode(URI);
newAsset.add(rdf.type, myprefix.SampleObject);

Likewise, if you state generate prefix classes "myprefix" you may be able to just do

let newAsset = myprefix.createSampleObject(...)

(Assuming the script editor panel is in write mode using the lock button of the upper right corner, and that you have refreshed the API after changes to the prefixes as above)

Holger



--
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/c58a9d35-c71a-4467-8835-e9a41d0b1d5cn%40googlegroups.com.

Hamid Abdirad

unread,
Sep 23, 2022, 5:49:10 PMSep 23
to TopBraid Suite Users
Thank you for your help, Holger. I was able to create assets with your help.
A couple of followup questions:
(1) in my script, the prefix does not work for me and I need to use the ontology name as the superclass name. e.g., g.createEverything() does not work but dpr.createEverything() works.
see the attachement 1 please. Can you hint at what the reason might be? What happens if multiple ontologies use the same prefix (by mistake)? And what if I do not have access to all ontologies of my organization to check for this?

(2) I have two classes named "Task" and "Level" and Task assets have an object property named "RelatedLevel". How can I assign Levels to the Tasks using ADS?
For example: I have  "http://example.org/data-graphs/TestVDC2#Level22" as URI and "Level22" as level but I cannot make ties between the tasks I am creating and the levels.
see attachment 2 please. I tried using URI, label, javascript object itself but none worked. If applicable, would you give me ADS examples for adding this object using triples or using javascript objects? 

Thank you,
Hamid
1.JPG
2.JPG

Holger Knublauch

unread,
Sep 24, 2022, 3:52:33 AMSep 24
to topbrai...@googlegroups.com

On 23 Sep 2022, at 11:49 pm, Hamid Abdirad <habdir...@gmail.com> wrote:

Thank you for your help, Holger. I was able to create assets with your help.
A couple of followup questions:
(1) in my script, the prefix does not work for me and I need to use the ontology name as the superclass name. e.g., g.createEverything() does not work but dpr.createEverything() works.
see the attachement 1 please. Can you hint at what the reason might be?

I don't see an attachment - did you mean to share Turtle files? Without the details it's a bit difficult, so feel free to send me your files off-list. Do you see any constant called g in the generated source code (either auto-complete after g. or open the Panel > Script API Viewer. One possible explanation is that the generate prefix constants triple is defined outside of an Ontology or File - those cannot be stored in instance graphs such as Taxonomies.

What happens if multiple ontologies use the same prefix (by mistake)? And what if I do not have access to all ontologies of my organization to check for this?

Overlapping prefixes or namespaces is a general issue with the semantic web stack, and there is no clean solution beside applying organization-wide policies. In practice, we hardly see overlapping prefixes, and even http://prefix.cc has few examples where clashes are likely. Having said this, you, as the ontology developer, typically have full control over which files or graphs you include and at that time you can check for conflicting prefixes.


(2) I have two classes named "Task" and "Level" and Task assets have an object property named "RelatedLevel". How can I assign Levels to the Tasks using ADS?
For example: I have  "http://example.org/data-graphs/TestVDC2#Level22" as URI and "Level22" as level but I cannot make ties between the tasks I am creating and the levels.
see attachment 2 please. I tried using URI, label, javascript object itself but none worked. If applicable, would you give me ADS examples for adding this object using triples or using javascript objects? 

If you already know the URI and just need a reference to that object, you can use

let level = graph.namedNode("http://example.org/data-graphs/TestVDC2#Level22");

but your mechanism - to fetch the first instance - would also work. OTOH if you use something like

level.uri

then the value that you are assigning is interpreted as a string, and it would become an RDF string literal, not an object reference. So in your example, just drop the .uri and it should work.

HTH and please feel free to follow up
Holger


Reply all
Reply to author
Forward
0 new messages