/// <summary>
 /// Creates a new <see cref="IDataObjectContext"/> instance that uses SPARQL query and update
 /// to access RDF data.
 /// </summary>
 /// <param name="queryProcessor">The SPARQL query processor to use for read/query </param>
 /// <param name="updateProcessor">The SPARQL update processor to use for update</param>
 /// <param name="optimisticLocking">Boolean flag indicating if optimistic locking should be enabled by default for the stores
 /// accessed via this context.</param>
 /// <param name="storeName">Overrides the default store name of 'sparql' for the store managed by this context</param>
 public SparqlDataObjectContext(ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor, bool optimisticLocking, string storeName = DefaultStoreName)
 {
     QueryProcessor = queryProcessor;
     UpdateProcessor = updateProcessor;
     OptimisticLockingEnabled = optimisticLocking;
     _storeName = storeName;
 }
 public SparqlDataObjectStore(
     ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor,
     Dictionary<string, string> namespaceMappings, bool optimisticLockingEnabled, 
     string updateGraphUri = null, IEnumerable<string> datasetGraphUris = null, string versionGraphUri = null) 
     : base(namespaceMappings, optimisticLockingEnabled, updateGraphUri, datasetGraphUris, versionGraphUri)
 {
     _client = new SparqlUpdatableStore(queryProcessor, updateProcessor);
 }
 /// <summary>
 /// Create a new instance of <see cref="DotNetRdfDataObjectContext"/>
 /// with a specific ISparqlQueryProcessor and ISparqlUpdateProcessor instance
 /// that serves up a single named store.
 /// </summary>
 /// <param name="storeName">The name of the store that will be provided by this context</param>
 /// <param name="queryProcessor">The ISparqlQueryProcessor instance that provides SPARQL query functionality for the store.</param>
 /// <param name="updateProcessor">The ISparqlUpdateProcessor instance that provides SPARQL update functionality for the store.</param>
 /// <exception cref="ArgumentException">Raised if <paramref name="storeName"/> is NULL or an empty string</exception>
 /// <exception cref="ArgumentNullException">Raised if <paramref name="queryProcessor"/> or <paramref name="updateProcessor"/> is NULL</exception>
 public DotNetRdfDataObjectContext(string storeName, ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor)
 {
     if (String.IsNullOrEmpty(storeName)) throw new ArgumentException(Strings.StringParameterMustBeNonEmpty, "storeName");
     if (queryProcessor == null) throw new ArgumentNullException("queryProcessor");
     if (updateProcessor == null) throw new ArgumentNullException("updateProcessor");
     _configuredStoreName = storeName;
     _queryProcessor = queryProcessor;
     _updateProcessor = updateProcessor;
 }
        /// <summary>
        /// Creates a new Base SPARQL Server Configuration based on information from a Configuration Graph
        /// </summary>
        /// <param name="context">HTTP Context</param>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        public BaseSparqlServerConfiguration(HttpContext context, IGraph g, INode objNode)
            : base(context, g, objNode)
        {
            //Get the Query Processor to be used
            INode procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryProcessor));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlQueryProcessor)
                {
                    this._queryProcessor = (ISparqlQueryProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:queryProcessor property which cannot be loaded as an object which implements the ISparqlQueryProcessor interface");
                }
            }

            //SPARQL Query Default Config
            this._defaultGraph = ConfigurationLoader.GetConfigurationValue(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultGraphUri)).ToSafeString();
            this._defaultTimeout = ConfigurationLoader.GetConfigurationInt64(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyTimeout), this._defaultTimeout);
            this._defaultPartialResults = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyPartialResults), this._defaultPartialResults);

            //Handler Configuration
            this._showQueryForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyShowQueryForm), this._showQueryForm);
            String defQueryFile = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultQueryFile));
            if (defQueryFile != null)
            {
                defQueryFile = ConfigurationLoader.ResolvePath(defQueryFile);
                if (File.Exists(defQueryFile))
                {
                    using (StreamReader reader = new StreamReader(defQueryFile))
                    {
                        this._defaultQuery = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            //Get Query Syntax to use
            try
            {
                String syntaxSetting = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertySyntax));
                if (syntaxSetting != null)
                {
                    this._syntax = (SparqlQuerySyntax)Enum.Parse(typeof(SparqlQuerySyntax), syntaxSetting);
                }
            }
            catch (Exception ex)
            {
                throw new DotNetRdfConfigurationException("Unable to set the Syntax for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:syntax property was not a valid value from the enum VDS.RDF.Parsing.SparqlQuerySyntax", ex);
            }

            //Get the SPARQL Describe Algorithm
            INode describeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDescribeAlgorithm));
            if (describeNode != null)
            {
                if (describeNode.NodeType == NodeType.Literal)
                {
                    String algoClass = ((ILiteralNode)describeNode).Value;
                    try
                    {
                        Object desc = Activator.CreateInstance(Type.GetType(algoClass));
                        if (desc is ISparqlDescribe)
                        {
                            this._describer = (ISparqlDescribe)desc;
                        }
                        else
                        {
                            throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name of a type that implements the ISparqlDescribe interface");
                        }
                    }
                    catch (DotNetRdfConfigurationException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name for a type that can be instantiated", ex);
                    }
                }
            }

            //Get the Query Optimiser
            INode queryOptNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryOptimiser));
            if (queryOptNode != null)
            {
                Object queryOpt = ConfigurationLoader.LoadObject(g, queryOptNode);
                if (queryOpt is IQueryOptimiser)
                {
                    this._queryOptimiser = (IQueryOptimiser)queryOpt;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Query Optimiser for the HTTP Handler identified by the Node '" + queryOptNode.ToString() + "' as the value given for the dnr:queryOptimiser property points to an Object which could not be loaded as an object which implements the required IQueryOptimiser interface");
                }
            }

            //Get the Algebra Optimisers
            foreach (INode algOptNode in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyAlgebraOptimiser)))
            {
                Object algOpt = ConfigurationLoader.LoadObject(g, algOptNode);
                if (algOpt is IAlgebraOptimiser)
                {
                    this._algebraOptimisers.Add((IAlgebraOptimiser)algOpt);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Algebra Optimiser for the HTTP Handler identified by the Node '" + algOptNode.ToString() + "' as the value given for the dnr:algebraOptimiser property points to an Object which could not be loaded as an object which implements the required IAlgebraOptimiser interface");
                }
            }

            //Then get the Update Processor to be used
            procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUpdateProcessor));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlUpdateProcessor)
                {
                    this._updateProcessor = (ISparqlUpdateProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:updateProcessor property which cannot be loaded as an object which implements the ISparqlUpdateProcessor interface");
                }
            }

            //Handler Settings
            this._showUpdateForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyShowUpdateForm), this._showUpdateForm);
            String defUpdateFile = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultUpdateFile));
            if (defUpdateFile != null)
            {
                defUpdateFile = ConfigurationLoader.ResolvePath(defUpdateFile);
                if (File.Exists(defUpdateFile))
                {
                    using (StreamReader reader = new StreamReader(defUpdateFile))
                    {
                        this._defaultUpdate = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            //Then get the Protocol Processor to be used
            procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyProtocolProcessor));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlHttpProtocolProcessor)
                {
                    this._protocolProcessor = (ISparqlHttpProtocolProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:protocolProcessor property which cannot be loaded as an object which implements the ISparqlHttpProtocolProcessor interface");
                }
            }

            if (this._queryProcessor == null && this._updateProcessor == null && this._protocolProcessor == null)
            {
                throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file does not specify at least one of a Query/Update/Protocol processor for the server using the dnr:queryProcessor/dnr:updateProcessor/dnr:protocolProcessor properties");
            }

            //Get the Service Description Graph
            INode descripNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServiceDescription));
            if (descripNode != null)
            {
                Object descrip = ConfigurationLoader.LoadObject(g, descripNode);
                if (descrip is IGraph)
                {
                    this._serviceDescription = (IGraph)descrip;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Service Description Graph for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:serviceDescription property points to an Object which could not be loaded as an object which implements the required IGraph interface");
                }
            }
        }
 public override void Process(ISparqlUpdateProcessor processor)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public SparqlUpdatableStore(ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor)
 {
     _queryProcessor = queryProcessor;
     _updateProcessor = updateProcessor;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Processes the Command using the given Update Processor
 /// </summary>
 /// <param name="processor">SPARQL Update Processor</param>
 public override void Process(ISparqlUpdateProcessor processor)
 {
     processor.ProcessInsertDataCommand(this);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Processes the Command Set using the given Update Processor
 /// </summary>
 /// <param name="processor">Update Processor</param>
 public void Process(ISparqlUpdateProcessor processor)
 {
     processor.ProcessCommandSet(this);
 }
Ejemplo n.º 9
0
 public SparqlUpdatableStore(ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor)
 {
     _queryProcessor  = queryProcessor;
     _updateProcessor = updateProcessor;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a new Base SPARQL Server Configuration based on information from a Configuration Graph
        /// </summary>
        /// <param name="context">HTTP Context</param>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        public BaseSparqlServerConfiguration(IHttpContext context, IGraph g, INode objNode)
            : base(context, g, objNode)
        {
            // Get the Query Processor to be used
            INode procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyQueryProcessor)));

            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlQueryProcessor)
                {
                    this._queryProcessor = (ISparqlQueryProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:queryProcessor property which cannot be loaded as an object which implements the ISparqlQueryProcessor interface");
                }
            }

            // SPARQL Query Default Config
            this._defaultGraph          = ConfigurationLoader.GetConfigurationValue(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyDefaultGraphUri)))?.ToString() ?? string.Empty;
            this._defaultTimeout        = ConfigurationLoader.GetConfigurationInt64(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyTimeout)), this._defaultTimeout);
            this._defaultPartialResults = ConfigurationLoader.GetConfigurationBoolean(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyPartialResults)), this._defaultPartialResults);

            // Handler Configuration
            this._showQueryForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyShowQueryForm)), this._showQueryForm);
            String defQueryFile = ConfigurationLoader.GetConfigurationString(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyDefaultQueryFile)));

            if (defQueryFile != null)
            {
                defQueryFile = ConfigurationLoader.ResolvePath(defQueryFile);
                if (File.Exists(defQueryFile))
                {
                    using (StreamReader reader = new StreamReader(defQueryFile))
                    {
                        this._defaultQuery = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            // Get Query Syntax to use
            try
            {
                String syntaxSetting = ConfigurationLoader.GetConfigurationString(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertySyntax)));
                if (syntaxSetting != null)
                {
                    this._syntax = (SparqlQuerySyntax)Enum.Parse(typeof(SparqlQuerySyntax), syntaxSetting);
                }
            }
            catch (Exception ex)
            {
                throw new DotNetRdfConfigurationException("Unable to set the Syntax for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:syntax property was not a valid value from the enum VDS.RDF.Parsing.SparqlQuerySyntax", ex);
            }

            // Get the SPARQL Describe Algorithm
            INode describeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyDescribeAlgorithm)));

            if (describeNode != null)
            {
                if (describeNode.NodeType == NodeType.Literal)
                {
                    String algoClass = ((ILiteralNode)describeNode).Value;
                    try
                    {
                        Object desc = Activator.CreateInstance(Type.GetType(algoClass));
                        if (desc is ISparqlDescribe)
                        {
                            this._describer = (ISparqlDescribe)desc;
                        }
                        else
                        {
                            throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name of a type that implements the ISparqlDescribe interface");
                        }
                    }
                    catch (DotNetRdfConfigurationException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name for a type that can be instantiated", ex);
                    }
                }
            }

            // Get the Query Optimiser
            INode queryOptNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyQueryOptimiser)));

            if (queryOptNode != null)
            {
                Object queryOpt = ConfigurationLoader.LoadObject(g, queryOptNode);
                if (queryOpt is IQueryOptimiser)
                {
                    this._queryOptimiser = (IQueryOptimiser)queryOpt;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Query Optimiser for the HTTP Handler identified by the Node '" + queryOptNode.ToString() + "' as the value given for the dnr:queryOptimiser property points to an Object which could not be loaded as an object which implements the required IQueryOptimiser interface");
                }
            }

            // Get the Algebra Optimisers
            foreach (INode algOptNode in ConfigurationLoader.GetConfigurationData(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyAlgebraOptimiser))))
            {
                Object algOpt = ConfigurationLoader.LoadObject(g, algOptNode);
                if (algOpt is IAlgebraOptimiser)
                {
                    this._algebraOptimisers.Add((IAlgebraOptimiser)algOpt);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Algebra Optimiser for the HTTP Handler identified by the Node '" + algOptNode.ToString() + "' as the value given for the dnr:algebraOptimiser property points to an Object which could not be loaded as an object which implements the required IAlgebraOptimiser interface");
                }
            }

            // Then get the Update Processor to be used
            procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyUpdateProcessor)));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlUpdateProcessor)
                {
                    this._updateProcessor = (ISparqlUpdateProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:updateProcessor property which cannot be loaded as an object which implements the ISparqlUpdateProcessor interface");
                }
            }

            // Handler Settings
            this._showUpdateForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyShowUpdateForm)), this._showUpdateForm);
            String defUpdateFile = ConfigurationLoader.GetConfigurationString(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyDefaultUpdateFile)));

            if (defUpdateFile != null)
            {
                defUpdateFile = ConfigurationLoader.ResolvePath(defUpdateFile);
                if (File.Exists(defUpdateFile))
                {
                    using (StreamReader reader = new StreamReader(defUpdateFile))
                    {
                        this._defaultUpdate = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            // Then get the Protocol Processor to be used
            procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyProtocolProcessor)));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlHttpProtocolProcessor)
                {
                    this._protocolProcessor = (ISparqlHttpProtocolProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:protocolProcessor property which cannot be loaded as an object which implements the ISparqlHttpProtocolProcessor interface");
                }
            }

            if (this._queryProcessor == null && this._updateProcessor == null && this._protocolProcessor == null)
            {
                throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file does not specify at least one of a Query/Update/Protocol processor for the server using the dnr:queryProcessor/dnr:updateProcessor/dnr:protocolProcessor properties");
            }

            // Get the Service Description Graph
            INode descripNode = ConfigurationLoader.GetConfigurationNode(g, objNode, g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyServiceDescription)));

            if (descripNode != null)
            {
                Object descrip = ConfigurationLoader.LoadObject(g, descripNode);
                if (descrip is IGraph)
                {
                    this._serviceDescription = (IGraph)descrip;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Service Description Graph for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:serviceDescription property points to an Object which could not be loaded as an object which implements the required IGraph interface");
                }
            }
        }
