本文整理汇总了Java中org.apache.jena.update.UpdateFactory类的典型用法代码示例。如果您正苦于以下问题:Java UpdateFactory类的具体用法?Java UpdateFactory怎么用?Java UpdateFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UpdateFactory类属于org.apache.jena.update包,在下文中一共展示了UpdateFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: runSparqlUpdate
import org.apache.jena.update.UpdateFactory; //导入依赖的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: main2
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
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()
.setPort(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);
}
开发者ID:afs,项目名称:rdf-delta,代码行数:25,代码来源:DeltaEx3_FusekiLogChanges.java
示例3: generateIndividual
import org.apache.jena.update.UpdateFactory; //导入依赖的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
示例4: ex3
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
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) ;
}
开发者ID:xcurator,项目名称:xcurator,代码行数:23,代码来源:UpdateExecuteOperations.java
示例5: deleteLabelForLanguagePostCheck
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
private void deleteLabelForLanguagePostCheck(Label label) {
String sparql = "DELETE { ?conceptSchemeURI rdfs:label ?labelValue } WHERE { ?conceptSchemeURI rdfs:label ?labelValue . FILTER(STRLANG(?label) = STR(?labelLanguage)) }";
ParameterizedSparqlString parameterizedSparql = new ParameterizedSparqlString(model);
parameterizedSparql.setCommandText(sparql);
parameterizedSparql.setParam("conceptSchemeURI", resource);
parameterizedSparql.setParam("labelLanguage", model.createLiteral(label.getValue(), label.getLanguageCode()));
UpdateRequest updateRequest = UpdateFactory.create(parameterizedSparql.getCommandText());
UpdateAction.execute(updateRequest, model);
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:11,代码来源:Concept.java
示例6: deleteLabelPostCheck
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
private void deleteLabelPostCheck(Label label) {
String sparql = "DELETE { ?conceptSchemeURI rdfs:label ?labelValue } WHERE { }";
ParameterizedSparqlString parameterizedSparql = new ParameterizedSparqlString(model);
parameterizedSparql.setCommandText(sparql);
parameterizedSparql.setParam("conceptSchemeURI", resource);
parameterizedSparql.setParam("labelLanguage", model.createLiteral(label.getValue(), label.getLanguageCode()));
UpdateRequest updateRequest = UpdateFactory.create(parameterizedSparql.getCommandText());
UpdateAction.execute(updateRequest, model);
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:11,代码来源:Concept.java
示例7: runModifySparql
import org.apache.jena.update.UpdateFactory; //导入依赖的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
示例8: sendUpdateQuery
import org.apache.jena.update.UpdateFactory; //导入依赖的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
示例9: run
import org.apache.jena.update.UpdateFactory; //导入依赖的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
示例10: getTimeForQueryMs
import org.apache.jena.update.UpdateFactory; //导入依赖的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
示例11: runModifySparql
import org.apache.jena.update.UpdateFactory; //导入依赖的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
示例12: create
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
public UpdateRequest create(String str) {
analyzeRequest(str);
return UpdateFactory.create(str, Syntax.syntaxARQ);
}
开发者ID:TopQuadrant,项目名称:shacl,代码行数:5,代码来源:UpdateFactoryFilter.java
示例13: execUpdate
import org.apache.jena.update.UpdateFactory; //导入依赖的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: InMemoryFixedUpdateOperation
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
/**
* Creates a new update operation
*
* @param name
* Name
* @param updateString
* SPARQL Update
*/
public InMemoryFixedUpdateOperation(String name, String updateString) {
super(name);
this.origUpdateStr = updateString;
this.update = UpdateFactory.create(updateString);
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:14,代码来源:InMemoryFixedUpdateOperation.java
示例15: FixedUpdateOperation
import org.apache.jena.update.UpdateFactory; //导入依赖的package包/类
/**
* Creates a new update operation
*
* @param name
* Name
* @param updateString
* SPARQL Update
*/
public FixedUpdateOperation(String name, String updateString) {
super(name);
this.origUpdateStr = updateString;
this.update = UpdateFactory.create(updateString);
}
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:14,代码来源:FixedUpdateOperation.java
注:本文中的org.apache.jena.update.UpdateFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论