org.apache.jena.update.UpdateProcessor Java Examples
The following examples show how to use
org.apache.jena.update.UpdateProcessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UPDATEWorker.java From IGUANA with GNU Affero General Public License v3.0 | 6 votes |
private void setCredentials(UpdateProcessor exec) { if (exec instanceof UpdateProcessRemote && user != null && !user.isEmpty() && password != null && !password.isEmpty()) { CredentialsProvider provider = new BasicCredentialsProvider(); provider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(user, password)); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(HttpClientContext.CREDS_PROVIDER, provider); ((UpdateProcessRemote) exec).setHttpContext(httpContext); HttpClient test = ((UpdateProcessRemote) exec).getClient(); System.out.println(test); } }
Example #2
Source File: SparqlService.java From SDA with BSD 2-Clause "Simplified" License | 5 votes |
private void runModifySparql(String sparql, String[] idxVals) throws Exception { String updateService = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.sparql.endpoint") + "/update"; String madeQl = makeSparql(sparql, idxVals); UpdateRequest ur = UpdateFactory.create(madeQl); UpdateProcessor up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); }
Example #3
Source File: SparqlService.java From SDA with BSD 2-Clause "Simplified" License | 5 votes |
private void runModifySparql(String sparql, String[] idxVals) throws Exception { String updateService = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.sparql.endpoint") + "/update"; String madeQl = makeSparql(sparql, idxVals); UpdateRequest ur = UpdateFactory.create(madeQl); UpdateProcessor up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); }
Example #4
Source File: UPDATEWorker.java From IGUANA with GNU Affero General Public License v3.0 | 5 votes |
@Override public void executeQuery(String query, String queryID) { UpdateRequest update = UpdateFactory.create(query); // Set update timeout RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(this.timeOut.intValue()) .setConnectTimeout(this.timeOut.intValue()).setSocketTimeout(this.timeOut.intValue()).build(); CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build(); // create Update Processor and use timeout config UpdateProcessor exec = UpdateExecutionFactory.createRemote(update, service, client); setCredentials(exec); Instant start = Instant.now(); try { // Execute Update exec.execute(); double duration = durationInMilliseconds(start, Instant.now()); LOGGER.debug("Worker[{{}} : {{}}]: Update with ID {{}} took {{}}.", this.workerType, this.workerID, queryID, duration); // Return time super.addResults(new QueryExecutionStats(queryID, COMMON.QUERY_SUCCESS, duration)); return; } catch (Exception e) { LOGGER.warn("Worker[{{}} : {{}}]: Could not execute the following update\n{{}}\n due to", this.workerType, this.workerID, query, e); } // Exception was thrown, return error //return -1L; super.addResults(new QueryExecutionStats(queryID, COMMON.QUERY_UNKNOWN_EXCEPTION, durationInMilliseconds(start, Instant.now()))); }
Example #5
Source File: SparqlFusekiQueryImpl.java From SDA with BSD 2-Clause "Simplified" License | 4 votes |
/** * update쿼리수행(sparql만 해당됨) * @param sparql * @param idxVals * @param dest * @throws Exception * @return void */ public void runModifySparql(String sparql, String[] idxVals, String dest) throws Exception { String madeQl = makeFinal(sparql, idxVals); if(dest.equals("ALL") || dest.equals("DW")) { String updateService = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.dw.sparql.endpoint") + "/update"; //String madeQl = makeFinal(sparql, idxVals); UpdateRequest ur = UpdateFactory.create(madeQl); UpdateProcessor up; log.debug("runModifySparql() on DatWarehouse server start.................................. "); try { log.debug("try (first).................................. "); up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); } catch (Exception e) { int waitTime = 15*1000; log.debug("Exception message in runModifySparql() =====> "+e.getMessage()); try { // 일정시간 대기 했다가 다시 수행함 log.debug("sleeping.(first).................................. in "+waitTime); Thread.sleep(waitTime); log.debug("try (second).................................. "); up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); } catch (Exception ee) { log.debug("Exception 1====>"+ee.getMessage()); waitTime = 30*1000; if(ee.getMessage().contains("Service Unavailable") || ee.getMessage().contains("java.net.ConnectException") ) { try { // restart fuseki Utils.restartFuseki(); // 일정시간을 대기 한다. log.debug("sleeping (final)................................. in "+waitTime); Thread.sleep(waitTime); // 마지막으로 다시한번 시도한다. log.debug("try (final).................................. "); up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); } catch (Exception eee) { log.debug("Exception 2====>"+eee.getMessage()); throw eee; } } throw ee; } // 두번째 try } // 첫번째 try log.debug("runModifySparql() on DataWarehouse server end.................................. "); } if(dest.equals("ALL") || dest.equals("DM")) { //동일한(delete or insert) sparql를 DM서버에도 수행함(최근값 혹은 추론결과, subscription값등을 등록한다.) log.debug("runModifySparql() on DataMart server start.................................. "); String updateService2 = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.dm.sparql.endpoint") + "/update"; UpdateRequest ur2 = UpdateFactory.create(madeQl); UpdateProcessor up2 = UpdateExecutionFactory.createRemote(ur2, updateService2); up2.execute(); log.debug("runModifySparql() on DataMart server end.................................. "); } }
Example #6
Source File: SparqlFusekiQueryImpl.java From SDA with BSD 2-Clause "Simplified" License | 4 votes |
/** * update쿼리수행(sparql만 해당됨) * @param sparql * @param idxVals * @param dest * @throws Exception * @return void */ public void runModifySparql(String sparql, String[] idxVals, String dest) throws Exception { String madeQl = makeFinal(sparql, idxVals); if(dest.equals("ALL") || dest.equals("DW")) { String updateService = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.dw.sparql.endpoint") + "/update"; //String madeQl = makeFinal(sparql, idxVals); UpdateRequest ur = UpdateFactory.create(madeQl); UpdateProcessor up; log.debug("runModifySparql() on DatWarehouse server start.................................. "); try { log.debug("try (first).................................. "); up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); } catch (Exception e) { int waitTime = 15*1000; log.debug("Exception message in runModifySparql() =====> "+e.getMessage()); try { // 일정시간 대기 했다가 다시 수행함 log.debug("sleeping.(first).................................. in "+waitTime); Thread.sleep(waitTime); log.debug("try (second).................................. "); up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); } catch (Exception ee) { log.debug("Exception 1====>"+ee.getMessage()); waitTime = 30*1000; if(ee.getMessage().contains("Service Unavailable") || ee.getMessage().contains("java.net.ConnectException") ) { try { // restart fuseki Utils.restartFuseki(); // 일정시간을 대기 한다. log.debug("sleeping (final)................................. in "+waitTime); Thread.sleep(waitTime); // 마지막으로 다시한번 시도한다. log.debug("try (final).................................. "); up = UpdateExecutionFactory.createRemote(ur, updateService); up.execute(); } catch (Exception eee) { log.debug("Exception 2====>"+eee.getMessage()); throw eee; } } throw ee; } // 두번째 try } // 첫번째 try log.debug("runModifySparql() on DataWarehouse server end.................................. "); } if(dest.equals("ALL") || dest.equals("DM")) { //동일한(delete or insert) sparql를 DM서버에도 수행함(최근값 혹은 추론결과, subscription값등을 등록한다.) log.debug("runModifySparql() on DataMart server start.................................. "); String updateService2 = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.dm.sparql.endpoint") + "/update"; UpdateRequest ur2 = UpdateFactory.create(madeQl); UpdateProcessor up2 = UpdateExecutionFactory.createRemote(ur2, updateService2); up2.execute(); log.debug("runModifySparql() on DataMart server end.................................. "); } }
Example #7
Source File: ExTDB_Txn2.java From xcurator with Apache License 2.0 | 4 votes |
public static void execUpdate(String sparqlUpdateString, GraphStore graphStore) { UpdateRequest request = UpdateFactory.create(sparqlUpdateString) ; UpdateProcessor proc = UpdateExecutionFactory.create(request, graphStore) ; proc.execute() ; }