Ejemplo n.º 11
0
 private void RunUpdate(SparqlUpdateCommandSet cmds, ISparqlUpdateProcessor processor)
 {
     processor.ProcessCommandSet(cmds);
 }
        public DotNetRdfDataObjectContext(ConnectionString connectionString)
        {
            try
            {
                _configuration = LoadConfiguration(connectionString.Configuration);
            }
            catch (Exception ex)
            {
                throw new BrightstarClientException(
                    String.Format("Error loading DotNetRDF configuration from {0}.", connectionString.Configuration), ex);
            }
            _configuredStoreName = connectionString.StoreName;
            if (!String.IsNullOrEmpty(connectionString.DnrStore))
            {
                var configObject = GetConfigurationObject(connectionString.DnrStore);
                if (configObject is IUpdateableTripleStore)
                {
                    _updateProcessor = new SimpleUpdateProcessor(configObject as IUpdateableTripleStore);
                }
                else if (configObject is IInMemoryQueryableStore)
                {
                    _updateProcessor = new LeviathanUpdateProcessor(configObject as IInMemoryQueryableStore);
                }
                else if (configObject is IStorageProvider)
                {
                    _updateProcessor = new GenericUpdateProcessor(configObject as IStorageProvider);
                }
                else
                {
                    throw new BrightstarClientException(
                        "Could not create a SPARQL Update processor for the configured store.");
                }

                if (configObject is INativelyQueryableStore)
                {
                    _queryProcessor = new SimpleQueryProcessor(configObject as INativelyQueryableStore);
                }
                else if (configObject is IInMemoryQueryableStore)
                {
                    _queryProcessor = new LeviathanQueryProcessor(configObject as IInMemoryQueryableStore);
                }
                else if (configObject is IQueryableStorage)
                {
                    _queryProcessor = new GenericQueryProcessor(configObject as IQueryableStorage);
                }
                else
                {
                    throw new BrightstarClientException(
                        "Could not create a SPARQL Query processor for the configured store.");
                }
            }
            else
            {
                if (String.IsNullOrEmpty(connectionString.DnrQuery) ||
                    String.IsNullOrEmpty(connectionString.DnrUpdate))
                {
                    throw new BrightstarClientException("DotNetRDF connection requires either a Store property or a Query and an Update property.");
                }

                _queryProcessor = GetConfigurationObject(connectionString.DnrQuery) as ISparqlQueryProcessor;
                if (_queryProcessor == null)
                {
                    throw new BrightstarClientException("Could not create a SPARQL Query processor from the configured Query property.");
                }
                _updateProcessor = GetConfigurationObject(connectionString.DnrUpdate) as ISparqlUpdateProcessor;
                if (_updateProcessor == null)
                {
                    throw new BrightstarClientException("Could not create a SPARQL Update processor from the configured Update property.");
                }
            }
        }
        public DotNetRdfDataObjectContext(ConnectionString connectionString)
        {
            try
            {
                _configuration = LoadConfiguration(connectionString.Configuration);
            }
            catch (Exception ex)
            {
                throw new BrightstarClientException(
                          String.Format("Error loading DotNetRDF configuration from {0}.", connectionString.Configuration), ex);
            }
            _configuredStoreName = connectionString.StoreName;
            if (!String.IsNullOrEmpty(connectionString.DnrStore))
            {
                var configObject = GetConfigurationObject(connectionString.DnrStore);
                if (configObject is IUpdateableTripleStore)
                {
                    _updateProcessor = new SimpleUpdateProcessor(configObject as IUpdateableTripleStore);
                }
                else if (configObject is IInMemoryQueryableStore)
                {
                    _updateProcessor = new LeviathanUpdateProcessor(configObject as IInMemoryQueryableStore);
                }
                else if (configObject is IStorageProvider)
                {
                    _updateProcessor = new GenericUpdateProcessor(configObject as IStorageProvider);
                }
                else
                {
                    throw new BrightstarClientException(
                              "Could not create a SPARQL Update processor for the configured store.");
                }

                if (configObject is INativelyQueryableStore)
                {
                    _queryProcessor = new SimpleQueryProcessor(configObject as INativelyQueryableStore);
                }
                else if (configObject is IInMemoryQueryableStore)
                {
                    _queryProcessor = new LeviathanQueryProcessor(configObject as IInMemoryQueryableStore);
                }
                else if (configObject is IQueryableStorage)
                {
                    _queryProcessor = new GenericQueryProcessor(configObject as IQueryableStorage);
                }
                else
                {
                    throw new BrightstarClientException(
                              "Could not create a SPARQL Query processor for the configured store.");
                }
            }
            else
            {
                if (String.IsNullOrEmpty(connectionString.DnrQuery) ||
                    String.IsNullOrEmpty(connectionString.DnrUpdate))
                {
                    throw new BrightstarClientException("DotNetRDF connection requires either a Store property or a Query and an Update property.");
                }

                var queryObject = GetConfigurationObject(connectionString.DnrQuery);
                if (queryObject == null)
                {
                    throw new BrightstarClientException("The configured Query property of the connection string could not be resolved.");
                }
                if (queryObject is ISparqlQueryProcessor)
                {
                    _queryProcessor = queryObject as ISparqlQueryProcessor;
                }
                else if (queryObject is SparqlRemoteEndpoint)
                {
                    _queryProcessor = new RemoteQueryProcessor(queryObject as SparqlRemoteEndpoint);
                }
                else
                {
                    throw new BrightstarClientException(
                              String.Format("Could not create a SPARQL Query processor from the configured Query property. Expected instance of {0} or {1}. Got an instance of {2}",
                                            typeof(ISparqlQueryProcessor).FullName, typeof(SparqlRemoteEndpoint).FullName, queryObject.GetType().FullName));
                }

                var updateObject = GetConfigurationObject(connectionString.DnrUpdate);
                if (updateObject == null)
                {
                    throw new BrightstarClientException("The configured Update property of the connection string could not be resolved.");
                }
                if (updateObject is ISparqlUpdateProcessor)
                {
                    _updateProcessor = queryObject as ISparqlUpdateProcessor;
                }
#if !WINDOWS_PHONE && !PORTABLE
                else if (updateObject is SparqlRemoteUpdateEndpoint)
                {
                    _updateProcessor = new RemoteUpdateProcessor(updateObject as SparqlRemoteUpdateEndpoint);
                }
#endif
                else
                {
                    throw new BrightstarClientException(
                              String.Format("Could not create a SPARQL Update processor from the configured Update property. Expected instance of {0} or {1}. Got an instance of {2}",
                                            typeof(ISparqlUpdateProcessor).FullName, typeof(SparqlRemoteUpdateEndpoint).FullName, updateObject.GetType().FullName));
                }
            }
        }
 /// <summary>
 /// Creates a new Protocol to Update Processor
 /// </summary>
 /// <param name="queryProcessor">Query Processor</param>
 /// <param name="updateProcessor">Update Processor</param>
 public ProtocolToUpdateProcessor(ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor)
 {
     this._queryProcessor = queryProcessor;
     this._updateProcessor = updateProcessor;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Processes the Command using the given Update Processor
 /// </summary>
 /// <param name="processor">SPARQL Update Processor</param>
 public override void Process(ISparqlUpdateProcessor processor)
 {
     processor.ProcessInsertDataCommand(this);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a new LINQ Triple Store that operates over a given pair of SPARQL Processors
 /// </summary>
 /// <param name="queryProcessor">Query Processor</param>
 /// <param name="updateProcessor">Update Processor</param>
 public LinqTripleStore(ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor)
     : this(new LinqQueryProcessor(queryProcessor), new LinqUpdateProcessor(updateProcessor), LinqQueryMethod.CustomSparql) { }
Ejemplo n.º 17
0
 /// <summary>
 /// Processes the Command using the given Update Processor
 /// </summary>
 /// <param name="processor">SPARQL Update Processor</param>
 public override void Process(ISparqlUpdateProcessor processor)
 {
     processor.ProcessMoveCommand(this);
 }
        /// <summary>
        /// Creates a new Update Handler Configuration
        /// </summary>
        /// <param name="context">HTTP Context</param>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        public BaseUpdateHandlerConfiguration(HttpContext context, IGraph g, INode objNode)
            : base(context, g, objNode)
        {
            //Then get the Update Processor to be used
            ISparqlUpdateProcessor processor;
            INode procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUpdateProcessor));
            if (procNode == null) throw new DotNetRdfConfigurationException("Unable to load Update Handler Configuration as the RDF configuration file does not specify a dnr:updateProcessor property for the Handler");
            Object temp = ConfigurationLoader.LoadObject(g, procNode);
            if (temp is ISparqlUpdateProcessor)
            {
                processor = (ISparqlUpdateProcessor)temp;
            }
            else
            {
                throw new DotNetRdfConfigurationException("Unable to load Update Handler Configuration as the RDF configuration file specifies a value for the Handlers dnr:updateProcessor property which cannot be loaded as an object which implements the ISparqlUpdateProcessor interface");
            }
            this._processor = processor;

            //Handler Settings
            this._showUpdateForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyShowUpdateForm), this._showUpdateForm);
            String defUpdateFile = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultUpdateFile));
            if (defUpdateFile != null)
            {
                defUpdateFile = ConfigurationLoader.ResolvePath(defUpdateFile);
                if (File.Exists(defUpdateFile))
                {
                    using (StreamReader reader = new StreamReader(defUpdateFile))
                    {
                        this._defaultUpdate = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            //Get the Service Description Graph
            INode descripNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServiceDescription));
            if (descripNode != null)
            {
                Object descrip = ConfigurationLoader.LoadObject(g, descripNode);
                if (descrip is IGraph)
                {
                    this._serviceDescription = (IGraph)descrip;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Service Description Graph for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:serviceDescription property points to an Object which could not be loaded as an object which implements the required IGraph interface");
                }
            }
        }
 /// <summary>
 /// Creates a new Protocol to Update Processor.
 /// </summary>
 /// <param name="queryProcessor">Query Processor.</param>
 /// <param name="updateProcessor">Update Processor.</param>
 public ProtocolToUpdateProcessor(ISparqlQueryProcessor queryProcessor, ISparqlUpdateProcessor updateProcessor)
 {
     _queryProcessor  = queryProcessor;
     _updateProcessor = updateProcessor;
 }
