本文整理汇总了Java中org.apache.jena.update.UpdateProcessor类的典型用法代码示例。如果您正苦于以下问题:Java UpdateProcessor类的具体用法?Java UpdateProcessor怎么用?Java UpdateProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UpdateProcessor类属于org.apache.jena.update包,在下文中一共展示了UpdateProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: runSparqlUpdate
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
/**
* @param sparql
* @return
*/
public boolean runSparqlUpdate(String sparql) {
if (logger.isDebugEnabled())
logger.debug("run SPARQL update: {}", sparql);
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
setCloudAuthHeaderIfConfigured(clientBuilder);
if (proxyHost != null && proxyPort != null) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
clientBuilder.setProxy(proxy);
}
try (CloseableHttpClient client = clientBuilder.build()) {
UpdateRequest update = UpdateFactory.create(sparql, Syntax.syntaxARQ);
UpdateProcessor processor = UpdateExecutionFactory.createRemoteForm(update, buildSPARQLUrl().toString(), client);
processor.execute();
} catch (IOException ioe) {
throw new RuntimeException("IOException.", ioe);
}
return true;
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:28,代码来源:OEModelEndpoint.java
示例2: generateIndividual
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
public void generateIndividual(VirtualEntity virtualEntity) {
Model model = createIndividual(new VirtualEntity());
String id = UUID.randomUUID().toString();
System.out.println(String.format("Adding %s", id));
UpdateProcessor upp = UpdateExecutionFactory.createRemote(
UpdateFactory.create(String.format(UPDATE_TEMPLATE, id)),
"http://localhost:3030/pswot/update");
upp.execute();
//Query the collection, dump output
QueryExecution qe = QueryExecutionFactory.sparqlService(
"http://localhost:3030/pswot/query",
"SELECT * WHERE {?x ?r ?y}");
ResultSet results = qe.execSelect();
ResultSetFormatter.out(System.out, results);
qe.close();
}
开发者ID:nailtonvieira,项目名称:cloudsemanticwot,代码行数:21,代码来源:DataConnectorImpl.java
示例3: setCredentials
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
private void setCredentials(UpdateProcessor exec) {
if (exec instanceof UpdateProcessRemote) {
if (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);
}
}
}
开发者ID:dice-group,项目名称:IGUANA,代码行数:17,代码来源:UPDATEWorker.java
示例4: call
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
public UpdateRun call() throws Exception {
UpdateRequest update = this.getUpdate();
logger.debug("Running update:\n" + update.toString());
// Create a remote update processor and configure it appropriately
UpdateProcessor processor = this.createUpdateProcessor(update);
this.customizeRequest(processor);
long startTime = System.nanoTime();
try {
// Execute the update
processor.execute();
} catch (HttpException e) {
// Make sure to categorize HTTP errors appropriately
logger.error("{}", FormatUtils.formatException(e));
return new UpdateRun(e.getMessage(), ErrorCategories.categorizeHttpError(e), System.nanoTime() - startTime);
}
if (this.isCancelled())
return null;
long endTime = System.nanoTime();
return new UpdateRun(endTime - startTime);
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:26,代码来源:AbstractUpdateCallable.java
示例5: runModifySparql
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
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();
}
开发者ID:iotoasis,项目名称:SDA,代码行数:9,代码来源:SparqlService.java
示例6: sendUpdateQuery
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
public boolean sendUpdateQuery(String query) {
if (query == null) {
LOGGER.error("Can not send an update query that is null. Returning false.");
return false;
}
UpdateRequest update = UpdateFactory.create(query);
UpdateProcessor up = UpdateExecutionFactory.create(update, dataset);
up.execute();
// DatasetGraph dg = up.getDatasetGraph();
// return
// ModelFactory.createModelForGraph(dg.getGraph(NodeFactory.createURI(graphUri)));
return true;
}
开发者ID:hobbit-project,项目名称:platform,代码行数:15,代码来源:ChallengePublicationTest.java
示例7: run
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
private void run() {
dsg.clear();
String insertData = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> "
+ "PREFIX : <http://example.org/> "
+"INSERT DATA {GRAPH :g1 {"
+ ":charles a foaf:Person ; "
+ " foaf:name \"Charles\" ;"
+ " foaf:knows :jim ."
+ ":jim a foaf:Person ;"
+ " foaf:name \"Jim\" ;"
+ " foaf:knows :charles ."
+ "} }";
System.out.println("Running SPARQL update");
UpdateRequest update = UpdateFactory.create(insertData);
UpdateProcessor processor = UpdateExecutionFactory.create(update, dsg);
processor.execute();
System.out.println("Examine the data as JSON-LD");
RDFDataMgr.write(System.out, dsg.getGraph(NodeFactory.createURI("http://example.org/g1")), RDFFormat.JSONLD_PRETTY);
System.out.println("Remove it.");
update = UpdateFactory.create("PREFIX : <http://example.org/> DROP GRAPH :g1");
processor = UpdateExecutionFactory.create(update, dsg);
processor.execute();
dsg.close();
}
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:31,代码来源:SPARQLUpdateExample.java
示例8: getTimeForQueryMs
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
public Long getTimeForQueryMs(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);
try {
long start = System.currentTimeMillis();
// Execute Update
exec.execute();
long end = System.currentTimeMillis();
LOGGER.debug("Worker[{{}} : {{}}]: Update with ID {{}} took {{}}.", this.workerType, this.workerID, queryID,
end - start);
// Return time
return end - start;
} 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;
}
开发者ID:dice-group,项目名称:IGUANA,代码行数:30,代码来源:UPDATEWorker.java
示例9: createUpdateProcessor
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
protected UpdateProcessor createUpdateProcessor(UpdateRequest update) {
if (this.getOptions().getEnsureAbsoluteURIs()) {
if (!update.explicitlySetBaseURI()) update.setBaseURI((String)null);
}
return UpdateExecutionFactory.create(update, this.getGraphStore(this.getOptions()));
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:8,代码来源:AbstractInMemoryUpdateCallable.java
示例10: createUpdateProcessor
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
protected UpdateProcessor createUpdateProcessor(UpdateRequest update) {
if (this.getOptions().getEnsureAbsoluteURIs()) {
if (!update.explicitlySetBaseURI()) update.setBaseURI((String)null);
}
return UpdateExecutionFactory.createRemote(update, this.getOptions().getUpdateEndpoint(), this.getOptions()
.getAuthenticator());
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:9,代码来源:AbstractRemoteUpdateCallable.java
示例11: customizeRequest
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
@Override
protected void customizeRequest(UpdateProcessor processor) {
super.customizeRequest(processor);
if (processor instanceof UpdateProcessRemoteBase)
{
UpdateProcessRemoteBase remote = (UpdateProcessRemoteBase)processor;
for (Entry<String, List<String>> nvp : this.nvps.entrySet()) {
for (String value : nvp.getValue()) {
remote.addParam(nvp.getKey(), value);
}
}
}
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:14,代码来源:NvpUpdateCallable.java
示例12: runModifySparql
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
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("sparql of "+dest+" in runModifySparql ===> "+madeQl);
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()); // HTTP 500 error making the query: java.lang.StackOverflowError or...
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")
// || ee.getMessage().contains("500 - Server Error") || ee.getMessage().contains("HTTP 500 error")
) {
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 madeQl = makeFinal(sparql, idxVals);
String updateService2 = Utils.getSdaProperty("com.pineone.icbms.sda.knowledgebase.dm.sparql.endpoint") + "/update";
UpdateRequest ur2 = UpdateFactory.create(madeQl);
//log.debug("sparql of "+dest+" in runModifySparql ===> "+madeQl2);
//log.debug("madeQl2 ============>"+ madeQl2);
//log.debug("query ============>"+ ur2.toString());
UpdateProcessor up2 = UpdateExecutionFactory.createRemote(ur2, updateService2);
up2.execute();
log.debug("runModifySparql() on DataMart server end.................................. ");
}
}
开发者ID:iotoasis,项目名称:SDA,代码行数:76,代码来源:SparqlFusekiQueryImpl.java
示例13: execUpdate
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
public static void execUpdate(String sparqlUpdateString, GraphStore graphStore)
{
UpdateRequest request = UpdateFactory.create(sparqlUpdateString) ;
UpdateProcessor proc = UpdateExecutionFactory.create(request, graphStore) ;
proc.execute() ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:7,代码来源:ExTDB_Txn2.java
示例14: customizeRequest
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
/**
* Provides derived implementations the option to customize the update
* processor before actually executing the update e.g. to add custom
* parameters
* <p>
* The default implementation does nothing.
* </p>
*
* @param processor
* Update processor
*/
protected void customizeRequest(UpdateProcessor processor) {
// Default implementation does nothing
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:15,代码来源:AbstractUpdateCallable.java
示例15: createUpdateProcessor
import org.apache.jena.update.UpdateProcessor; //导入依赖的package包/类
/**
* Creates an update processor for running the update
*
* @param update
* Update
*
* @return Update processor
*/
protected abstract UpdateProcessor createUpdateProcessor(UpdateRequest update);
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:10,代码来源:AbstractUpdateCallable.java
注:本文中的org.apache.jena.update.UpdateProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论