本文整理汇总了Java中org.apache.jena.query.DatasetFactory.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java DatasetFactory.wrap方法的具体用法?Java DatasetFactory.wrap怎么用?Java DatasetFactory.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.query.DatasetFactory
的用法示例。
在下文中一共展示了DatasetFactory.wrap方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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")
);
}
示例2: 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());
}
示例3: 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());
}
示例4: 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);
}
示例5: 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);
}
示例6: 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"));
}
示例7: 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();
}
示例8: create
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
protected Dataset create() {
DatasetGraph dsg1 = DatasetGraphFactory.create() ;
DatasetGraphBuffering dsg = new DatasetGraphBuffering(dsg1) ;
return DatasetFactory.wrap(dsg) ;
}
示例9: open
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Override
public Object open(Assembler a, Resource root, Mode mode) {
// delta:changes.
if ( ! exactlyOneProperty(root, pDeltaChanges) )
throw new AssemblerException(root, "No destination for changes given") ;
String destURL = getAsStringValue(root, pDeltaChanges);
// Future - multiple outputs.
List<String> xs = Arrays.asList(destURL);
// delta:zone.
if ( ! exactlyOneProperty(root, pDeltaZone) )
throw new AssemblerException(root, "No location for state manangement (zone)") ;
String zoneLocation = getAsStringValue(root, pDeltaZone);
// Name of the patch log.
// delta:patchlog
if ( ! exactlyOneProperty(root, pDeltaPatchLog) )
throw new AssemblerException(root, "No patch log name") ;
String dsName = getAsStringValue(root, pDeltaPatchLog);
// delta:storage
if ( ! exactlyOneProperty(root, pDeltaChanges) )
throw new AssemblerException(root, "No location for state manangement (zone)") ;
String storageTypeStr = getAsStringValue(root, pDeltaStorage);
LocalStorageType storage = LocalStorageType.fromString(storageTypeStr);
if ( storage == null )
throw new AssemblerException(root, "Unrecognized storage type '"+storageTypeStr+"'");
// Build the RDFChanges: URLs to send each patch log entry.
RDFChanges streamChanges = null ;
for ( String dest : xs ) {
FmtLog.info(log, "Destination: '%s'", dest) ;
RDFChanges sc = DeltaLib.destination(dest);
streamChanges = RDFChangesN.multi(streamChanges, sc) ;
}
// Link to log server.
DeltaLink deltaLink = DeltaLinkHTTP.connect(destURL);
// Touch server
Id clientId = Id.create();
deltaLink.register(clientId);
// Create.connect the local copy.
Zone zone = Zone.connect(zoneLocation);
// Local client.
DeltaClient deltaClient = DeltaClient.create(zone, deltaLink);
Id dsRef = setup(deltaClient, dsName, "delta:"+dsName, storage);
DeltaConnection deltaConnection = deltaClient.get(dsRef);
DatasetGraph dsg = deltaConnection.getDatasetGraph();
// This DatasetGraph syncs on transaction so it happens, and assumes, a transaction for any Fuseki operation.
// And someday tap into services to add a "sync before operation" step.
// Poll for changes as well.
// if ( root.hasProperty(pPollForChanges) ) {
// if ( ! exactlyOneProperty(root, pPollForChanges) )
// throw new AssemblerException(root, "Multiple places to poll for chnages") ;
// String source = getStringValue(root, pPollForChanges) ;
// forkUpdateFetcher(source, dsgSub) ;
// }
// Put state into dsg Context "for the record".
Context cxt = dsg.getContext();
cxt.set(symDeltaClient, deltaClient);
cxt.set(symDeltaConnection, deltaConnection);
cxt.set(symDeltaZone, zone);
return DatasetFactory.wrap(dsg);
}
示例10: configure
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Setup
public void configure() {
markLogicDatasetGraph = ExampleUtils.loadPropsAndInit();
RDFDataMgr.read(markLogicDatasetGraph, "test.owl", Lang.RDFXML);
dataset = DatasetFactory.wrap(markLogicDatasetGraph);
}
示例11: dataset
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
public static Dataset dataset(LzDataset lz) {
return DatasetFactory.wrap(lz.getDataset()) ;
}
示例12: toDataset
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
/**
* Gets a view of the DatasetGraph as a Dataset, which is used to back
* queries.
* @return The DatasetGraph, wrapped in a Dataset interface.
*/
public Dataset toDataset() {
checkIsOpen();
return DatasetFactory.wrap(this);
}