/// <summary> /// Indexes a Dataset /// </summary> /// <param name="dataset">Dataset</param> public void Index(ISparqlDataset dataset) { foreach (Uri u in dataset.GraphUris) { IGraph g = dataset[u]; this.Index(g); } }
/// <summary> /// Creates a new Evaluation Context for the given Query over the given Dataset /// </summary> /// <param name="q">Query</param> /// <param name="data">Dataset</param> public SparqlEvaluationContext(SparqlQuery q, ISparqlDataset data) { this._query = q; this._data = data; this._inputSet = new IdentityMultiset(); this._binder = new LeviathanResultBinder(this); this.CalculateTimeout(); }
/// <summary> /// Creates a new Leviathan Update Processor /// </summary> /// <param name="data">SPARQL Dataset</param> public LeviathanUpdateProcessor(ISparqlDataset data) { this._dataset = data; if (!this._dataset.HasGraph(null)) { //Create the Default unnamed Graph if it doesn't exist and then Flush() the change this._dataset.AddGraph(new Graph()); this._dataset.Flush(); } }
private void EnsureTestData() { if (this._data == null) { TripleStore store = new TripleStore(); Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); store.Add(g); this._data = new InMemoryDataset(store); } }
/// <summary> /// Creates a new Dataset Handler configuration /// </summary> /// <param name="context">HTTP Context</param> /// <param name="config">Configuration Graph</param> /// <param name="objNode">Object Node</param> public BaseDatasetHandlerConfiguration(HttpContext context, IGraph config, INode objNode) : base(context, config, objNode) { INode datasetNode = ConfigurationLoader.GetConfigurationNode(config, objNode, ConfigurationLoader.CreateConfigurationNode(config, ConfigurationLoader.PropertyUsingDataset)); if (datasetNode == null) throw new DotNetRdfConfigurationException("Unable to load Dataset Handler Configuration as there is no value given for the required dnr:usingDataset property"); //Load the Dataset Object temp = ConfigurationLoader.LoadObject(config, datasetNode); if (temp is ISparqlDataset) { this._dataset = (ISparqlDataset)temp; } else { throw new DotNetRdfConfigurationException("Unable to load Dataset Handler Configuration as the dnr:usingDatset property points to an Object which cannot be loaded as an object which implements the ISparqlDataset interface"); } }
private void EnsureLeviathanReady() { if (this._dataset == null) { TripleStore store = new TripleStore(); Graph g = new Graph(); g.LoadFromFile("resources\\InferenceTest.ttl"); store.Add(g); this._dataset = new InMemoryDataset(store); } if (this._leviathan == null) { this._leviathan = new LeviathanQueryProcessor(this._dataset); } if (this._explainer == null) { this._explainer = new ExplainQueryProcessor(this._dataset, ExplanationLevel.Default); } }
private void TestBindings(ISparqlDataset data, String queryWithBindings, String queryWithoutBindings) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(data); SparqlQuery bindingsQuery = this._parser.ParseFromString(queryWithBindings); SparqlQuery noBindingsQuery = this._parser.ParseFromString(queryWithoutBindings); SparqlResultSet bindingsResults = processor.ProcessQuery(bindingsQuery) as SparqlResultSet; SparqlResultSet noBindingsResults = processor.ProcessQuery(noBindingsQuery) as SparqlResultSet; if (bindingsResults == null) Assert.Fail("Did not get a SPARQL Result Set for the Bindings Query"); if (noBindingsResults == null) Assert.Fail("Did not get a SPARQL Result Set for the Non-Bindings Query"); Console.WriteLine("Bindings Results"); TestTools.ShowResults(bindingsResults); Console.WriteLine(); Console.WriteLine("Non-Bindings Results"); TestTools.ShowResults(noBindingsResults); Console.WriteLine(); Assert.AreEqual(noBindingsResults, bindingsResults, "Result Sets should have been equal"); }
private void EnableFullTextIndex() { if (this._dataset is FullTextIndexedDataset) { //Nothing to do } else if (this._dataset is WebDemandDataset) { WebDemandDataset ds = (WebDemandDataset)this._dataset; this._dataset = ds.UnderlyingDataset; this.EnableFullTextIndex(); this._dataset = new WebDemandDataset(this._dataset); } else { //Create and ensure index ready for use this._ftIndex = new RAMDirectory(); var writer = new IndexWriter(this._ftIndex, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), IndexWriter.MaxFieldLength.UNLIMITED); writer.Dispose(); //Create Indexer and wrap dataset this._ftIndexer = new LuceneObjectsIndexer(this._ftIndex, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30), new DefaultIndexSchema()); if (this._dataset is WebDemandDataset) { //Web Demand needs to go around Full Text as we want to index on demand loaded content this._dataset = new WebDemandDataset(new FullTextIndexedDataset(((WebDemandDataset)this._dataset).UnderlyingDataset, this._ftIndexer, true)); } else { this._dataset = new FullTextIndexedDataset(this._dataset, this._ftIndexer, true); } //Create and Register Optimizer this._ftSearcher = new LuceneSearchProvider(Lucene.Net.Util.Version.LUCENE_29, this._ftIndex); this._ftOptimiser = new FullTextOptimiser(this._ftSearcher); SparqlOptimiser.AddOptimiser(this._ftOptimiser); } this._processor = new LeviathanQueryProcessor(this._dataset); }
private void TestDropGraphRollback() { ISparqlDataset dataset = this.GetNonEmptyDataset(); String updates = "DROP GRAPH <" + TestGraphUri.ToString() + ">; DROP GRAPH <" + TestGraphUri.ToString() + ">"; SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates); LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset); try { processor.ProcessCommandSet(cmds); Assert.True(false, "Did not thrown a SparqlUpdateException as expected"); } catch (SparqlUpdateException upEx) { TestTools.ReportError("Update Exception", upEx); } Assert.True(dataset.HasGraph(TestGraphUri), "Graph should exist as the Discard() should ensure it was still in the Dataset"); }
private void TestCreateGraphRollbackWithoutAutoCommit() { ISparqlDataset dataset = this.GetEmptyDataset(); String updates = "CREATE GRAPH <" + TestGraphUri.ToString() + ">; CREATE GRAPH <" + TestGraphUri.ToString() + ">"; SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates); LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset); processor.AutoCommit = false; try { processor.ProcessCommandSet(cmds); Assert.True(false, "Did not throw a SparqlUpdateException as expected"); } catch (SparqlUpdateException upEx) { TestTools.ReportError("Update Exception", upEx); } Assert.True(dataset.HasGraph(TestGraphUri), "Graph should exist as the Transaction has not been committed yet as Auto-Commit is off"); //Try to Flush() which should error try { processor.Flush(); Assert.True(false, "Did not throw a SparqlUpdateException as expected on call to Flush()"); } catch (SparqlUpdateException upEx) { Console.WriteLine("Threw error when attempting to Flush() as expected"); TestTools.ReportError("Update Exception", upEx); } //Now discard processor.Discard(); Assert.False(dataset.HasGraph(TestGraphUri), "Graph should not exist as the Discard() should cause it to be removed from the Dataset"); }
private void TestInsertDataThenDeleteDataRollback() { ISparqlDataset dataset = this.GetNonEmptyDataset(); String updates = "INSERT DATA { GRAPH <" + TestGraphUri.ToString() + "> { <ex:subj> <ex:pred> <ex:obj> } }; DELETE DATA { GRAPH <" + TestGraphUri.ToString() + "> { <ex:subj> <ex:pred> <ex:obj> } }; CREATE GRAPH <" + TestGraphUri.ToString() + ">"; SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates); LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset); try { processor.ProcessCommandSet(cmds); Assert.True(false, "Did not thrown a SparqlUpdateException as expected"); } catch (SparqlUpdateException upEx) { TestTools.ReportError("Update Exception", upEx); } Assert.True(dataset[TestGraphUri].IsEmpty, "Graph should be empty as the Discard() should reverse first the delete then the insert"); }
private void TestCreateGraphRollback() { ISparqlDataset dataset = this.GetEmptyDataset(); String updates = "CREATE GRAPH <" + TestGraphUri.ToString() + ">; CREATE GRAPH <" + TestGraphUri.ToString() + ">"; SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates); LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset); try { processor.ProcessCommandSet(cmds); Assert.True(false, "Did not thrown a SparqlUpdateException as expected"); } catch (SparqlUpdateException upEx) { TestTools.ReportError("Update Exception", upEx); } Assert.False(dataset.HasGraph(TestGraphUri), "Graph should not exist as the Discard() should cause it to be removed from the Dataset"); }
/// <summary> /// Creates a new Dataset Handler configuration /// </summary> /// <param name="context">HTTP Context</param> /// <param name="config">Configuration Graph</param> /// <param name="objNode">Object Node</param> public BaseDatasetHandlerConfiguration(IHttpContext context, IGraph config, INode objNode) : base(context, config, objNode) { INode datasetNode = ConfigurationLoader.GetConfigurationNode(config, objNode, config.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyUsingDataset))); if (datasetNode == null) { throw new DotNetRdfConfigurationException("Unable to load Dataset Handler Configuration as there is no value given for the required dnr:usingDataset property"); } // Load the Dataset Object temp = ConfigurationLoader.LoadObject(config, datasetNode); if (temp is ISparqlDataset) { this._dataset = (ISparqlDataset)temp; } else { throw new DotNetRdfConfigurationException("Unable to load Dataset Handler Configuration as the dnr:usingDatset property points to an Object which cannot be loaded as an object which implements the ISparqlDataset interface"); } }
private void TestCreateDropSequenceRollback2() { ISparqlDataset dataset = this.GetNonEmptyDataset(); String updates = "DROP GRAPH <" + TestGraphUri.ToString() + ">; CREATE GRAPH <" + TestGraphUri.ToString() + ">; DROP GRAPH <" + TestGraphUri.ToString() + ">; DROP GRAPH <" + TestGraphUri.ToString() + ">"; SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates); LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset); try { processor.ProcessCommandSet(cmds); Assert.True(false, "Expected SPARQL Update Exception was not thrown"); } catch (SparqlUpdateException upEx) { TestTools.ReportError("Update Exception", upEx); } Assert.True(dataset.HasGraph(TestGraphUri), "Graph should not exist"); }
public fclsSparqlGui() { InitializeComponent(); Constants.WindowIcon = this.Icon; this._store = new TripleStore(); this._dataset = new InMemoryQuadDataset(this._store); this._processor = new LeviathanQueryProcessor(this._dataset); //Enable UTF-8 BOM setting if user set Options.UseBomForUtf8 = false; if (Properties.Settings.Default.UseUtf8Bom) { Options.UseBomForUtf8 = true; this.chkUseUtf8Bom.Checked = true; } String temp = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); String sep = new String(new char[] { Path.DirectorySeparatorChar }); if (!temp.EndsWith(sep)) { temp += sep; } temp = Path.Combine(temp, @"dotNetRDF\"); if (!System.IO.Directory.Exists(temp)) { System.IO.Directory.CreateDirectory(temp); } temp = Path.Combine(temp, @"SparqlGUI\"); if (!System.IO.Directory.Exists(temp)) { System.IO.Directory.CreateDirectory(temp); } this._logfile = Path.Combine(temp, "SparqlGui-" + DateTime.Now.ToString("MMM-yyyy") + ".log"); this.ofdBrowse.Filter = MimeTypesHelper.GetFilenameFilter(true, true, false, false, false, true); this.ofdQuery.Filter = MimeTypesHelper.GetFilenameFilter(false, false, false, true, false, true); }
private void TestDropThenInsertDataRollback() { ISparqlDataset dataset = this.GetNonEmptyDataset(); String updates = "DROP GRAPH <" + TestGraphUri.ToString() + ">; INSERT DATA { GRAPH <" + TestGraphUri.ToString() + "> { <ex:subject> <ex:predicate> <ex:object> } }; CREATE GRAPH <" + TestGraphUri.ToString() + ">"; SparqlUpdateCommandSet cmds = this._parser.ParseFromString(updates); LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset); try { processor.ProcessCommandSet(cmds); Assert.True(false, "Did not thrown a SparqlUpdateException as expected"); } catch (SparqlUpdateException upEx) { TestTools.ReportError("Update Exception", upEx); } Assert.True(dataset.HasGraph(TestGraphUri), "Graph should not exist as the Discard() should cause it to be removed from the Dataset"); Assert.True(dataset[TestGraphUri].IsEmpty, "Graph should be empty as the Discard() should have reversed the INSERT DATA"); }
public Connector(ISparqlDataset dataset) { Dataset = dataset; }
private void TestNegation(ISparqlDataset data, String queryWithNegation) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(data); SparqlQuery negQuery = this._parser.ParseFromString(queryWithNegation); SparqlResultSet negResults = processor.ProcessQuery(negQuery) as SparqlResultSet; if (negResults == null) Assert.Fail("Did not get a SPARQL Result Set for the Negation Query"); Console.WriteLine("Negation Results"); TestTools.ShowResults(negResults); Console.WriteLine(); Assert.IsTrue(negResults.IsEmpty, "Result Set should be empty"); }
/// <summary> /// Creates a new Evaluation Context for the given Query over the given Dataset using a specific processor. /// </summary> /// <param name="q">Query.</param> /// <param name="data">Dataset.</param> /// <param name="processor">Query Processor.</param> public SparqlEvaluationContext(SparqlQuery q, ISparqlDataset data, ISparqlQueryAlgebraProcessor <BaseMultiset, SparqlEvaluationContext> processor) : this(q, data) { _processor = processor; }
/// <summary> /// Creates a new Web Demand Dataset /// </summary> /// <param name="dataset">Underlying Dataset</param> public WebDemandDataset(ISparqlDataset dataset) : base(dataset) { }
/// <summary> /// Creates a new SPARQL Update Evaluation Context /// </summary> /// <param name="commands">Command Set</param> /// <param name="data">SPARQL Dataset</param> public SparqlUpdateEvaluationContext(SparqlUpdateCommandSet commands, ISparqlDataset data) : this(data) { this._commands = commands; }
public void Evaluate(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, ISparqlDataset dataset) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset); processor.ProcessQuery(rdfHandler, resultsHandler, this); }
/// <summary> /// Executes a SPARQL Update command set on the Dataset if it is updateable /// </summary> /// <param name="sparqlUpdateCommandSet"></param> public static void ExecuteUpdate(this ISparqlDataset dataset, String sparqlUpdateCommandSet) { }
/// <summary> /// Creates a new Dataset Graph collection. /// </summary> /// <param name="dataset">SPARQL Dataset.</param> public DatasetGraphCollection(ISparqlDataset dataset) { _dataset = dataset; }
private void TestBindings(ISparqlDataset data, SparqlParameterizedString queryWithBindings, SparqlParameterizedString queryWithoutBindings) { this.TestBindings(data, queryWithBindings.ToString(), queryWithoutBindings.ToString()); }
/// <summary> /// Creates a new Leviathan Protocol Processor /// </summary> /// <param name="dataset">SPARQL Dataset</param> public LeviathanProtocolProcessor(ISparqlDataset dataset) : base(new LeviathanQueryProcessor(dataset), new LeviathanUpdateProcessor(dataset)) { }
private void TestNegation(ISparqlDataset data, SparqlParameterizedString queryWithNegation, SparqlParameterizedString queryWithoutNegation) { this.TestNegation(data, queryWithNegation.ToString(), queryWithoutNegation.ToString()); }
private void TestNegation(ISparqlDataset data, String queryWithNegation, String queryWithoutNegation) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(data); SparqlQuery negQuery = this._parser.ParseFromString(queryWithNegation); SparqlQuery noNegQuery = this._parser.ParseFromString(queryWithoutNegation); SparqlResultSet negResults = processor.ProcessQuery(negQuery) as SparqlResultSet; SparqlResultSet noNegResults = processor.ProcessQuery(noNegQuery) as SparqlResultSet; if (negResults == null) Assert.Fail("Did not get a SPARQL Result Set for the Negation Query"); if (noNegResults == null) Assert.Fail("Did not get a SPARQL Result Set for the Non-Negation Query"); Console.WriteLine("Negation Results"); TestTools.ShowResults(negResults); Console.WriteLine(); Console.WriteLine("Non-Negation Results"); TestTools.ShowResults(noNegResults); Console.WriteLine(); Assert.AreEqual(noNegResults, negResults, "Result Sets should have been equal"); }
/// <summary> /// Creates a new Explain Update Processor. /// </summary> /// <param name="data">Dataset.</param> /// <param name="level">Explanation Level.</param> public ExplainUpdateProcessor(ISparqlDataset data, ExplanationLevel level) : base(data) { _level = level; }
/// <summary> /// Executes a SPARQL Query on the Dataset /// </summary> /// <param name="sparqlQuery"></param> /// <returns></returns> public static object ExecuteQuery(this ISparqlDataset dataset, String sparqlQuery) { }
public Object Evaluate(ISparqlDataset dataset) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset); return processor.ProcessQuery(this); }
public Object Evaluate(ISparqlDataset dataset) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(dataset); return(processor.ProcessQuery(this)); }
/// <summary> /// Serves the Dataset to the Client /// </summary> /// <param name="context">HTTP Context</param> /// <param name="dataset">Dataset to serve</param> /// <remarks> /// <para> /// Implementations should override this if they wish to override the default behaviour of outputting the entire dataset using the <see cref="HandlerHelper.SendToClient">HandlerHelper.SendToClient()</see> method e.g. to use a custom writer or server only portions of the dataset /// </para> /// </remarks> public virtual void SendDatasetToClient(HttpContext context, ISparqlDataset dataset) { try { HandlerHelper.SendToClient(context, dataset, this._config); } catch (RdfWriterSelectionException) { context.Response.StatusCode = (int)HttpStatusCode.NotAcceptable; } catch { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; } }
/// <summary> /// Creates a new Demand Dataset. /// </summary> /// <param name="dataset">Underlying Dataset.</param> public BaseDemandDataset(ISparqlDataset dataset) : base(dataset) { }
/// <summary> /// Creates a new wrapped dataset /// </summary> /// <param name="dataset">Dataset</param> public WrapperDataset(ISparqlDataset dataset) { if (dataset == null) throw new ArgumentNullException("dataset"); this._dataset = dataset; }
/// <summary> /// Creates a new SPARQL Update Evaluation Context /// </summary> /// <param name="data">SPARQL Dataset</param> public SparqlUpdateEvaluationContext(ISparqlDataset data) { this._data = data; }
public ExplainDataset(ISparqlDataset dataset) : base(dataset) { }
/// <summary> /// Creates a new Explain Query Processor with the desired Explanation Level. /// </summary> /// <param name="dataset">Dataset.</param> /// <param name="level">Explanation Level.</param> public ExplainQueryProcessor(ISparqlDataset dataset, ExplanationLevel level) : this(dataset) { _level = level; }
/// <summary> /// Creates a new SPARQL Update Evaluation Context. /// </summary> /// <param name="data">SPARQL Dataset.</param> /// <param name="processor">Query Processor for WHERE clauses.</param> public SparqlUpdateEvaluationContext(ISparqlDataset data, ISparqlQueryAlgebraProcessor <BaseMultiset, SparqlEvaluationContext> processor) : this(data) { QueryProcessor = processor; }
public BrightstarQueryProcessor(IStore store, ISparqlDataset data) : base(data) { //_store = store; }
/// <summary> /// Creates a new Explain Update Processor /// </summary> /// <param name="data">Dataset</param> public ExplainUpdateProcessor(ISparqlDataset data) : this(data, ExplanationLevel.Default) { }
/// <summary> /// Creates a new In-Memory Manager which is a wrapper around a SPARQL Dataset /// </summary> /// <param name="dataset">Dataset</param> public InMemoryManager(ISparqlDataset dataset) { this._dataset = dataset; }
/// <summary> /// Creates a new Explain Update Processor /// </summary> /// <param name="data">Dataset</param> /// <param name="level">Explanation Level</param> public ExplainUpdateProcessor(ISparqlDataset data, ExplanationLevel level) : base(data) { this._level = level; }
/// <summary> /// Creates a new Evaluation Context for the given Query over the given Dataset using a specific processor /// </summary> /// <param name="q">Query</param> /// <param name="data">Dataset</param> /// <param name="processor">Query Processor</param> public SparqlEvaluationContext(SparqlQuery q, ISparqlDataset data, ISparqlQueryAlgebraProcessor<BaseMultiset, SparqlEvaluationContext> processor) : this(q, data) { this._processor = processor; }
public BrightstarQueryProcessor(IStore store, ISparqlDataset data) : base(data) { _store = store; }
private void TestBindings(ISparqlDataset data, String queryWithBindings) { LeviathanQueryProcessor processor = new LeviathanQueryProcessor(data); SparqlQuery bindingsQuery = this._parser.ParseFromString(queryWithBindings); SparqlResultSet bindingsResults = processor.ProcessQuery(bindingsQuery) as SparqlResultSet; if (bindingsResults == null) Assert.Fail("Did not get a SPARQL Result Set for the Bindings Query"); Console.WriteLine("Bindings Results"); TestTools.ShowResults(bindingsResults); Console.WriteLine(); Assert.IsTrue(bindingsResults.IsEmpty, "Result Set should be empty"); }
/// <summary> /// Creates a new Demand Dataset /// </summary> /// <param name="dataset">Underlying Dataset</param> public BaseDemandDataset(ISparqlDataset dataset) : base(dataset) { }
/// <summary> /// Creates a new Explain Query Processor that will use the Default Explanation Level. /// </summary> /// <param name="dataset">Dataset.</param> public ExplainQueryProcessor(ISparqlDataset dataset) : this(new ExplainDataset(dataset)) { }
/// <summary> /// Creates a new Dataset Graph collection /// </summary> /// <param name="dataset">SPARQL Dataset</param> public DatasetGraphCollection(ISparqlDataset dataset) { this._dataset = dataset; }
/// <summary> /// Creates a new SPARQL Update Evaluation Context. /// </summary> /// <param name="commands">Command Set.</param> /// <param name="data">SPARQL Dataset.</param> public SparqlUpdateEvaluationContext(SparqlUpdateCommandSet commands, ISparqlDataset data) : this(data) { _commands = commands; }
/// <summary> /// Creates a new Explain Update Processor. /// </summary> /// <param name="data">Dataset.</param> public ExplainUpdateProcessor(ISparqlDataset data) : this(data, ExplanationLevel.Default) { }
/// <summary> /// Creates a new SPARQL Update Evaluation Context. /// </summary> /// <param name="data">SPARQL Dataset.</param> public SparqlUpdateEvaluationContext(ISparqlDataset data) { _data = data; }
/// <summary> /// Creates a new SPARQL Update Evaluation Context /// </summary> /// <param name="data">SPARQL Dataset</param> /// <param name="processor">Query Processor for WHERE clauses</param> public SparqlUpdateEvaluationContext(ISparqlDataset data, ISparqlQueryAlgebraProcessor<BaseMultiset, SparqlEvaluationContext> processor) : this(data) { this.QueryProcessor = processor; }