当前位置: 首页>>代码示例>>Java>>正文


Java UpdateRequest类代码示例

本文整理汇总了Java中org.apache.jena.update.UpdateRequest的典型用法代码示例。如果您正苦于以下问题:Java UpdateRequest类的具体用法?Java UpdateRequest怎么用?Java UpdateRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UpdateRequest类属于org.apache.jena.update包,在下文中一共展示了UpdateRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runSparqlUpdate

import org.apache.jena.update.UpdateRequest; //导入依赖的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.UpdateRequest; //导入依赖的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: testUpdateAction

import org.apache.jena.update.UpdateRequest; //导入依赖的package包/类
@Test
public void testUpdateAction() {
    DatasetGraph gs = getMarkLogicDatasetGraph();
    UpdateRequest update = new UpdateRequest();
    update.add("INSERT DATA { <s2> <p1> <o1> }");
    update.add("DROP ALL")
            .add("CREATE GRAPH <http://example/update1>")
            .add("BASE <http://example.org/> INSERT DATA { GRAPH <http://example.org/update2> { <s1> <p1> <o1>  } }")
            .add("BASE <http://example.org/> INSERT DATA { GRAPH <http://example.org/update3> { <s1> <p1> <o1>  } }");

    UpdateAction.execute(update, gs);

    QueryExecution askQuery = QueryExecutionFactory
            .create("BASE <http://example.org/> ASK WHERE { GRAPH <update3> { <s1> <p1> <o1>  }}",
                    DatasetFactory.wrap(gs));
    assertTrue("update action must update database.", askQuery.execAsk());

}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:19,代码来源:MarkLogicUpdatesTest.java

示例4: call

import org.apache.jena.update.UpdateRequest; //导入依赖的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: ex3

import org.apache.jena.update.UpdateRequest; //导入依赖的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

示例6: validateUpdateRequest

import org.apache.jena.update.UpdateRequest; //导入依赖的package包/类
private static Collection<IllegalArgumentException> validateUpdateRequest(final UpdateRequest request) {
    return request.getOperations().stream()
            .flatMap(x -> {
                if (x instanceof UpdateModify) {
                    final UpdateModify y = (UpdateModify) x;
                    return concat(y.getInsertQuads().stream(), y.getDeleteQuads().stream());
                } else if (x instanceof UpdateData) {
                    return ((UpdateData) x).getQuads().stream();
                } else if (x instanceof UpdateDeleteWhere) {
                    return ((UpdateDeleteWhere) x).getQuads().stream();
                } else {
                    return empty();
                }
            })
            .flatMap(FedoraResourceImpl::validateQuad)
            .filter(x -> x != null)
            .collect(Collectors.toList());
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:19,代码来源:FedoraResourceImpl.java

示例7: deleteLabelForLanguagePostCheck

import org.apache.jena.update.UpdateRequest; //导入依赖的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

示例8: deleteLabelPostCheck

import org.apache.jena.update.UpdateRequest; //导入依赖的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

示例9: runModifySparql

import org.apache.jena.update.UpdateRequest; //导入依赖的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

示例10: sendUpdateQuery

import org.apache.jena.update.UpdateRequest; //导入依赖的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

示例11: createUpdateRequest

import org.apache.jena.update.UpdateRequest; //导入依赖的package包/类
public UpdateRequest createUpdateRequest(String parsableString) {
	UpdateRequest result = string2Update.get(parsableString);
	if(result == null) {
		result = UpdateFactoryFilter.get().create(parsableString);
		if(useCaches) {
			string2Update.put(parsableString, result);
		}
	}
	return result;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:11,代码来源:ARQFactory.java

示例12: clearGraphs

import org.apache.jena.update.UpdateRequest; //导入依赖的package包/类
@After
public void clearGraphs() {
    MarkLogicDatasetGraph markLogicDatasetGraph = getMarkLogicDatasetGraph();

    UpdateAction.execute(new UpdateRequest().add("DROP SILENT ALL"),
            markLogicDatasetGraph);
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:8,代码来源:MarkLogicDatasetGraphTest.java

示例13: testUpdateTransactions

import org.apache.jena.update.UpdateRequest; //导入依赖的package包/类
@Test
public void testUpdateTransactions() {
    MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();

    UpdateRequest update = new UpdateRequest();
    update.add("BASE <http://example.org/> INSERT DATA { GRAPH <transact3> { <s4882> <p132> <o12321> } }");

    // insert a graph within a transaction, rollback
    assertFalse(dsg.isInTransaction());
    dsg.begin(ReadWrite.WRITE);
    assertTrue(dsg.isInTransaction());
    UpdateAction.execute(update, dsg);
    dsg.abort();
    assertFalse(dsg.isInTransaction());
    QueryExecution queryExec = QueryExecutionFactory
            .create("ASK WHERE { graph <http://example.org/transact3> { ?s ?p ?o }}",
                    dsg.toDataset());
    assertFalse("transact3 graph must not exist after rollback",
            queryExec.execAsk());

    dsg.begin(ReadWrite.WRITE);
    assertTrue(dsg.isInTransaction());
    UpdateAction.execute(update, dsg);
    dsg.commit();
    assertFalse(dsg.isInTransaction());

    queryExec = QueryExecutionFactory
            .create("BASE <http://example.org/>  ASK WHERE {  GRAPH <transact3> { ?s ?p ?o }}",
                    dsg.toDataset());
    assertTrue("transact3 graph must exist after commit",
            queryExec.execAsk());
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:33,代码来源:MarkLogicUpdatesTest.java

示例14: dropTransactGraph

import org.apache.jena.update.UpdateRequest; //导入依赖的package包/类
@After
public void dropTransactGraph() {
    MarkLogicDatasetGraph dsg = getMarkLogicDatasetGraph();

    UpdateRequest update = new UpdateRequest();
    update.add("BASE <http://example.org/> DROP SILENT GRAPH <transact3>")
            .add("DROP SILENT GRAPH <http://example.org/update2>")
            .add("DROP SILENT GRAPH <http://example.org/update3>")
            .add("DROP SILENT GRAPH <http://example.org/gp2>");
    UpdateAction.execute(update, dsg);
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:12,代码来源:MarkLogicUpdatesTest.java

示例15: run

import org.apache.jena.update.UpdateRequest; //导入依赖的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


注:本文中的org.apache.jena.update.UpdateRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。