/** * Process the configuration file declarations for {@link Context} settings. */ public static void processContext(Resource server, Context cxt) { if ( server == null ) return ; AssemblerUtils.setContext(server, cxt) ; }
/** * Process the configuration file declarations for {@link Context} settings. */ public static void processContext(Resource server, Context cxt) { if ( server == null ) return ; AssemblerUtils.setContext(server, cxt) ; }
@Override public Dataset open(Assembler a, Resource root, Mode mode) { StoreDesc desc = openStore(a, root, mode) ; Dataset ds = SDBFactory.connectDataset(desc) ; AssemblerUtils.setContext(root, ds.getContext()); return ds ; }
@Override public Object open(Assembler a, Resource root, Mode mode) { DatasetGraph dsg; if ( DatasetAssemblerVocab.tDatasetSink.equals(tDataset) ) dsg = new DatasetGraphSink(); else if ( DatasetAssemblerVocab.tDatasetZero.equals(tDataset) ) dsg = new DatasetGraphZero(); else throw new InternalErrorException(); Dataset ds = DatasetFactory.wrap(dsg); AssemblerUtils.setContext(root, ds.getContext()); return ds; } }
@Override public Dataset open(final Assembler assembler, final Resource root, final Mode mode) { // Old name : bypass. if ( ! root.hasProperty( RDF.type, DatasetAssemblerVocab.tDatasetTxnMem ) ) checkType(root, DatasetAssemblerVocab.tMemoryDataset); final Dataset dataset = createTxnMem(); setContext(root, dataset.getContext()); Txn.executeWrite(dataset, ()->{ // Load data into the default graph // This also loads quads into the dataset. multiValueAsString(root, data) .forEach(dataURI -> read(dataset, dataURI)); // load data into named graphs multiValueResource(root, pNamedGraph).forEach(namedGraphResource -> { final String graphName = getAsStringValue(namedGraphResource, pGraphName); if (namedGraphResource.hasProperty(data)) { multiValueAsString(namedGraphResource, data) .forEach(namedGraphData -> read(dataset.getNamedModel(graphName), namedGraphData)); } }); }); return dataset; } }
public Dataset createDataset(Assembler a, Resource root, Mode mode) { // Can use ja:graph or ja:defaultGraph but not both. Resource dftGraphDesc1 = GraphUtils.getResourceValue(root, DatasetAssemblerVocab.pDefaultGraph); Resource dftGraphDesc2 = GraphUtils.getResourceValue(root, DatasetAssemblerVocab.pGraph); if ( dftGraphDesc1 != null && dftGraphDesc2 != null ) throw new AssemblerException(root, "Found both ja:graph and ja:defaultGraph"); Resource graphDesc = ( dftGraphDesc1 != null) ? dftGraphDesc1 : dftGraphDesc2 ; Model model; if ( graphDesc != null ) model = a.openModel(graphDesc); else // Assembler description did not define one. model = GraphFactory.makeDefaultModel(); Dataset ds = DatasetFactory.wrap(model); List<RDFNode> nodes = GraphUtils.multiValue(root, DatasetAssemblerVocab.pNamedGraph); if ( ! nodes.isEmpty() ) { String x = DatasetAssemblerVocab.tDatasetOne.getLocalName(); throw new AssemblerException(root, "A "+x+" dataset can only hold a default graph, and no named graphs"); } AssemblerUtils.setContext(root, ds.getContext()); return ds; } }
static Dataset make(Resource root) { if ( !exactlyOneProperty(root, pLocation) ) throw new AssemblerException(root, "No location given") ; String dir = getStringValue(root, pLocation) ; Location loc = Location.create(dir) ; DatasetGraph dsg = TDBFactory.createDatasetGraph(loc) ; if ( root.hasProperty(pUnionDefaultGraph) ) { Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode() ; NodeValue nv = NodeValue.makeNode(b) ; if ( nv.isBoolean() ) dsg.getContext().set(TDB.symUnionDefaultGraph, nv.getBoolean()) ; else Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value for union graph setting (ignored): " + b) ; } /* <r> rdf:type tdb:DatasetTDB ; tdb:location "dir" ; //ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ; tdb:unionGraph true ; # or "true" */ AssemblerUtils.setContext(root, dsg.getContext()); return DatasetFactory.wrap(dsg) ; }
static Dataset make(Resource root) { if ( !exactlyOneProperty(root, pLocation) ) throw new AssemblerException(root, "No location given") ; String dir = getStringValue(root, pLocation) ; Location loc = Location.create(dir) ; DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(loc) ; if ( root.hasProperty(pUnionDefaultGraph) ) { Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode() ; NodeValue nv = NodeValue.makeNode(b) ; if ( nv.isBoolean() ) dsg.getContext().set(TDB2.symUnionDefaultGraph, nv.getBoolean()) ; else Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value for union graph setting (ignored): " + b) ; } /* <r> rdf:type tdb:DatasetTDB2 ; tdb:location "dir" ; //ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ; tdb:unionGraph true ; # or "true" */ AssemblerUtils.setContext(root, dsg.getContext()); return DatasetFactory.wrap(dsg) ; }
ds.addNamedModel(gName, m); AssemblerUtils.setContext(root, ds.getContext()) ; return ds ;