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


Java DatasetFactory类代码示例

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


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


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