Ejemplo n.º 20
0
 private void RunUpdate(SparqlUpdateCommandSet cmds, ISparqlUpdateProcessor processor)
 {
     processor.ProcessCommandSet(cmds);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Processes the Command Set using the given Update Processor.
 /// </summary>
 /// <param name="processor">Update Processor.</param>
 public abstract void Process(ISparqlUpdateProcessor processor);
        public DotNetRdfDataObjectContext(ConnectionString connectionString)
        {
            try
            {
                _configuration = LoadConfiguration(connectionString.Configuration);
            }
            catch (Exception ex)
            {
                throw new BrightstarClientException(
                    String.Format("Error loading DotNetRDF configuration from {0}.", connectionString.Configuration), ex);
            }
            _configuredStoreName = connectionString.StoreName;
            if (!String.IsNullOrEmpty(connectionString.DnrStore))
            {
                var configObject = GetConfigurationObject(connectionString.DnrStore);
                if (configObject is IUpdateableTripleStore)
                {
                    _updateProcessor = new SimpleUpdateProcessor(configObject as IUpdateableTripleStore);
                }
                else if (configObject is IInMemoryQueryableStore)
                {
                    _updateProcessor = new LeviathanUpdateProcessor(configObject as IInMemoryQueryableStore);
                }
                else if (configObject is IStorageProvider)
                {
                    _updateProcessor = new GenericUpdateProcessor(configObject as IStorageProvider);
                }
                else
                {
                    throw new BrightstarClientException(
                        "Could not create a SPARQL Update processor for the configured store.");
                }

                if (configObject is INativelyQueryableStore)
                {
                    _queryProcessor = new SimpleQueryProcessor(configObject as INativelyQueryableStore);
                }
                else if (configObject is IInMemoryQueryableStore)
                {
                    _queryProcessor = new LeviathanQueryProcessor(configObject as IInMemoryQueryableStore);
                }
                else if (configObject is IQueryableStorage)
                {
                    _queryProcessor = new GenericQueryProcessor(configObject as IQueryableStorage);
                }
                else
                {
                    throw new BrightstarClientException(
                        "Could not create a SPARQL Query processor for the configured store.");
                }
            }
            else
            {
                if (String.IsNullOrEmpty(connectionString.DnrQuery) ||
                    String.IsNullOrEmpty(connectionString.DnrUpdate))
                {
                    throw new BrightstarClientException("DotNetRDF connection requires either a Store property or a Query and an Update property.");
                }

                var queryObject = GetConfigurationObject(connectionString.DnrQuery);
                if (queryObject == null)
                {
                    throw new BrightstarClientException("The configured Query property of the connection string could not be resolved.");
                }
                if (queryObject is ISparqlQueryProcessor)
                {
                    _queryProcessor = queryObject as ISparqlQueryProcessor;
                }
                else if (queryObject is SparqlRemoteEndpoint)
                {
                    _queryProcessor = new RemoteQueryProcessor(queryObject as SparqlRemoteEndpoint);
                }
                else
                {
                    throw new BrightstarClientException(
                        String.Format("Could not create a SPARQL Query processor from the configured Query property. Expected instance of {0} or {1}. Got an instance of {2}",
                        typeof(ISparqlQueryProcessor).FullName, typeof(SparqlRemoteEndpoint).FullName, queryObject.GetType().FullName));
                }

                var updateObject = GetConfigurationObject(connectionString.DnrUpdate);
                if (updateObject == null)
                {
                    throw new BrightstarClientException("The configured Update property of the connection string could not be resolved.");
                }
                if (updateObject is ISparqlUpdateProcessor)
                {
                    _updateProcessor = queryObject as ISparqlUpdateProcessor;
                }
#if !WINDOWS_PHONE && !PORTABLE
                else if (updateObject is SparqlRemoteUpdateEndpoint)
                {
                    _updateProcessor = new RemoteUpdateProcessor(updateObject as SparqlRemoteUpdateEndpoint);
                }
#endif
                else
                {
                    throw new BrightstarClientException(
                        String.Format("Could not create a SPARQL Update processor from the configured Update property. Expected instance of {0} or {1}. Got an instance of {2}",
                        typeof(ISparqlUpdateProcessor).FullName, typeof(SparqlRemoteUpdateEndpoint).FullName, updateObject.GetType().FullName));
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Tries to load a SPARQL Update based on information from the Configuration Graph
        /// </summary>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        /// <param name="targetType">Target Type</param>
        /// <param name="obj">Output Object</param>
        /// <returns></returns>
        public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj)
        {
            obj = null;
            ISparqlUpdateProcessor processor = null;
            INode  storeObj;
            Object temp;

            switch (targetType.FullName)
            {
            case LeviathanUpdateProcessor:
                INode datasetObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingDataset));
                if (datasetObj != null)
                {
                    temp = ConfigurationLoader.LoadObject(g, datasetObj);
                    if (temp is ISparqlDataset)
                    {
                        processor = new LeviathanUpdateProcessor((ISparqlDataset)temp);
                    }
                    else
                    {
                        throw new DotNetRdfConfigurationException("Unable to load the Leviathan Update Processor identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingDataset property points to an Object that cannot be loaded as an object which implements the ISparqlDataset interface");
                    }
                }
                else
                {
                    storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingStore));
                    if (storeObj == null)
                    {
                        return(false);
                    }
                    temp = ConfigurationLoader.LoadObject(g, storeObj);
                    if (temp is IInMemoryQueryableStore)
                    {
                        processor = new LeviathanUpdateProcessor((IInMemoryQueryableStore)temp);
                    }
                    else
                    {
                        throw new DotNetRdfConfigurationException("Unable to load the Leviathan Update Processor identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingStore property points to an Object that cannot be loaded as an object which implements the IInMemoryQueryableStore interface");
                    }
                }
                break;

            case SimpleUpdateProcessor:
                storeObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUsingStore));
                if (storeObj == null)
                {
                    return(false);
                }
                temp = ConfigurationLoader.LoadObject(g, storeObj);
                if (temp is IUpdateableTripleStore)
                {
                    processor = new SimpleUpdateProcessor((IUpdateableTripleStore)temp);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load the Simple Update Processor identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:usingStore property points to an Object that cannot be loaded as an object which implements the IUpdateableTripleStore interface");
                }
                break;

            case GenericUpdateProcessor:
                INode managerObj = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyGenericManager));
                if (managerObj == null)
                {
                    return(false);
                }
                temp = ConfigurationLoader.LoadObject(g, managerObj);
                if (temp is IGenericIOManager)
                {
                    processor = new GenericUpdateProcessor((IGenericIOManager)temp);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load the Generic Update Processor identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:genericManager property points to an Object that cannot be loaded as an object which implements the IGenericIOManager interface");
                }

                break;
            }

            obj = processor;
            return(processor != null);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Processes the Command Set using the given Update Processor
 /// </summary>
 /// <param name="processor">Update Processor</param>
 public abstract void Process(ISparqlUpdateProcessor processor);
Ejemplo n.º 25
0
 public LinqUpdateProcessor(ISparqlUpdateProcessor processor)
 {
     this._underlyingProcessor = processor;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Processes the Command using the given Update Processor
 /// </summary>
 /// <param name="processor">SPARQL Update Processor</param>
 public override void Process(ISparqlUpdateProcessor processor)
 {
     processor.ProcessLoadCommand(this);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Processes the Command Set using the given Update Processor
 /// </summary>
 /// <param name="processor">Update Processor</param>
 public void Process(ISparqlUpdateProcessor processor)
 {
     processor.ProcessCommandSet(this);
 }