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


Java UpdateAction类代码示例

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


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

示例1: insertData

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
public static void insertData(GraphDatabaseService njgraph){
	NeoGraph graph = new NeoGraph(njgraph);
	Model njmodel = ModelFactory.createModelForGraph(graph);
	
	String s2 = "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
           	"PREFIX uni: <http://seecs.edu.pk/db885#>" +
           	"PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
           "INSERT DATA "+
           "{ " +
           " <http://seecs.edu.pk/db885#KhalidLatif> rdf:type uni:Professor ."+
           "}"; 
	StopWatch watch = new StopWatch();
	UpdateAction.parseExecute(s2, njmodel);
	System.out.println("Insert query took: " + watch.stop() + " ms");
	log.info("Data inserted");
	System.out.println("Data inserted");
}
 
开发者ID:semr,项目名称:neo4jena,代码行数:18,代码来源:Course_Test.java

示例2: executeUpdate

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

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 既存の名前付きグラフのデータを別の既存の名前付きグラフに移動する(move1)と同等のCLEAR/INSERT文。
 */
public static void move7() {
    System.out.println("##### move7 #####");
    GraphStore graphStore = loadData();
    printDebug(graphStore, "before");
    String cmd = "CLEAR SILENT GRAPH <http://sparqlbook.jp/graph2>;"
               + "INSERT {"
               + "  GRAPH <http://sparqlbook.jp/graph2> { ?s ?p ?o }"
               + "}"
               + "WHERE {"
               + "  GRAPH <http://sparqlbook.jp/graph1> { ?s ?p ?o }"
               + "};"
               + "DROP GRAPH <http://sparqlbook.jp/graph1>";
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:19,代码来源:MoveExamples.java

示例4: insert

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 既存の名前付きグラフから検索したデータを元に新しいデータを挿入する。
 */
public static void insert() {
    System.out.println("##### insert #####");
    GraphStore graphStore = loadData();
    printDebug(graphStore, "before");
    String cmd = "PREFIX : <http://sparqlbook.jp/>"
               + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
               + ""
               + "INSERT {"
               + "  GRAPH <http://sparqlbook.jp/graph1> {"
               + "    ?author rdf:type :Person ."
               + "  }"
               + "}"
               + "WHERE {"
               + "  GRAPH <http://sparqlbook.jp/graph1> {"
               + "    :book :author ?author . "
               + "  }"
               + "}";
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:24,代码来源:InsertDeleteExamples.java

示例5: delete

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 既存の名前付きグラフから検索したデータを元にデータを削除する。
 */
public static void delete() {
    System.out.println("##### delete #####");
    GraphStore graphStore = loadData();
    printDebug(graphStore, "before");
    String cmd = "PREFIX : <http://sparqlbook.jp/>"
               + ""
               + "DELETE {"
               + "  GRAPH <http://sparqlbook.jp/graph1> {"
               + "    ?author ?p ?o . "
               + "  }"
               + "}"
               + "WHERE {"
               + "  GRAPH <http://sparqlbook.jp/graph1> {"
               + "    :book :author ?author . "
               + "    ?author ?p ?o . "
               + "  }"
               + "}";
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:24,代码来源:InsertDeleteExamples.java

示例6: deleteWhere

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 既存の名前付きグラフから検索したデータを元にデータを削除する。
 * DELETE直後にWHERE句を記述して、WHERE句で指定したパターンにマッチするデータを全て削除する。
 */
public static void deleteWhere() {
    System.out.println("##### deleteWhere #####");
    GraphStore graphStore = loadData();
    printDebug(graphStore, "before");
    String cmd = "PREFIX : <http://sparqlbook.jp/>"
               + ""
               + "DELETE "
               + "WHERE {"
               + "  GRAPH <http://sparqlbook.jp/graph1> {"
               + "    :book :author ?author . "
               + "    ?author ?p ?o . "
               + "  }"
               + "}";
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:21,代码来源:InsertDeleteExamples.java

示例7: with

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 既存の名前付きグラフから検索したデータを元にデータを削除し、挿入する。 WITH句を使用してグラフ指定を簡略化している。
 */
public static void with() {
    System.out.println("##### with #####");
    GraphStore graphStore = loadData2();
    printDebug(graphStore, "before");
    String cmd = "PREFIX : <http://sparqlbook.jp/>"
               + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
               + "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"
               + ""
               + "WITH <http://sparqlbook.jp/graph1>"
               + "DELETE {"
               + "  ?author rdf:type :Person ."
               + "}"
               + "INSERT {"
               + "  ?author rdf:type dbpedia-owl:Person ."
               + "}"
               + "WHERE {"
               + "  :book :author ?author . "
               + "}";
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:25,代码来源:InsertDeleteExamples.java

示例8: using

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 既存の名前付きグラフから検索したデータを元にデータを削除し、挿入する。 USING句を使用してWHERE句の対象グラフ指定を指定している。
 */
public static void using() {
    System.out.println("##### usnig #####");
    GraphStore graphStore = loadData2();
    printDebug(graphStore, "before");
    String cmd = "PREFIX : <http://sparqlbook.jp/>"
               + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
               + "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"
               + ""
               + "WITH <http://sparqlbook.jp/graph2>"
               + "DELETE {"
               + "  ?author rdf:type :Person ."
               + "}"
               + "INSERT {"
               + "  ?author rdf:type dbpedia-owl:Person ."
               + "}"
               + "USING <http://sparqlbook.jp/graph1>"
               + "WHERE {"
               + "  :book :author ?author . "
               + "}";
    UpdateAction.parseExecute(cmd, graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:26,代码来源:InsertDeleteExamples.java

示例9: 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

示例10: dePublishRecord

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
@Override
public void dePublishRecord(byte[] rdf, String rdfAbout, String host) throws Exception {
	super.dePublishRecord(rdf, rdfAbout, host);
	SDBConnection conn = new SDBConnection(jenaDataSource);
	StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash, BygleSystemUtils.getDBType(databaseType));
	Store store = SDBFactory.connectStore(conn, storeDesc);
	Dataset dataset = SDBFactory.connectDataset(store);
	Model modelTpl = ModelFactory.createDefaultModel();
	modelTpl.read(new ByteArrayInputStream(rdf), "");

	StringBuilder query = new StringBuilder();
	query.append("DELETE  {?bn ?a ?b}   WHERE {");
	query.append("{<" + host + "/" + rdfAbout + "> ?p ?o");
	query.append(". FILTER(isBlank(?o))");
	query.append(". ?o ?c ?s");
	query.append(". FILTER(isBlank(?s))");
	query.append(". ?s ?d ?bn");
	query.append(". FILTER(isBlank(?bn))}");
	query.append("UNION{");
	query.append("<" + host + "/" + rdfAbout + "> ?p ?o");
	query.append(". FILTER(isBlank(?o))");
	query.append(". ?o ?c ?bn");
	query.append(". FILTER(isBlank(?bn))}");
	query.append("UNION{");
	query.append(" <" + host + "/" + rdfAbout + "> ?p ?bn");
	query.append(". FILTER(isBlank(?bn))");
	query.append("} ?bn ?a ?b}");

	UpdateAction.parseExecute(query.toString(), modelTpl);
	modelTpl.removeAll(modelTpl.createResource(host + "/" + rdfAbout), null, null);
	dataset.getDefaultModel().remove(modelTpl);
	store.getConnection().close();
	store.close();

}
 
开发者ID:regestaexe,项目名称:bygle-ldp,代码行数:36,代码来源:JenaEndPointManager.java

示例11: 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

示例12: 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

示例13: execute

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * Executes a given {@link UpdateRequest} against the given {@link DatasetGraph}.
 * 
 * @param updateRequest the update request.
 * @param datasetGraph the dataset graph.
 * @param graphUris the target graphs (optional).
 */
void execute(final UsingList list, final String updateRequests, final DatasetGraph datasetGraph) {
	try {
		UpdateAction.parseExecute(
				list, 
				datasetGraph, 
				new ByteArrayInputStream(updateRequests.getBytes("UTF-8")));		
	} catch (final Exception exception) {	
		final String message = MessageFactory.createMessage(
				MessageCatalog._00099_INVALID_UPDATE_QUERY, 
				updateRequests);
		LOGGER.error(message, exception);
		throw new SolrException(ErrorCode.BAD_REQUEST, message);
	}	
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:22,代码来源:Sparql11UpdateRdfDataLoader.java

示例14: load1

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * デフォルトグラフにロードする。
 */
public static void load1() {
    System.out.println("##### load1 #####");
    GraphStore graphStore = createGraphStore();
    printDebug(graphStore, "before");
    UpdateAction.parseExecute("LOAD <file:/data/rdf/update-data1.ttl>", graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:11,代码来源:LoadExamples.java

示例15: load2

import com.hp.hpl.jena.update.UpdateAction; //导入依赖的package包/类
/**
 * 名前付きグラフにロードする。
 */
public static void load2() {
    System.out.println("##### load2 #####");
    GraphStore graphStore = createGraphStore();
    printDebug(graphStore, "before");
    UpdateAction.parseExecute("LOAD <file:/data/rdf/update-data1.ttl> INTO GRAPH <http://sparqlbook.jp/graph1>",
            graphStore);
    printDebug(graphStore, "after");
}
 
开发者ID:sparql-book,项目名称:sparql-book,代码行数:12,代码来源:LoadExamples.java


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