public override void ProcessCommand(SparqlUpdateCommand cmd)
 {
     if (cmd is ClearCommand)
     {
         ProcessClearCommand(cmd as ClearCommand);
     }
     else if (cmd is CopyCommand)
     {
         ProcessCopyCommand(cmd as CopyCommand);
     }
     else if (cmd is MoveCommand)
     {
         ProcessMoveCommand(cmd as MoveCommand);
     }
     else if (cmd is AddCommand)
     {
         ProcessAddCommand(cmd as AddCommand);
     }
     else
     {
         base.ProcessCommand(cmd);
     }
 }
 /// <summary>
 /// Adds a new Command to the end of the sequence of Commands.
 /// </summary>
 /// <param name="command">Command to add.</param>
 internal void AddCommand(SparqlUpdateCommand command)
 {
     _commands.Add(command);
 }
 /// <summary>
 /// Creates a new Command Set containing the given Command.
 /// </summary>
 /// <param name="command">Command.</param>
 public SparqlUpdateCommandSet(SparqlUpdateCommand command)
 {
     _commands.Add(command);
 }
Esempio n. 4
0
        /// <summary>
        /// Processes a command.
        /// </summary>
        /// <param name="cmd">Command.</param>
        /// <param name="context">SPARQL Update Evaluation Context.</param>
        /// <remarks>
        /// Invokes the type specific method for the command type.
        /// </remarks>
        private void ProcessCommandInternal(SparqlUpdateCommand cmd, SparqlUpdateEvaluationContext context)
        {
            // If auto-committing then Flush() any existing Transaction first
            if (_autoCommit)
            {
                Flush();
            }

            // Then if possible attempt to get the lock and determine whether it needs releasing
            ReaderWriterLockSlim currLock = (_dataset is IThreadSafeDataset) ? ((IThreadSafeDataset)_dataset).Lock : _lock;
            bool mustRelease = false;

            try
            {
                if (!currLock.IsWriteLockHeld)
                {
                    currLock.EnterWriteLock();
                    mustRelease = true;
                }

                // Then based on the command type call the appropriate protected method
                switch (cmd.CommandType)
                {
                case SparqlUpdateCommandType.Add:
                    ProcessAddCommandInternal((AddCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Clear:
                    ProcessClearCommandInternal((ClearCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Copy:
                    ProcessCopyCommandInternal((CopyCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Create:
                    ProcessCreateCommandInternal((CreateCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Delete:
                    ProcessDeleteCommandInternal((DeleteCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.DeleteData:
                    ProcessDeleteDataCommandInternal((DeleteDataCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Drop:
                    ProcessDropCommandInternal((DropCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Insert:
                    ProcessInsertCommandInternal((InsertCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.InsertData:
                    ProcessInsertDataCommandInternal((InsertDataCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Load:
                    ProcessLoadCommandInternal((LoadCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Modify:
                    ProcessModifyCommandInternal((ModifyCommand)cmd, context);
                    break;

                case SparqlUpdateCommandType.Move:
                    ProcessMoveCommandInternal((MoveCommand)cmd, context);
                    break;

                default:
                    throw new SparqlUpdateException("Unknown Update Commands cannot be processed by the Leviathan Update Processor");
                }

                // If auto-committing flush after every command
                if (_autoCommit)
                {
                    Flush();
                }
            }
            catch
            {
                // If auto-committing discard if an error occurs, if not then mark the transaction as uncomittable
                if (_autoCommit)
                {
                    Discard();
                }
                else
                {
                    _canCommit = false;
                }
                throw;
            }
            finally
            {
                // Release locks if necessary
                if (mustRelease)
                {
                    currLock.ExitWriteLock();
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Processes a command.
 /// </summary>
 /// <param name="cmd">Command.</param>
 public void ProcessCommand(SparqlUpdateCommand cmd)
 {
     ProcessCommandInternal(cmd, GetContext());
 }
Esempio n. 6
0
 /// <summary>
 /// Processes a command
 /// </summary>
 /// <param name="cmd">Command</param>
 public void ProcessCommand(SparqlUpdateCommand cmd)
 {
     this._endpoint.Update(cmd.ToString());
 }
Esempio n. 7
0
 /// <summary>
 /// Processes a command
 /// </summary>
 /// <param name="cmd">Command</param>
 public void ProcessCommand(SparqlUpdateCommand cmd)
 {
     this.ProcessCommandInternal(cmd, this.GetContext());
 }
 /// <inheritdoc />
 public new void ExecuteUpdate(SparqlUpdateCommand update)
 {
     ((IUpdateableTripleStore)this).ExecuteUpdate(update);
 }
 /// <inheritdoc />
 void IUpdateableTripleStore.ExecuteUpdate(SparqlUpdateCommand update)
 {
     ((IUpdateableTripleStore)this).ExecuteUpdate(new SparqlUpdateCommandSet(update));
 }
Esempio n. 10
0
 /// <summary>
 /// Processes a command
 /// </summary>
 /// <param name="cmd">Command</param>
 /// <remarks>
 /// <para>
 /// If the provided manager also implements the <see cref="IUpdateableGenericIOManager">IUpdateableGenericIOManager</see> interface then the managers native SPARQL Update implementation will be used.
 /// </para>
 /// </remarks>
 public virtual void ProcessCommand(SparqlUpdateCommand cmd)
 {
     if (this._manager is IUpdateableGenericIOManager)
     {
         ((IUpdateableGenericIOManager)this._manager).Update(cmd.ToString());
     }
     else
     {
         switch (cmd.CommandType)
         {
             case SparqlUpdateCommandType.Add:
                 this.ProcessAddCommand((AddCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Clear:
                 this.ProcessClearCommand((ClearCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Copy:
                 this.ProcessCopyCommand((CopyCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Create:
                 this.ProcessCreateCommand((CreateCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Delete:
                 this.ProcessDeleteCommand((DeleteCommand)cmd);
                 break;
             case SparqlUpdateCommandType.DeleteData:
                 this.ProcessDeleteDataCommand((DeleteDataCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Drop:
                 this.ProcessDropCommand((DropCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Insert:
                 this.ProcessInsertCommand((InsertCommand)cmd);
                 break;
             case SparqlUpdateCommandType.InsertData:
                 this.ProcessInsertDataCommand((InsertDataCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Load:
                 this.ProcessLoadCommand((LoadCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Modify:
                 this.ProcessModifyCommand((ModifyCommand)cmd);
                 break;
             case SparqlUpdateCommandType.Move:
                 this.ProcessMoveCommand((MoveCommand)cmd);
                 break;
             default:
                 throw new SparqlUpdateException("Unknown Update Commands cannot be processed by the Generic Update Processor");
         }
     }
 }
 /// <summary>
 /// Processes a command
 /// </summary>
 /// <param name="cmd">Command</param>
 public void ProcessCommand(SparqlUpdateCommand cmd)
 {
     this._store.ExecuteUpdate(cmd);
 }
 /// <summary>
 /// Executes a SPARQL Update on the Store
 /// </summary>
 /// <param name="update">SPARQL Update Command</param>
 /// <remarks>
 /// <para>
 /// If the underlying Manager is an <see cref="IUpdateableGenericIOManager">IUpdateableGenericIOManager</see> then the managers own Update implementation will be used, otherwise dotNetRDF's approximated implementation for generic stores will be used.  In the case of approximation exact feature support will vary depending on the underlying manager being used.
 /// </para>
 /// </remarks>
 public void ExecuteUpdate(SparqlUpdateCommand update)
 {
     GenericUpdateProcessor processor = new GenericUpdateProcessor(this._manager);
     processor.ProcessCommand(update);
 }
 /// <summary>
 /// Executes a SPARQL Update on the Virtuoso store
 /// </summary>
 /// <param name="update">SPARQL Update</param>
 /// <remarks>
 /// <para>
 /// <strong>Warning:</strong> In rare cases we have been able to crash Virtuoso by issuing malformed Sparql Update commands to it, this appears to be an issue with Virtuoso.
 /// </para>
 /// </remarks>
 public void ExecuteUpdate(SparqlUpdateCommand update)
 {
     this._manager.Update(update.ToString());
 }
Esempio n. 14
0
        /// <summary>
        /// Processes a command
        /// </summary>
        /// <param name="cmd">Command</param>
        /// <param name="context">SPARQL Update Evaluation Context</param>
        /// <remarks>
        /// Invokes the type specific method for the command type
        /// </remarks>
        private void ProcessCommandInternal(SparqlUpdateCommand cmd, SparqlUpdateEvaluationContext context)
        {
            //If auto-committing then Flush() any existing Transaction first
            if (this._autoCommit) this.Flush();

            //Then if possible attempt to get the lock and determine whether it needs releasing
            #if !NO_RWLOCK
            ReaderWriterLockSlim currLock = (this._dataset is IThreadSafeDataset) ? ((IThreadSafeDataset)this._dataset).Lock : this._lock;
            #endif
            bool mustRelease = false;
            try
            {
            #if !NO_RWLOCK
                if (!currLock.IsWriteLockHeld)
                {
                    currLock.EnterWriteLock();
                    mustRelease = true;
                }
            #else
                //If ReaderWriteLockSlim is not available use a Monitor instead
                Monitor.Enter(this._dataset);
                mustRelease = true;
            #endif

                //Then based on the command type call the appropriate protected method
                switch (cmd.CommandType)
                {
                    case SparqlUpdateCommandType.Add:
                        this.ProcessAddCommandInternal((AddCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Clear:
                        this.ProcessClearCommandInternal((ClearCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Copy:
                        this.ProcessCopyCommandInternal((CopyCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Create:
                        this.ProcessCreateCommandInternal((CreateCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Delete:
                        this.ProcessDeleteCommandInternal((DeleteCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.DeleteData:
                        this.ProcessDeleteDataCommandInternal((DeleteDataCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Drop:
                        this.ProcessDropCommandInternal((DropCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Insert:
                        this.ProcessInsertCommandInternal((InsertCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.InsertData:
                        this.ProcessInsertDataCommandInternal((InsertDataCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Load:
                        this.ProcessLoadCommandInternal((LoadCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Modify:
                        this.ProcessModifyCommandInternal((ModifyCommand)cmd, context);
                        break;
                    case SparqlUpdateCommandType.Move:
                        this.ProcessMoveCommandInternal((MoveCommand)cmd, context);
                        break;
                    default:
                        throw new SparqlUpdateException("Unknown Update Commands cannot be processed by the Leviathan Update Processor");
                }

                //If auto-committing flush after every command
                if (this._autoCommit) this.Flush();
            }
            catch
            {
                //If auto-committing discard if an error occurs, if not then mark the transaction as uncomittable
                if (this._autoCommit)
                {
                    this.Discard();
                }
                else
                {
                    this._canCommit = false;
                }
                throw;
            }
            finally
            {
                //Release locks if necessary
                if (mustRelease)
                {
            #if !NO_RWLOCK
                    currLock.ExitWriteLock();
            #else
                    Monitor.Exit(this._dataset);
            #endif
                }
            }
        }
Esempio n. 15
0
 /// <summary>
 /// Processes a command
 /// </summary>
 /// <param name="cmd">Command</param>
 public void ProcessCommand(SparqlUpdateCommand cmd)
 {
     _store.ExecuteUpdate(cmd);
 }
Esempio n. 16
0
 /// <summary>
 /// Creates a new Command Set containing the given Command
 /// </summary>
 /// <param name="command">Command</param>
 public SparqlUpdateCommandSet(SparqlUpdateCommand command)
 {
     this._commands.Add(command);
 }
Esempio n. 17
0
 /// <summary>
 /// Executes a single Update Command against the Triple Store
 /// </summary>
 /// <param name="update">SPARQL Update Command</param>
 public void ExecuteUpdate(SparqlUpdateCommand update)
 {
     SparqlUpdateEvaluationContext context = new SparqlUpdateEvaluationContext(new InMemoryDataset(this));
     update.Evaluate(context);
 }
Esempio n. 18
0
 /// <summary>
 /// Adds a new Command to the end of the sequence of Commands
 /// </summary>
 /// <param name="command">Command to add</param>
 internal void AddCommand(SparqlUpdateCommand command)
 {
     this._commands.Add(command);
 }
Esempio n. 19
0
 /// <summary>
 /// Gets the Permission action for the SPARQL Update Command
 /// </summary>
 /// <param name="cmd">Update Command</param>
 /// <returns></returns>
 private String GetPermissionAction(SparqlUpdateCommand cmd)
 {
     switch (cmd.CommandType)
     {
         case SparqlUpdateCommandType.InsertData:
             return "INSERT DATA";
         case SparqlUpdateCommandType.DeleteData:
             return "DELETE DATA";
         case SparqlUpdateCommandType.Insert:
             return "INSERT";
         case SparqlUpdateCommandType.Delete:
             return "DELETE";
         case SparqlUpdateCommandType.Modify:
             return "MODIFY";
         case SparqlUpdateCommandType.Load:
             return "LOAD";
         case SparqlUpdateCommandType.Clear:
             return "CLEAR";
         case SparqlUpdateCommandType.Create:
             return "CREATE";
         case SparqlUpdateCommandType.Drop:
             return "DROP";
         default:
             return String.Empty;
     }
 }
Esempio n. 20
0
 /// <summary>
 /// Processes a command
 /// </summary>
 /// <param name="cmd">Command</param>
 public void ProcessCommand(SparqlUpdateCommand cmd)
 {
     this._endpoint.Update(cmd.ToString());
 }