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


Java UpdateAction.execute方法代码示例

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


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

示例1: entailSKOSModel

import com.hp.hpl.jena.update.UpdateAction; //导入方法依赖的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

示例2: transform

import com.hp.hpl.jena.update.UpdateAction; //导入方法依赖的package包/类
public long transform(String tfilename, Map<String,String> parameter){
    File tfile = new File(System.getProperty("user.dir")+"/sparql/transformations/"+tfilename);
    String transformation = "";
    try {
        List<String> lines = Files.readAllLines(tfile.toPath());
        for(String line : lines){
            transformation+=line+"\n";
        }
    } catch (IOException ex) {
        System.err.println("Exception transforming:"+tfilename);;
    }
    dataset.begin(ReadWrite.WRITE);
    Graph graph = dataset.asDatasetGraph().getDefaultGraph();
    long size = graph.size();
    ParameterizedSparqlString pss = new ParameterizedSparqlString();
    pss.setCommandText(transformation);
    for(String key: parameter.keySet()){
        String query = pss.asUpdate().toString();
        if(!parameter.get(key).contains("http://")){
            pss.setLiteral(key, parameter.get(key).trim());
        }else{
            pss.setIri(key, parameter.get(key).trim());
        }
        if(query.equals(pss.asUpdate().toString())) {
            JOptionPane.showMessageDialog(null,"Querynames are flawed. This should not happen.");
            System.err.println(pss.toString());
            return 0;
        }
    }
    UpdateAction.execute(pss.asUpdate(), graph);
    size = graph.size() - size;
    dataset.commit();
    return size;
}
 
开发者ID:MarcelH91,项目名称:WikiOnto,代码行数:35,代码来源:TransformationProcessor.java

示例3: rdfAnalysisProvider

import com.hp.hpl.jena.update.UpdateAction; //导入方法依赖的package包/类
@Override
public RDFAnalysisProvider rdfAnalysisProvider() {
	return new RDFAnalysisProvider() {
		private static final String DETECTED_LANGUAGE_INSERT_SPARQL = "/org/openimaj/tools/twiiter/rdf/detected_language_insert.sparql";
		private String query;

		@Override
		public void addAnalysis(Model m, Resource socialEvent, GeneralJSON analysisSource) {
			final Map<String, Object> analysis = analysisSource.getAnalysis(LANGUAGES);
			if (analysis == null)
				return;

			final ParameterizedSparqlString pss = new ParameterizedSparqlString(query); // wasteful?
																						// makes
																						// it
																						// threadsafe
																						// but
																						// is
																						// it
																						// bad?
			pss.setParam("socialEvent", socialEvent);
			final Resource langNode = m.createResource();
			pss.setParam("langid", langNode);
			pss.setLiteral("language", analysis.get("language").toString());
			pss.setLiteral("confidence", (Double) analysis.get("confidence"));
			UpdateAction.execute(pss.asUpdate(), m);
		}

		@Override
		public void init() {
			try {
				query = FileUtils.readall(GeneralJSONRDF.class.getResourceAsStream(DETECTED_LANGUAGE_INSERT_SPARQL));
			} catch (final IOException e) {
				throw new RuntimeException(e);
			}

		}
	};
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:40,代码来源:LanguageDetectionMode.java

示例4: updateDataset

import com.hp.hpl.jena.update.UpdateAction; //导入方法依赖的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

示例5: cleanupModel

import com.hp.hpl.jena.update.UpdateAction; //导入方法依赖的package包/类
private void cleanupModel() {
	final UpdateRequest del = PQUtils.constructPQ(readQuery(DELETE_TM_NULL), m).asUpdate();
	UpdateAction.execute(del, m);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:5,代码来源:GeneralJSONRDF.java

示例6: main

import com.hp.hpl.jena.update.UpdateAction; //导入方法依赖的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.UpdateAction.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。