public SparqlStmtUpdate(UpdateRequest updateRequest) { this(updateRequest, updateRequest.toString()); }
private void test(UpdateRequest update1, UpdateRequest update2, boolean isomorphic) { boolean b = UpdateCompare.isomorphic(update1, update2) ; assertEquals(update1.toString(), b, isomorphic) ; } }
/** * POSTs update to a remote SPARQL endpoint. * * @param updateRequest post request * @param params name/value pairs of request parameters or null, if none * @param headers request headers * @return client response */ public ClientResponse post(UpdateRequest updateRequest, MultivaluedMap<String, String> params, MultivaluedMap<String, String> headers) { if (log.isDebugEnabled()) log.debug("Remote service {} Query: {} ", getWebResource().getURI(), updateRequest); if (updateRequest == null) throw new IllegalArgumentException("UpdateRequest must be not null"); MultivaluedMap formData = new MultivaluedMapImpl(); if (params != null) formData.putAll(params); formData.putSingle("update", updateRequest.toString()); WebResource.Builder builder = getWebResource().type(MediaType.APPLICATION_FORM_URLENCODED_TYPE); if (headers != null) return setHeaders(builder, headers).post(ClientResponse.class, formData); return builder.post(ClientResponse.class, formData); }
private void testUpdate(String input, String output, String varStr, String valStr) { UpdateRequest req1 = UpdateFactory.create(PREFIX+input) ; UpdateRequest reqExpected = UpdateFactory.create(PREFIX+output) ; Map<Var, Node> map = new HashMap<>() ; map.put(Var.alloc(varStr), SSE.parseNode(valStr)) ; UpdateRequest reqTrans = UpdateTransformOps.transform(req1, map) ; // Crude. String x1 = reqExpected.toString().replaceAll("[ \n\t]", "") ; String x2 = reqTrans.toString().replaceAll("[ \n\t]", "") ; //assertEquals(reqExpected, reqTrans) ; assertEquals(x1, x2) ; }
private void updateExec(UpdateRequest update, String updateString ) { checkUpdate(); if ( update == null && updateString == null ) throw new InternalErrorException("Both update request and update string are null"); if ( update == null ) { if ( parseCheckUpdates ) UpdateFactory.create(updateString); } // Use the update string as provided if possible, otherwise serialize the update. String updateStringToSend = ( updateString != null ) ? updateString : update.toString(); exec(()->HttpOp.execHttpPost(svcUpdate, WebContent.contentTypeSPARQLUpdate, updateStringToSend, this.httpClient, this.httpContext)); }
private void updateExec(UpdateRequest update, String updateString ) { checkUpdate(); if ( update == null && updateString == null ) throw new InternalErrorException("Both update request and update string are null"); if ( update == null ) { if ( parseCheckUpdates ) UpdateFactory.create(updateString); } // Use the update string as provided if possible, otherwise serialize the update. String updateStringToSend = ( updateString != null ) ? updateString : update.toString(); exec(()->HttpOp.execHttpPost(svcUpdate, WebContent.contentTypeSPARQLUpdate, updateStringToSend, this.httpClient, this.httpContext)); }
private void testUpdateModel(String input, String output, String varStr, String valStr) { UpdateRequest req1 = UpdateFactory.create(PREFIX+input) ; UpdateRequest reqExpected = UpdateFactory.create(PREFIX+output) ; Map<String, RDFNode> map = new HashMap<>() ; Node n = SSE.parseNode(valStr); RDFNode x = ModelUtils.convertGraphNodeToRDFNode(n); map.put(varStr, x); UpdateRequest reqTrans = UpdateTransformOps.transformUpdate(req1, map) ; // Crude. String x1 = reqExpected.toString().replaceAll("[ \n\t]", "") ; String x2 = reqTrans.toString().replaceAll("[ \n\t]", "") ; //assertEquals(reqExpected, reqTrans) ; assertEquals(x1, x2) ; } }
@Override public void execute() { // Validation if ( this.getEndpoint() == null ) throw new ARQException("Null endpoint for remote update") ; if ( this.getUpdateRequest() == null ) throw new ARQException("Null update request for remote update") ; // Build endpoint URL String endpoint = this.getEndpoint(); String querystring = this.getUpdateString(); if (querystring != null && !querystring.equals("")) { endpoint = endpoint.contains("?") ? endpoint + "&" + querystring : endpoint + "?" + querystring; } // Execution String reqStr = this.getUpdateRequest().toString() ; HttpOp.execHttpPost(endpoint, WebContent.contentTypeSPARQLUpdate, reqStr, getClient(), getHttpContext()) ; } }
@Override public void execute() { // Validation if (this.getEndpoint() == null) throw new ARQException("Null endpoint for remote update by form"); if (this.getUpdateRequest() == null) throw new ARQException("Null update request for remote update"); // Execution String reqStr = this.getUpdateRequest().toString(); Params ps = new Params(this.getParams()); ps.addParam(HttpParams.pUpdate, reqStr); execHttpPostForm(this.getEndpoint(), ps, null, HttpResponseLib.nullResponse, getClient(), getHttpContext()); } }