本文整理汇总了Java中org.apache.jena.update.UpdateFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateFactory.create方法的具体用法?Java UpdateFactory.create怎么用?Java UpdateFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.update.UpdateFactory
的用法示例。
在下文中一共展示了UpdateFactory.create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例3: 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) ;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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();
}
示例7: 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;
}
示例8: 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();
}
示例9: 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;
}
示例10: 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.................................. ");
}
}
示例11: create
import org.apache.jena.update.UpdateFactory; //导入方法依赖的package包/类
public UpdateRequest create(String str) {
analyzeRequest(str);
return UpdateFactory.create(str, Syntax.syntaxARQ);
}
示例12: 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() ;
}
示例13: 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);
}
示例14: 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);
}