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

Java DatasetFactory类代码示例

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

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



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

示例1: init

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Before
public void init() throws Exception {

    // For some reason, this is necessary after upgrating to Camel 2.19.
    // Otherwise, it looks like the context doesn't start(!??)
    context.start();
    dataset = DatasetFactory.create();

    // Create two named graphs with triples. Verify that they're non-empty from the start.
    final Model a = ModelFactory.createDefaultModel();
    final Model b = ModelFactory.createDefaultModel();

    a.add(a.getResource("test:something"), a.getProperty("test:prop"), a.getResource("test:whatever"));
    b.add(b.getResource("test:somethingElse"), b.getProperty("test:prop"), b.getResource("test:whatever"));

    dataset.addNamedModel("test:unaffected", a);
    dataset.addNamedModel(SERVICE_DOC_URI, b);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:19,代码来源:ServiceIndexingRoutesTest.java


示例2: main

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
public static void main(String ...args) {
    // -- Base dataset 
    DatasetGraph dsgBase = DatasetGraphFactory.createTxnMem();

    // -- Destination for changes.
    // Text form of output.  
    OutputStream out = System.out;
    // Create an RDFChanges that writes to "out".
    RDFChanges changeLog = RDFPatchOps.textWriter(out);

    // Combined datasetgraph and changes. 
    DatasetGraph dsg = RDFPatchOps.changes(dsgBase, changeLog);

    // Wrap in the Dataset API
    Dataset ds = DatasetFactory.wrap(dsg);

    // --------
    // Do something. Read in data.ttl inside a transaction.
    // (data.ttl is in src/main/resources/)
    Txn.executeWrite(ds,
        ()->RDFDataMgr.read(dsg, "data.ttl")
        );
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:24,代码来源:DeltaEx1_DatasetWithPatchLog.java


示例3: testRulesets

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Test
public void testRulesets() {
    MarkLogicDatasetGraph infTestDsg = getMarkLogicDatasetGraph();
    Dataset ds = DatasetFactory.wrap(infTestDsg);
    String query = "prefix : <http://example.org/> select ?o where { :r3 a ?o }";
    QueryExecution exec = QueryExecutionFactory.create(query, ds);
    ResultSet results = exec.execSelect();

    List<String> subjects = project(results, "o");
    assertEquals("No inference, got back list of size 1", 1,
            subjects.size());

    infTestDsg.withRulesets(SPARQLRuleset.RDFS);
    // MarkLogicQuery inferringQuery = MarkLogicQuery.create(query);
    // inferringQuery.setRulesets(SPARQLRuleset.RDFS);
    exec = QueryExecutionFactory.create(query, ds);
    results = exec.execSelect();
    subjects = project(results, "o");
    System.out.println(subjects);
    assertEquals("Using RDFs got back two class assertions", 2,
            subjects.size());

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


示例4: testBaseUri

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Test
public void testBaseUri() {

    MarkLogicDatasetGraph baseTest = getMarkLogicDatasetGraph();
    Dataset ds = DatasetFactory.wrap(baseTest);
    String query = "select ?o where { <r3> a ?o }";
    QueryExecution exec = QueryExecutionFactory.create(query, ds);
    ResultSet results = exec.execSelect();
    List<String> subjects = project(results, "o");
    assertEquals("No base, got back list of size 0", 0, subjects.size());

    Query q = QueryFactory.create(query, "http://example.org/");
    exec = QueryExecutionFactory.create(q, ds);
    results = exec.execSelect();
    subjects = project(results, "o");
    assertEquals("No base, got back list of size 1", 1, subjects.size());

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


示例5: testUpdateAction

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


示例6: testStringAskQuery

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Test
public void testStringAskQuery() {
	String file = datasource + "tigers.ttl";
	// Read triples into dataset
	RDFDataMgr.read(markLogicDatasetGraph, file);
	markLogicDatasetGraph.sync();
	dataSet = DatasetFactory.create(markLogicDatasetGraph);

	String query1 = "PREFIX  bb: <http://marklogic.com/baseball/players#>" + " ASK " + " WHERE" + " {" + " ?id bb:lastname  ?name ."
			+ " FILTER  EXISTS { ?id bb:country ?countryname }" + " }";
	QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
	Boolean result = queryExec.execAsk();
	assertFalse(result);

	String query2 = "PREFIX  bb: <http://marklogic.com/baseball/players#>" + "PREFIX  r: <http://marklogic.com/baseball/rules#>"
			+ " ASK WHERE" + " {" + " ?id bb:team r:Tigers." + " ?id bb:position \"pitcher\"." + " }";
	queryExec = QueryExecutionFactory.create(query2, dataSet);
	assertTrue(queryExec.execAsk());
	markLogicDatasetGraph.close();
	markLogicDatasetGraph = MarkLogicDatasetGraphFactory.createDatasetGraph(writerClient);

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


示例7: testStringAskQuery2

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Test
public void testStringAskQuery2() {

	String file = datasource + "tigers.ttl";
	// Read triples into dataset
	RDFDataMgr.read(markLogicDatasetGraph, file);
	markLogicDatasetGraph.sync();
	Graph g = markLogicDatasetGraph.getDefaultGraph();
	Node newgraph = NodeFactory.createURI("http://marklogic.com/Graph1");
	markLogicDatasetGraph.addGraph(newgraph, g);
	dataSet = DatasetFactory.create(markLogicDatasetGraph);

	String query1 = "ASK FROM <http://marklogic.com/Graph1>" + " WHERE" + " {" + " ?player ?team <#Tigers>." + " }";
	QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
	Boolean result = queryExec.execAsk();
	assertFalse(result);

	String query2 = "PREFIX  bb: <http://marklogic.com/baseball/players#>" + "PREFIX  r: <http://marklogic.com/baseball/rules#>"
			+ " ASK WHERE" + " {" + " ?id bb:team r:Tigers." + " ?id bb:position \"pitcher\"." + " }";
	queryExec = QueryExecutionFactory.create(query2, dataSet);
	assertTrue(queryExec.execAsk());

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


示例8: main

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
public static void main(String...argv)
{
    Dataset ds = null ;
    
    // Read a TriG file into quad storage in-memory.
    ds = RDFDataMgr.loadDataset("data.trig") ;
    
    // read some (more) data into a dataset graph.
    RDFDataMgr.read(ds, "data2.trig") ;
    
    // Create a dataset,
    Dataset ds2 = DatasetFactory.createTxnMem() ;
    // read in data, indicating the syntax in case the remote end does not
    // correctly provide the HTTP content type.
    RDFDataMgr.read(ds2, "http://host/data2.unknown", TRIG) ;
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:17,代码来源:ExRIOT_3.java


示例9: main

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
public static void main(String []args)
{
    // Create an empty GraphStore (has an empty default graph and no named graphs) 
    Dataset dataset = DatasetFactory.createTxnMem() ;
    
    // ---- Read and update script in one step.
    UpdateAction.readExecute("update.ru", dataset) ;
    
    // ---- Reset.
    UpdateAction.parseExecute("DROP ALL", dataset) ;
    
    // ---- Read the update script, then execute, in separate two steps
    UpdateRequest request = UpdateFactory.read("update.ru") ;
    UpdateAction.execute(request, dataset) ;

    // Write in debug format.
    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,代码行数:25,代码来源:UpdateReadFromFile.java


示例10: main

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
public static void main(String []args)
{
    Dataset dataset = DatasetFactory.createTxnMem() ;
    
    UpdateRequest request = UpdateFactory.create() ;
    
    request.add(new UpdateDrop(Target.ALL)) ;
    request.add(new UpdateCreate("http://example/g2")) ;
    request.add(new UpdateLoad("file:etc/update-data.ttl", "http://example/g2")) ;
    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,代码行数:20,代码来源:UpdateProgrammatic.java


示例11: setUp

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Before
public void setUp() {
    Model defaultModel = ModelFactory.createDefaultModel();
    defaultModel.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Cool")
    );

    Model namedModel = ModelFactory.createDefaultModel();
    namedModel.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Super")
    );
    dataset = DatasetFactory.create(defaultModel);

    dataset.addNamedModel("http://rdfunit.aksw.org", namedModel);
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:20,代码来源:RdfStreamReaderDatasetTest.java


示例12: process

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
	RDFExportResolvedObjects resObj = getResolvedObjects();
	Logger logger = getLogger(ctx);
	EvaluationContext evalCtx = new EvaluationContext(logger);

	int count = 0;
	for (Element elt : Iterators.loop(resObj.files.evaluateElements(evalCtx, corpus))) {
		fillModel(ctx, evalCtx, elt);
		count += resObj.model.size();
		String fn = resObj.fileName.evaluateString(evalCtx, elt);
		OutputFile f = new OutputFile(outDir, fn);
		TargetStream ts = new FileTargetStream(charset, f);
		try (OutputStream out = ts.getOutputStream()) {
			writeModel(ctx, out, resObj.model);
			resObj.model.removeAll();
		}
		catch (IOException e) {
			resObj.model.close();
			rethrow(e);
		}
	}
	logger.info("wrote " + count + " statements");
	if (startServer) {
		Dataset ds = DatasetFactory.assemble(resObj.model);
		FusekiEmbeddedServer server = FusekiEmbeddedServer.create().add("alvisnlp", ds).build();
		server.start();
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:30,代码来源:RDFExport.java


示例13: ServiceNodeWriter

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
/**
 * ServiceNodeWriter.
 *
 * @param serviceURI       String
 * @param servicePredicate String
 * @param serviceType      String
 */
ServiceNodeWriter(final String serviceURI, final String servicePredicate,
                  final String serviceType) {
    final Model model = ModelFactory.createDefaultModel();
    final Resource s = model.createResource(getIdentitySubject());
    final Property p = model.createProperty(servicePredicate);
    final Resource o = model.createResource(serviceURI);
    model.add(s, p, o);

    final Dataset dataset = DatasetFactory.create(model);
    dataset.addNamedModel("http://iiif.service", model);
    this.serviceNode = new ByteArrayOutputStream();
    RDFDataMgr.write(this.serviceNode, model, Lang.NTRIPLES);
}
 
开发者ID:pan-dora,项目名称:modeller,代码行数:21,代码来源:ServiceNodeWriter.java


示例14: createExpModelForChallengeTask

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
private Model createExpModelForChallengeTask(Model model, String challengeTaskUri, String systemUri) {
    Dataset dataset = DatasetFactory.create();
    dataset.addNamedModel("http://temp.org/challenge", model);
    String query = SparqlQueries.getCreateExperimentFromTaskQuery(Constants.NEW_EXPERIMENT_URI, challengeTaskUri,
            systemUri, "http://temp.org/challenge");
    if (query == null) {
        LOGGER.error("Couldn't load SPARQL query to create an RDF model for a new experiment. Returning null.");
        return null;
    }
    QueryExecution qe = QueryExecutionFactory.create(query, dataset);
    return qe.execConstruct();
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:13,代码来源:PlatformController.java


示例15: DummyStorage

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
public DummyStorage(String configGraphFile, String privateGraphFile, String publicGraphFile) {
    super(null);
    dataset = DatasetFactory.create();
    Model model = configGraphFile != null ? loadModel(configGraphFile) : ModelFactory.createDefaultModel();
    dataset.addNamedModel(Constants.CHALLENGE_DEFINITION_GRAPH_URI, model);
    model = privateGraphFile != null ? loadModel(privateGraphFile) : ModelFactory.createDefaultModel();
    dataset.addNamedModel(Constants.PRIVATE_RESULT_GRAPH_URI, model);
    model = publicGraphFile != null ? loadModel(publicGraphFile) : ModelFactory.createDefaultModel();
    dataset.addNamedModel(Constants.PUBLIC_RESULT_GRAPH_URI, model);
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:11,代码来源:ChallengePublicationTest.java


示例16: main

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
public static void main(String ...args) {
    // -- Base dataset 
    DatasetGraph dsgBase = DatasetGraphFactory.createTxnMem();

    // -- Destination for changes.
    // Text form of output.  
    OutputStream out = System.out;
    // Create an RDFChanges that writes to "out".
    RDFChanges changeLog = RDFPatchOps.textWriter(out);


    // ---- Collect up changes. 
    //RDFPatchOps.collect();
    RDFChangesCollector rcc = new RDFChangesCollector();
    DatasetGraph dsg = RDFPatchOps.changes(dsgBase, rcc);
    Dataset ds = DatasetFactory.wrap(dsg);
    Txn.executeWrite(ds,
                     ()->RDFDataMgr.read(dsg, "data.ttl")
                     );
    // Again - different bnodes.
    // Note all changes are recorded - even if they have no effect
    // (e.g the prefix, the triple "ex:s ex:p ex:o").
    Txn.executeWrite(ds,
                     ()->RDFDataMgr.read(dsg, "data.ttl")
                     );
    
    // Collected (in-memory) patch.
    RDFPatch patch = rcc.getRDFPatch();
    // Write it.
    patch.apply(changeLog);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:32,代码来源:DeltaEx2_DatasetCollectPatch.java


示例17: DeltaConnection

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
private DeltaConnection(DataState dataState, DatasetGraph basedsg, DeltaLink link, TxnSyncPolicy syncTxnBegin) {
    Objects.requireNonNull(dataState, "DataState");
    Objects.requireNonNull(link, "DeltaLink");
    //Objects.requireNonNull(basedsg, "base DatasetGraph");
    if ( basedsg instanceof DatasetGraphChanges )
        FmtLog.warn(this.getClass(), "[%s] DatasetGraphChanges passed into %s", dataState.getDataSourceId() ,Lib.className(this));
    this.state = dataState;
    this.base = basedsg;
    this.datasourceId = dataState.getDataSourceId();
    this.datasourceName = dataState.getDatasourceName();
    this.dLink = link;
    this.valid = true;
    this.syncTxnBegin = syncTxnBegin;
    if ( basedsg == null ) {
        this.target = null;
        this.managed = null;
        this.managedDataset = null;
        this.managedNoEmpty = null;
        this.managedNoEmptyDataset = null;
        return;
    }
    
    // Where to put incoming changes. 
    this.target = new RDFChangesApply(basedsg);
    // Where to send outgoing changes.
    RDFChanges monitor = createRDFChanges(datasourceId);
    this.managed = new DatasetGraphChanges(basedsg, monitor, null, syncer(syncTxnBegin));
    this.managedDataset = DatasetFactory.wrap(managed);
    // ----
    RDFChanges monitor1 = new RDFChangesSuppressEmpty(monitor);
    this.managedNoEmpty = new DatasetGraphChanges(basedsg, monitor1, null, syncer(syncTxnBegin));
    this.managedNoEmptyDataset = DatasetFactory.wrap(managedNoEmpty);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:34,代码来源:DeltaConnection.java


示例18: exec

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final Model exec() {
    Dataset inputDataset = DatasetFactory.create();
    QuerySolution initialBindings = new QuerySolutionMap();
    Model initialModel = ModelFactory.createDefaultModel();
    StreamRDF outputStream = new StreamRDFModel(initialModel);
    exec(inputDataset, initialBindings, outputStream);
    return initialModel;
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:13,代码来源:RootPlanImpl.java


示例19: setupDataset

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Before
public void setupDataset() {
    ds = DatasetFactory
            .wrap(getMarkLogicDatasetGraph("testdata/testData.trig"));
    // ds =
    // DatasetFactory.create(getJenaDatasetGraph("testdata/testData.trig"));
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:8,代码来源:MarkLogicQueryEngineTest.java


示例20: setupDataset

import org.apache.jena.query.DatasetFactory; //导入依赖的package包/类
@Before
public void setupDataset() {
    dsg = getMarkLogicDatasetGraph("testdata/testData.trig");

    ds = DatasetFactory.wrap(dsg);

    String tripleDocOne =

    "<semantic-document>\n"
            + "<title>First Title</title>\n"
            + "<size>100</size>\n"
            + "<sem:triples xmlns:sem=\"http://marklogic.com/semantics\">"
            + "<sem:triple><sem:subject>http://example.org/r9928</sem:subject>"
            + "<sem:predicate>http://example.org/p3</sem:predicate>"
            + "<sem:object datatype=\"http://www.w3.org/2001/XMLSchema#int\">1</sem:object></sem:triple>"
            + "</sem:triples>\n" + "</semantic-document>";

    String tripleDocTwo =

    "<semantic-document>\n"
            + "<title>Second Title</title>\n"
            + "<size>500</size>\n"
            + "<sem:triples xmlns:sem=\"http://marklogic.com/semantics\">"
            + "<sem:triple><sem:subject>http://example.org/r9929</sem:subject>"
            + "<sem:predicate>http://example.org/p3</sem:predicate>"
            + "<sem:object datatype=\"http://www.w3.org/2001/XMLSchema#int\">2</sem:object></sem:triple>"
            + "</sem:triples>\n" + "</semantic-document>";

    XMLDocumentManager docMgr = writerClient.newXMLDocumentManager();
    docMgr.write("/directory1/doc1.xml",
            new StringHandle().with(tripleDocOne));
    docMgr.write("/directory2/doc2.xml",
            new StringHandle().with(tripleDocTwo));
    qmgr = writerClient.newQueryManager();

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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