• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UpdateFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: executeUpdateQuerySparqlEndpoint

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
/**
 * It executes an UPDATE SPARQL query on the SPARQL endpoint.
 *
 * @param sparqlEndpointURI		the SPARQL endpoint URI.  
 * @param user					the user name for the SPARQl endpoint.
 * @param password				the password for the SPARQl endpoint.
 * @param query					the UPDATE query to execute.
 * @return true if the SPARQL has been executed. False otherwise.
 * @since 1.0
 */
public boolean executeUpdateQuerySparqlEndpoint(final String sparqlEndpointURI, final String user, final String password, final String query) {
	boolean done = false;
	try {
		UpdateExecutionFactory.createRemoteForm(
				UpdateFactory.create(query), 
				sparqlEndpointURI, 
				context(),
				auth(sparqlEndpointURI, user, password))
			.execute();
		done = true;
	} catch (Exception exception) {
		LOGGER.error(MessageCatalog._00035_SPARQL_FAILED, exception, query);
	}
	return done;
}
 
开发者ID:ALIADA,项目名称:aliada-tool,代码行数:26,代码来源:RDFStoreDAO.java


示例2: executeUpdate

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
/**
 * Executes a given update command both on remote and local model.
 * 
 * @param data the object holding test data (i.e. commands, queries, datafiles).
 * @throws Exception hopefully never otherwise the corresponding test fails.
 */
