On 4/04/2017 22:48, Ilya Ushakov wrote:
Hi Everyone,
I use evn 5.3.
I try to write sparqlmotion script thats exports exports taxonomies.
I need to change skos:hasTopConcept property in result set.
For make this do next:
1. For building resultset I use sml:ApplyConstruct with query inside:
CONSTRUCT {
    ?a ?b ?c .
}
WHERE {
    {
        SELECT ?a ?b ?c
        WHERE {
            {
                {
                    BIND (IRI(?selectedGraph) AS ?graphName) .
                    BIND (IRI(?nodeURI) AS ?taxUri) .
                    GRAPH ?graphName {
                        ?a (skos:broader)* ?taxUri .
                        ?a ?b ?c .
                    } .
                } .
            }
            UNION
            {
                BIND (IRI(?selectedGraph) AS ?graphName) .
                GRAPH ?graphName {
                    ?a a skos:ConceptScheme .
                    ?a ?b ?c .
                } .
            } .
        }
    } .
}

FWIW I don't see the need for the nested SELECT in the query above. Just leave the UNION, as it will project the ?a ?b ?c variables into the CONSTRUCT clause anyway.


2. on the next step I try to use the sml:PerformUpdate
2.1. In case of using next query:
DELETE {
        ?a skos:hasTopConcept ?oldValue .
}
INSERT {
        ?a skos:hasTopConcept ?newValue .
}
WHERE {
    BIND (IRI(?nodeURI) AS ?newValue) .
    ?a ?b ?c .
    ?a skos:hasTopConcept ?oldValue .

}
I got NullPointerException in log
org.topbraidlive.sparqlmotion: Exception in SPARQLMotion Servlet (java.lang.NullPointerException) org.topbraid.spin.sparqlmotion.modules.SMException: java.lang.NullPointerException at org.topbraidlive.sparqlmotion.modules.performUpdate.PerformUpdateModule.execute(PerformUpdateModule.java:76) at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.execute(ExecutionEngineImpl.java:203) at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.executeModule(ExecutionEngineImpl.java:169) at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.execute(ExecutionEngineImpl.java:119) at org.topbraidlive.sparqlmotion.servlets.sparqlmotion.SPARQLMotionServlet.run(SPARQLMotionServlet.java:342) at org.topbraidlive.sparqlmotion.servlets.sparqlmotion.SPARQLMotionServlet.doGet(SPARQLMotionServlet.java:249)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.topbraid.auth.servlet.TBAuthEnabledServlet.service(TBAuthEnabledServlet.java:41) at org.topbraid.eclipsex.servlet.TBHttpServlet.service(TBHttpServlet.java:155) at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180) at org.eclipse.equinox.http.servlet.internal.HttpServiceRuntimeImpl$LegacyServlet.service(HttpServiceRuntimeImpl.java:1221) at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153) at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62) at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:132) at org.eclipse.equinox.http.servlet.internal.servlet.ProxyServlet.service(ProxyServlet.java:100)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:152) at org.topbraidlive.servletbridge.webapplicationserver.BridgeServlet.service(BridgeServlet.java:259)eServlet.java:352) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)lterChain.java:207) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)ava:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)java:614) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)a:88) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)2) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)read$WrappingRunnable.run(TaskThread.java:61) Caused bat org.topbraidlive.sparqlmotion.modules.performUpdate.PerformUpdateGraphStore.<init>(PerformUpdateGraphStore.java:105) at org.topbraidlive.sparqlmotion.modules.performUpdate.PerformUpdateModule.execute(PerformUpdateModule.java:55))

The graph produced by a sml:ApplyConstruct is temporary and has no URI. As such it also cannot be updated via sml:PerformUpdate. I also do not believe that you really want to manipulate the underlying data graph during the script as below.


2.2. In case of using GRAPH keyword inside DELETE and INSERT accoring to descrioption of sml:PerformUpdate

