Java Code Examples for org.apache.jena.update.UpdateFactory#create()
The following examples show how to use
org.apache.jena.update.UpdateFactory#create() .
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: DeltaEx03_FusekiLogChanges.java From rdf-delta with Apache License 2.0 | 6 votes |
public static void main2(String ...args) { int PORT = 2020; DatasetGraph dsgBase = DatasetGraphFactory.createTxnMem(); RDFChanges changeLog = RDFPatchOps.textWriter(System.out); DatasetGraph dsg = RDFPatchOps.changes(dsgBase, changeLog); // Create a server with the changes-enables dataset. // Plain server. No other registration necessary. FusekiServer server = FusekiServer.create() .port(PORT) .add("/ds", dsg) .build(); server.start(); RDFConnection conn = RDFConnectionFactory.connect("http://localhost:"+PORT+"/ds"); UpdateRequest update = UpdateFactory.create("PREFIX : <http://example/> INSERT DATA { :s :p 123 }"); // Note - no prefix in changes. The SPARQL Update prefix is not a chnage to the dataset prefixes. conn.update(update); server.stop(); // // Server in the background so explicitly exit. // System.exit(0); }
Example 2
Source File: UpdateExecuteOperations.java From xcurator with Apache License 2.0 | 6 votes |
public static void ex3(Dataset dataset) { // Build up the request then execute it. // This is the preferred way for complex sequences of operations. UpdateRequest request = UpdateFactory.create() ; request.add("DROP ALL") .add("CREATE GRAPH <http://example/g2>") ; // Different style. // Equivalent to request.add("...") UpdateFactory.parse(request, "LOAD <file:etc/update-data.ttl> INTO GRAPH <http://example/g2>") ; // And perform the operations. UpdateAction.execute(request, dataset) ; System.out.println("# Debug format"); SSE.write(dataset) ; System.out.println(); System.out.println("# N-Quads: S P O G") ; RDFDataMgr.write(System.out, dataset, Lang.NQUADS) ; }
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: 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 5
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 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: 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 8
Source File: UpdateFactoryFilter.java From shacl with Apache License 2.0 | 4 votes |
public UpdateRequest create(String str) { analyzeRequest(str); return UpdateFactory.create(str, Syntax.syntaxARQ); }
Example 9
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() ; }