Please find a solution using SWP attached. The bulk of the work is done via
which recursively calls itself for all children. The tempGraph is used
to prevent infinite cycles (I think).
Put the file into your workspace and refresh services or restart, then
call something like
http://localhost:8083/tbl/swp?_viewClass=classTreeJSON:getClassTreeJSON&rootClass=owl:Thing&_base=http://topbraid.org/examples/kennedys&_withImports=true
HTH
Holger
On 4/12/2019 06:46, MB MB wrote:
Hi Holger,
Yes, please do so. That would be great
Mike
On Mon, Dec 2, 2019 at 5:59 PM Holger Knublauch
<[email protected] <mailto:[email protected]>> wrote:
In addition to what Irene said about GraphQL, note that our
(class) tree components only ever load one level at a time, so a
"flat" query is sufficient to return the immediate children of
each parent node.
To produce a recursive JSON structure of arbitrary depth you need
something like SWP, creating a SWON-based element that calls
itself. However, this should be made solid against infinite
recursion, i.e. record which nodes have already been reached in
something like ui:tempGraph. I don't have an example of that
pre-built but could produce one if you are interested.
Holger
On 3/12/2019 11:28, MB MB wrote:
Hi Holger,
Thanks for your help so far. Even if there is a pure SPARQL
version we can work out a JSON tree from it, but we are also
interested in the SWP version as well. For this example we can use:
*Default namespace:* http://example.org/ontologies/mike_test_2#
*Top Class:* http://www.w3.org/2002/07/owl#Thing (I don't know
if you need this)
*SubClass:*
http://similar2.com/ontology/landslideATmaterialVH#anyMaterial
This is how our EDG console looks like.
Capture.PNG
|
Entercode here...
|
By querying any of the available end points, we are looking to
get back a JSON object similar to what EDG displays on the console.
Capture.PNG
Regards,
Mike
--
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 [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/5675bed8-ef0e-42f9-95b4-001f092aeb75%40googlegroups.com
<https://groups.google.com/d/msgid/topbraid-users/5675bed8-ef0e-42f9-95b4-001f092aeb75%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
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/WbSBy-qqr0E/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/2ff93add-a3f1-5472-1b46-dcf354cb95ec%40topquadrant.com
<https://groups.google.com/d/msgid/topbraid-users/2ff93add-a3f1-5472-1b46-dcf354cb95ec%40topquadrant.com?utm_medium=email&utm_source=footer>.
--
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 [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/CADoe7Nt5oZyL6c1PmxbUtBuhGtf1zDC_YgLjufVxNg_Y-%2BtRiQ%40mail.gmail.com
<https://groups.google.com/d/msgid/topbraid-users/CADoe7Nt5oZyL6c1PmxbUtBuhGtf1zDC_YgLjufVxNg_Y-%2BtRiQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/f5f7f81d-4b8c-f413-8c6a-28241299c819%40topquadrant.com.
# baseURI: http://example.org/classTreeJSON
# imports: http://uispin.org/swon
# prefix: classTreeJSON
@prefix afn: <http://jena.hpl.hp.com/ARQ/function#> .
@prefix arg: <http://spinrdf.org/arg#> .
@prefix classTreeJSON: <http://example.org/classTreeJSON#> .
@prefix default: <http://uispin.org/default#> .
@prefix fn: <http://www.w3.org/2005/xpath-functions#> .
@prefix let: <http://uispin.org/let#> .
@prefix letrs: <http://uispin.org/letrs#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix smf: <http://topbraid.org/sparqlmotionfunctions#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spif: <http://spinrdf.org/spif#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix spl: <http://spinrdf.org/spl#> .
@prefix spr: <http://spinrdf.org/spr#> .
@prefix spra: <http://spinrdf.org/spra#> .
@prefix swon: <http://uispin.org/swon#> .
@prefix ui: <http://uispin.org/ui#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example.org/classTreeJSON>
a owl:Ontology ;
owl:imports <http://uispin.org/swon> ;
owl:versionInfo "Created with TopBraid Composer" ;
.
classTreeJSON:getClassTreeJSON
a ui:Service ;
spin:constraint [
a spl:Argument ;
spl:predicate arg:rootClass ;
spl:valueType rdfs:Resource ;
rdfs:comment "The class that is the root of the hierarchy." ;
] ;
ui:prototype """
<swon:Object let:visited=\"{= EXISTS {
GRAPH ui:tempGraph {
?rootClass ui:visited true .
} .
} }\">
<ui:setContext ui:queryGraph=\"{= ui:tempGraph }\"
ui:silentTransactions=\"{= true }\">
<ui:addPropertyValue arg:property=\"{= ui:visited }\" arg:value=\"{=
true }\" ui:this=\"{= ?rootClass }\"/>
</ui:setContext>
<swon:Value arg:name=\"uri\" arg:value=\"{= ?rootClass }\"/>
<swon:Value arg:name=\"label\" arg:value=\"{= ui:label(?rootClass) }\"/>
<ui:if ui:condition=\"{= (!?visited) && EXISTS {
?any rdfs:subClassOf ?rootClass .
} }\">
<swon:Value arg:name=\"subClasses\">
<swon:Array>
<ui:forEach ui:resultSet=\"{#
SELECT ?subClass
WHERE {
?subClass rdfs:subClassOf ?rootClass .
BIND (ui:label(?subClass) AS ?subClassLabel) .
}
ORDER BY (?subClassLabel) }\">
<classTreeJSON:getClassTreeJSON arg:rootClass=\"{=
?subClass }\"/>
</ui:forEach>
</swon:Array>
</swon:Value>
</ui:if>
</swon:Object>
"""^^ui:Literal ;
rdfs:label "get class tree JSON" ;
rdfs:subClassOf ui:JSONServices ;
.