protected void executeUpdate(final MisteryGuest data) throws Exception {
	load(data);
	
	final String updateCommandString = readFile(data.query);
	UpdateExecutionFactory.createRemote(UpdateFactory.create(updateCommandString), SPARQL_ENDPOINT_URI).execute();

	SOLRDF_CLIENT.commit();

	UpdateAction.parseExecute(updateCommandString, memoryDataset.asDatasetGraph());
	
	final Iterator<Node> nodes = memoryDataset.asDatasetGraph().listGraphNodes();
	if (nodes != null) {
		while (nodes.hasNext()) {
			final Node graphNode = nodes.next();
			final String graphUri = graphNode.getURI();
			final Model inMemoryNamedModel = memoryDataset.getNamedModel(graphUri);
			assertIsomorphic(inMemoryNamedModel, SOLRDF_CLIENT.getNamedModel(graphUri), graphUri);		
		}
	}
	
	assertIsomorphic(memoryDataset.getDefaultModel(), SOLRDF_CLIENT.getDefaultModel(), null);			
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:29,代码来源:IntegrationTestSupertypeLayer.java


示例3: save

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
public void save(Observation o) {
    cache.add(o);
    batchSize++;

    if (batchSize >= CONFIG.sparqlMaxBatchSize()) {
        try {
            logger.debug("Flushing the cache...");
            UpdateRequest request = UpdateFactory.create(modelToQuery(cache));
            UpdateExecutionFactory.createRemote(
                    request, endpoint, authenticator).execute();
            batchSize = 0;
            cache.clear();
        } catch (IOException ex) {
            logger.warn(ex.getMessage(), ex);
        }
    }
}
 
开发者ID:ailabitmo,项目名称:DAAFSE,代码行数:18,代码来源:Store.java


示例4: entailSKOSModel

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
private void entailSKOSModel() {
  GraphStore graphStore = GraphStoreFactory.create(skosModel) ;
  String sparqlQuery = StringUtils.join(new String[]{
      "PREFIX skos: <http://www.w3.org/2004/02/skos/core#>",
      "PREFIX skos-ehri: <http://data.ehri-project.eu/skos-extension#>",
      "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
      "INSERT { ?subject rdf:type skos:Concept }",
      "WHERE {",
        "{ ?subject skos:prefLabel ?text } UNION",
        "{ ?subject skos:altLabel ?text } UNION",
        "{ ?subject skos-ehri:prefMaleLabel ?text } UNION",
        "{ ?subject skos-ehri:prefFemaleLabel ?text } UNION",
        "{ ?subject skos-ehri:prefNeuterLabel ?text } UNION",
        "{ ?subject skos-ehri:altMaleLabel ?text } UNION",
        "{ ?subject skos-ehri:altFemaleLabel ?text } UNION",
        "{ ?subject skos-ehri:altNeuterLabel ?text } UNION",
        "{ ?subject skos:hiddenLabel ?text }",
       "}",
      }, "\n");
  UpdateRequest request = UpdateFactory.create(sparqlQuery);
  UpdateAction.execute(request, graphStore) ;
}
 
开发者ID:KepaJRodriguez,项目名称:lucene-skos-ehri,代码行数:23,代码来源:SKOSEngineImpl.java


示例5: executeInsert

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
/**
 * It executes an INSERT SPARQL query on the SPARQL endpoint.
 *
 * @param sparqlEndpointURI		the SPARQL endpoint URI.  
 * @param user					the user name for the SPARQl endpoint.
 * @param password				the password for the SPARQl endpoint.
 * @param triples				the triples that will be added.
 * throws Exception in case the INSERT goes wrong.
 * @since 1.0
 */
public void executeInsert(
		final String sparqlEndpointURI, 
		final String graphName, 
		final String user, 
		final String password, 
		final String triples) throws Exception {
	UpdateExecutionFactory.createRemoteForm(
			UpdateFactory.create(buildInsertQuery(graphName, triples)), 
			sparqlEndpointURI, 
			context(),
			auth(sparqlEndpointURI, user, password))
		.execute();
}
 
开发者ID:ALIADA,项目名称:aliada-tool,代码行数:24,代码来源:RDFStoreDAO.java


示例6: executeDelete

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
/**
 * It executes an DELETE SPARQL query on the SPARQL endpoint.
 *
 * @param sparqlEndpointURI		the SPARQL endpoint URI.  
 * @param graphName the graphName, null in case of default graph.
 * @param user					the user name for the SPARQl endpoint.
 * @param password				the password for the SPARQl endpoint.
 * @param triples				the triples that will be removed.
 * throws Exception in case the DELETE goes wrong.
 * @since 2.0
 */
public void executeDelete(
		final String sparqlEndpointURI, 
		final String graphName, 
		final String user, 
		final String password, 
		final String triples) throws Exception {
	UpdateExecutionFactory.createRemoteForm(
			UpdateFactory.create(buildDeleteQuery(graphName, triples)), 
			sparqlEndpointURI, 
			context(),
			auth(sparqlEndpointURI, user, password))
		.execute();
}
 
开发者ID:ALIADA,项目名称:aliada-tool,代码行数:25,代码来源:RDFStoreDAO.java


示例7: updateDataset

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
private void updateDataset(String updateString, HttpServletRequest request, HttpServletResponse response) 
		throws IOException {
	Config config = new Config(request);
	Dataset tdbstore = TDBFactory.createDataset(config.getTripleStoreDir());
	UpdateRequest update = UpdateFactory.create(updateString);
	UpdateAction.execute(update, tdbstore);
	out.print("Updated");
	TDB.sync(tdbstore);
}
 
开发者ID:IKCAP,项目名称:turbosoft,代码行数:10,代码来源:SparqlEndpoint.java


示例8: clearAll

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
public void clearAll() {
    UpdateRequest request = null;
    if (CONFIG.sparqlVendor().equalsIgnoreCase(PublisherConfig.VIRTUOSO)) {
        Query select = QueryFactory.create(
                "SELECT DISTINCT ?g { GRAPH ?g {?x ?y ?z}"
                + "FILTER(strStarts(str(?g), \"" + Observation.METERS + "\"))}");
        ResultSet result = QueryExecutionFactory.createServiceRequest(
                endpoint, select, authenticator).execSelect();
        StringBuilder cleanQuery = new StringBuilder();
        int count = 0;
        while (result.hasNext()) {
            String graphUri = result.next().getResource("g").getURI();
            cleanQuery.append("CLEAR GRAPH <").append(graphUri).append("> ;\n");
            if (++count > 4) {
                request = UpdateFactory.create(cleanQuery.toString());
                UpdateExecutionFactory.createRemote(
                        request, endpoint, authenticator).execute();
                count = 0;
                cleanQuery = new StringBuilder();
            }
            if (count > 0) {
                request = UpdateFactory.create(cleanQuery.toString());
                UpdateExecutionFactory.createRemote(
                        request, endpoint, authenticator).execute();
            }
        }
    } else {
        request = UpdateFactory.create("CLEAR ALL");
        UpdateExecutionFactory.createRemote(
                request, endpoint, authenticator).execute();
    }
}
 
开发者ID:ailabitmo,项目名称:DAAFSE,代码行数:33,代码来源:Store.java


示例9: main

import com.hp.hpl.jena.update.UpdateFactory; //导入依赖的package包/类
public static void main(String [] args)
{
	// Set up the ModelD2RQ using a mapping file
	String workingDir = System.getProperty("user.dir");		
	String propFile = workingDir + "/mapping-iswc2.ttl";
	
	String pckg = "de.fuberlin.wiwiss.d2rq.";
	Logger rdqlLogger = Logger.getLogger(pckg + "RDQL");
	
	org.apache.log4j.BasicConfigurator.configure();
	
	rdqlLogger.setLevel(Level.DEBUG);

	Model m = new de.fuberlin.wiwiss.d2rq.ModelD2RQ("file:" + propFile);
	
	String sparql = "CONSTRUCT {?s ?p ?o.} WHERE {?s ?p ?o.}";
	Query q = QueryFactory.create(sparql); 
	//ResultSet rs = QueryExecutionFactory.create(q, m).execSelect();
	Model m2 = QueryExecutionFactory.create(q, m).execConstruct();
	/*while (rs.hasNext()) {
	    QuerySolution row = rs.nextSolution();
	    System.out.println("Got here ");
	    //System.out.println(row.)
	};*/
	StmtIterator stmti = m2.listStatements();
	while(stmti.hasNext())
	{
		Statement stmt = stmti.next();
		System.out.println(stmt.getSubject()+ "<<>>" + stmt.getPredicate() + "<<>>" + stmt.getObject());
	}
	
	//String sparql = "SELECT ?s ?p ?o WHERE {?s <http://annotation.semanticweb.org/iswc/iswc.daml#FirstName> \"Yolanda\"^^<http://www.w3.org/2001/XMLSchema#string>}";
	//String sparql = "SELECT ?s ?p ?o WHERE {?s <http://annotation.semanticweb.org/iswc/iswc.daml#phone> ?o}";
	/*Query q2 = QueryFactory.create(sparql); 
	ResultSet rs = QueryExecutionFactory.create(q2, m).execSelect();
	while (rs.hasNext()) {
	    QuerySolution row = rs.nextSolution();
	    
	    System.out.println("-->" + row.get("s") + "<<>>" + row.get("p") + "<<>>" +row.get("o"));
	    
	    //System.out.println("Title: " + row.getLiteral("paperTitle").getString());
	    //System.out.println("Author: " + row.getLiteral("authorName").getString());
	};*/
	
	// Trying sparql insert
	System.out.println("Trying insert ");
	
	Model m3 = new ModelD2RQUpdate("file:" + propFile);

	
	String sparql2 = "DELETE {?person <http://annotation.semanticweb.org/iswc/iswc.daml#phone> \"666\"^^<http://www.w3.org/2001/XMLSchema#string>} WHERE { ?person <http://annotation.semanticweb.org/iswc/iswc.daml#FirstName> \"Yolanda\"^^<http://www.w3.org/2001/XMLSchema#string>}";
	String sparql4 = "INSERT {<http://conferences.org/comp/confno#90> <http://annotation.semanticweb.org/iswc/iswc.daml#phone> \"666\"^^<http://www.w3.org/2001/XMLSchema#string>}";
	String sparql3 = "MODIFY DELETE " + "{?person <http://annotation.semanticweb.org/iswc/iswc.daml#phone> \"666\"^^<http://www.w3.org/2001/XMLSchema#string>}" +
		"INSERT { ?person <http://annotation.semanticweb.org/iswc/iswc.daml#phone> \"667\"^^<http://www.w3.org/2001/XMLSchema#string> }" + 
		"WHERE { ?person <http://annotation.semanticweb.org/iswc/iswc.daml#FirstName> \"Varun\"^^<http://www.w3.org/2001/XMLSchema#string>}";
	
	UpdateRequest u = UpdateFactory.create(sparql4);
	UpdateAction.execute(u, m2);
	System.out.println("Done Inserts ");
	
	m2.close();
	m.close();
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:64,代码来源:D2RQTester.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DbManager类代码示例发布时间:2022-05-22
下一篇:
Java MethodSignature类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap