コード例 #1
0
        public void SparqlRemoteEndpointLongUpdate()
        {
            try
            {
                Options.HttpDebugging = true;

                StringBuilder input = new StringBuilder();
                input.AppendLine("LOAD <http://dbpedia.org/resource/Ilkeston>");
                input.AppendLine(new String('#', 2048));

                SparqlRemoteUpdateEndpoint endpoint = new SparqlRemoteUpdateEndpoint(new Uri(TestUpdateUri));
                endpoint.Update(input.ToString());
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
コード例 #2
0
 /// <summary>
 /// Creates a new Remote Update Processor
 /// </summary>
 /// <param name="endpoint">SPARQL Remote Update Endpoint</param>
 public RemoteUpdateProcessor(SparqlRemoteUpdateEndpoint endpoint)
 {
     this._endpoint = endpoint;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: jbunzel/MvcRQ_git
        static void DoUpdate(Dictionary<String, String> arguments)
        {
            SparqlRemoteUpdateEndpoint endpoint;
            bool verbose = arguments.ContainsKey("verbose") || arguments.ContainsKey("v");
            if (verbose) Options.HttpDebugging = true;

            //First get the Server to which we are going to connect
            try
            {
                if (arguments.ContainsKey("server") && !arguments["server"].Equals(String.Empty))
                {
                    endpoint = new SparqlRemoteUpdateEndpoint(new Uri(arguments["server"]));
                }
                else if (arguments.ContainsKey("service") && !arguments["service"].Equals(String.Empty))
                {
                    endpoint = new SparqlRemoteUpdateEndpoint(new Uri(arguments["service"]));
                }
                else
                {
                    Console.Error.WriteLine("soh: Error: Required --server/--service argument not present");
                    Environment.Exit(-1);
                    return;
                }
            }
            catch (UriFormatException uriEx)
            {
                Console.Error.WriteLine("soh: Error: Malformed SPARQL Update Endpoint URI");
                Console.Error.WriteLine(uriEx.Message);
                Environment.Exit(-1);
                return;
            }
            if (verbose) Console.Error.WriteLine("soh: SPARQL Update Endpoint for URI " + endpoint.Uri + " created OK");

            //Then decide where to get the update to execute from
            SparqlUpdateParser parser = new SparqlUpdateParser();
            SparqlUpdateCommandSet cmds;
            try
            {
                if (arguments.ContainsKey("update") && !arguments["update"].Equals(String.Empty))
                {
                    cmds = parser.ParseFromFile(arguments["update"]);
                }
                else if (arguments.ContainsKey("file") && !arguments["file"].Equals(String.Empty))
                {
                    cmds = parser.ParseFromFile(arguments["file"]);
                }
                else if (arguments.ContainsKey("$1") && !arguments["$1"].Equals(String.Empty))
                {
                    cmds = parser.ParseFromString(arguments["$1"]);
                }
                else
                {
                    Console.Error.WriteLine("soh: Error: Required SPARQL Update not found - may be specified as --file/--update FILE or as final argument");
                    Environment.Exit(-1);
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("soh: Error: Error Parsing SPARQL Update");
                Console.Error.WriteLine(ex.Message);
                Environment.Exit(-1);
                return;
            }

            if (verbose)
            {
                Console.Error.WriteLine("soh: Parsed Update OK");
                Console.Error.WriteLine("soh: dotNetRDF's interpretation of the Update:");
                Console.Error.WriteLine(cmds.ToString());
                Console.Error.WriteLine("soh: Submitting Update");
            }

            try
            {
                endpoint.Update(cmds.ToString());
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("soh: Error: Error while making the SPARQL Update");
                Console.Error.WriteLine(ex.Message);
                Environment.Exit(-1);
                return;
            }
        }
コード例 #4
0
ファイル: LinqTripleStore.cs プロジェクト: jbunzel/MvcRQ_git
 /// <summary>
 /// Creates a new LINQ Triple Store that operates over a pair of remote SPARQL endpoints
 /// </summary>
 /// <param name="queryEndpoint">Query Endpoint</param>
 /// <param name="updateEndpoint">Update Endpoint</param>
 public LinqTripleStore(SparqlRemoteEndpoint queryEndpoint, SparqlRemoteUpdateEndpoint updateEndpoint)
     : this(new LinqQueryProcessor(queryEndpoint), new LinqUpdateProcessor(updateEndpoint), LinqQueryMethod.RemoteSparql) { }
コード例 #5
0
        private static IDataObjectContext MakeSparqlDataObjectContext(ConnectionString connectionString)
        {
            var queryEndpoint = new SparqlRemoteEndpoint(new Uri(connectionString.DnrQuery));
            if (!String.IsNullOrEmpty(connectionString.UserName) && !String.IsNullOrEmpty(connectionString.Password))
            {
                queryEndpoint.SetCredentials(connectionString.UserName, connectionString.Password);
            }
            var queryProcessor = new RemoteQueryProcessor(queryEndpoint);

            ISparqlUpdateProcessor updateProcessor = null;
            if (!String.IsNullOrEmpty(connectionString.DnrUpdate))
            {
#if PORTABLE || SILVERLIGHT
                throw new NotSupportedException("The PCL and mobile builds of BrightstarDB do not currently support stores that use SPARQL Update. The store may be opened as a read-only store by removing the update= parameter in the connection string.");
#else
                var updateEndpoint = new SparqlRemoteUpdateEndpoint(new Uri(connectionString.DnrUpdate));
                if (!String.IsNullOrEmpty(connectionString.UserName) && !String.IsNullOrEmpty(connectionString.Password))
                {
                    updateEndpoint.SetCredentials(connectionString.UserName, connectionString.Password);
                }
                updateProcessor = new RemoteUpdateProcessor(updateEndpoint);
#endif
            }
            return new SparqlDataObjectContext(queryProcessor, updateProcessor, connectionString.OptimisticLocking);
        }
コード例 #6
0
        /// <summary>
        /// Creates a new 4store connector which manages access to the services provided by a 4store server
        /// </summary>
        /// <param name="baseUri">Base Uri of the 4store</param>
        /// <remarks>
        /// <strong>Note:</strong> As of the 0.4.0 release 4store support defaults to Triple Level updates enabled as all recent 4store releases have supported this.  You can still optionally disable this with the two argument version of the constructor
        /// </remarks>
        public FourStoreConnector(String baseUri)
        {
            //Determine the appropriate actual Base Uri
            if (baseUri.EndsWith("sparql/"))
            {
                this._baseUri = baseUri.Substring(0, baseUri.IndexOf("sparql/"));
            }
            else if (baseUri.EndsWith("data/"))
            {
                this._baseUri = baseUri.Substring(0, baseUri.IndexOf("data/"));
            }
            else if (!baseUri.EndsWith("/"))
            {
                this._baseUri = baseUri + "/";
            }
            else
            {
                this._baseUri = baseUri;
            }

            this._endpoint = new SparqlRemoteEndpoint(new Uri(this._baseUri + "sparql/"));
            this._updateEndpoint = new SparqlRemoteUpdateEndpoint(new Uri(this._baseUri + "update/"));
            this._endpoint.Timeout = 60000;
            this._updateEndpoint.Timeout = 60000;
        }
コード例 #7
0
 public LinqUpdateProcessor(SparqlRemoteUpdateEndpoint endpoint)
     : this(new RemoteUpdateProcessor(endpoint)) { }
コード例 #8
0
 /// <summary>
 /// Creates a new Remote Update Processor
 /// </summary>
 /// <param name="endpoint">SPARQL Remote Update Endpoint</param>
 public RemoteUpdateProcessor(SparqlRemoteUpdateEndpoint endpoint)
 {
     this._endpoint = endpoint;
 }