DELETE {
    GRAPH ?graphName {
        ?a skos:hasTopConcept ?oldValue .
    } .
}
INSERT {
    GRAPH ?graphName {
        ?a skos:hasTopConcept ?newValue .
    } .
}
WHERE {
    BIND (IRI(?selectedGraph) AS ?graphName) .
    BIND (IRI(?nodeURI) AS ?newValue) .
    ?a ?b ?c .
    ?a skos:hasTopConcept ?oldValue .
}
I got, "Unbound graph variable in sml:PerformUpdate" error message.

org.topbraidlive.sparqlmotion: Exception in SPARQLMotion Servlet (Unbound graph variable in sml:PerformUpdate) org.topbraid.spin.sparqlmotion.modules.SMException: Unbound graph variable in sml:PerformUpdate at org.topbraidlive.sparqlmotion.modules.performUpdate.PerformUpdateArgs.<init>(PerformUpdateArgs.java:52) at org.topbraidlive.sparqlmotion.modules.performUpdate.PerformUpdateModule.execute(PerformUpdateModule.java:51) at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.execute(ExecutionEngineImpl.java:203) at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.executeModule(ExecutionEngineImpl.java:169) at org.topbraid.spin.sparqlmotion.engine.impl.ExecutionEngineImpl.execute(ExecutionEngineImpl.java:119) at org.topbraidlive.sparqlmotion.servlets.sparqlmotion.SPARQLMotionServlet.run(SPARQLMotionServlet.java:342) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)tionServlet.doGet(SPARQLMotionServlet.java:249) at org.topbraid.eclipsex.servlet.TBHttpServlet.service(TBHttpServlet.java:155).java:41) at org.eclipse.equinox.http.servlet.internal.HttpServiceRuntimeImpl$LegacyServlet.service(HttpServiceRuntimeImpl.java:1221) at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62) at org.eclipse.equinox.http.servlet.internal.servlet.ProxyServlet.service(ProxyServlet.java:100)java:132) at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:152) at org.topbraidlive.servletbridge.webapplicationserver.BridgeServlet.service(BridgeServlet.java:259)eServlet.java:352) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)lterChain.java:207) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)ava:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)java:614) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)a:88) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)2) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)read$WrappingRunnable.run(TaskThread.java:61)


What did i wrong?

Overall I think you should switch from SPARQLMotion to SWP. SWP has the option to use temporary graphs as named graphs. Basically do something like

<ui:group>
    <ui:update ui:updateQuery="{!
INSERT {
    GRAPH ui:tempGraph {
        ?a ?b ?c .
    }
}
WHERE {
            {
                {
                    BIND (IRI(?selectedGraph) AS ?graphName) .
                    BIND (IRI(?nodeURI) AS ?taxUri) .
                    GRAPH ?graphName {
                        ?a (skos:broader)* ?taxUri .
                        ?a ?b ?c .
                    } .
                } .
            }
            UNION
            {
                BIND (IRI(?selectedGraph) AS ?graphName) .
                GRAPH ?graphName {
                    ?a a skos:ConceptScheme .
                    ?a ?b ?c .
                } .
            } .
} }" />
    <ui:update ui:updateQuery="{!
DELETE {
    GRAPH ui:tempGraph {
        ?a skos:hasTopConcept ?oldValue .
    } .
}
INSERT {
    GRAPH ui:tempGraph {
        ?a skos:hasTopConcept ?newValue .
    } .
}
WHERE {
    BIND (IRI(?nodeURI) AS ?newValue) .
    ?a skos:hasTopConcept ?oldValue .
} }" />
    <ui:setContext ui:queryGraph="{= ui:tempGraph }">
        <ui:return />
    </ui:setContext>
</ui:group>

This assumes that you want to produce a service that creates an output graph in Turtle serialization. For other scenarios, please describe what you need.

If you want to avoid SWP and continue with SPARQLMotion, you could try to reformulate the sml:ApplyConstruct query so that it does the replacement of the hasTopConcept triple on-the-fly, in a single query. I don't see why this wouldn't work in your case, but then I don't have the full scenario either.

HTH
Holger


--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include the TopBraid Suite family of products and its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
---
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]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Group "TopBraid 
Suite Users", the topics of which include the TopBraid Suite family of products and 
its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to [email protected]
--- 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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to