Hi Tim,

you were almost there. The missing info is that ui:update will only write to the context graph when done, not any graph mentioned in the INSERT. So change it to

<ui:setContext ui:queryGraph="&lt;http://example.com/swp_write_to_graph_output&gt;";>
        <ui:update ui:updateQuery="{!
                INSERT {
                    ?s ?p ?o .
                }
                WHERE {
                    GRAPH ui:tempGraphFinalOutput {
                        ?s ?p ?o .
                    } .
                } }"/>
    </ui:setContext>

which makes the target graph the active context graph while the source graph is moved into the WHERE clause.

You may also want to wrap the ui:update with a ui:transaction if you want to bundle multiple updates into a single save step. It will otherwise auto-create a transaction for each nested ui:update.

HTH and thanks for taking the time to prepare the bundled example.

Holger


On 18/08/2020 05:34, Tim Smith wrote:
Hi,

I cannot write to an existing graph in the workspace from an SWP.  This is a problem that has plagued me since TBC 5.1.4 so perhaps I'm doing something wrong.  I've attached a minimal example as a project.

The file, swp_write_to_graph.ui.ttlx contains a subclass of ui:Services called w2g:w2graph.  In the ui:prototype, I populate a temp graph (ui:tempGraphFinalOutput) with a single triple.  ui:prototype shown below.

Next, I dump the temp graph to a temporary file using ui:dumpGraph to ensure ui:tempGraphFinalOutput contains the triple.  This works as expected.  Then I try to insert the contents into an RDF file that exists in the workspace.  This file contains nothing but the triples TBC creates when a new RDF file is created.

The SWP call completes successfully but the single triple is not inserted into the existing graph.

The SWP is called using:

http://localhost:8083/tbl/swp?_viewClass=w2g:w2graph&outputGraph=http://example.com/swp_write_to_graph_output&_contextdebug=true

What am I missing such that I cannot insert triples into existing graphs from an SWP?

Note that my ultimate goal is to pass the name of the output graph into the SWP so you will see a constraint setup for that purpose but it is not used in this example.

Any help would be appreciated.  I need to create a number of SWPs and being able to manipulate graphs at will is a skill I need.

Tim



<ui:group let:outputFileGraph="{= IRI(?outputGraph) }">
    <h3>The output graph is {= ?outputGraph }  Graph: {= ?outputFileGraph }</h3>{= smf:trace("Populating the temp graph... ") }<ui:update ui:updateQuery="{!
            INSERT {
                GRAPH ui:tempGraphFinalOutput {
                    ?uri rdfs:label &quot;I am a Thing&quot; .
                } .
            }
            WHERE {
                BIND (spif:buildURI(&quot;&lt;http://example.com/{?1}&gt;&quot;, &quot;i_am_a_thing&quot;) AS ?uri) .
            } }"/>{= smf:trace("Finished!") }

{= smf:trace("Dumping to the debug graph...") }<ui:dumpGraph ui:filePath="/SWP_Example/swp_write_to_graph_debug_output.ttl" ui:graph="ui:tempGraphFinalOutput"/>     <!-- Try to insert into the output graph -->{= smf:trace("Writing output graph... ") }<ui:setContext ui:queryGraph="ui:tempGraphFinalOutput">
        <ui:update ui:updateQuery="{!
                INSERT {
                    GRAPH &lt;http://example.com/swp_write_to_graph_output&gt; {
                        ?s ?p ?o .
                    } .
                }
                WHERE {
                    ?s ?p ?o .
                } }"/>
    </ui:setContext>
</ui:group>
--
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-users+unsubscr...@googlegroups.com <mailto:topbraid-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/CAF0Wbn%2BG7FQ8vk8nsLP8FPt%3DoLy86mOs9PuBudBcQP4FTTyO3g%40mail.gmail.com <https://groups.google.com/d/msgid/topbraid-users/CAF0Wbn%2BG7FQ8vk8nsLP8FPt%3DoLy86mOs9PuBudBcQP4FTTyO3g%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 topbraid-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/f1680b28-4484-6d60-6f7d-8f2ec33bb586%40topquadrant.com.

Reply via email to