new public void ProcessCopyCommand(CopyCommand cmd)
 {
     try
     {
         //If Source and Destination are equal this is a no-op
         if (EqualityHelper.AreUrisEqual(cmd.SourceUri, cmd.DestinationUri)) return;
         if (cmd.SourceUri != null && !_manager.ListGraphs().Any(g=>EqualityHelper.AreUrisEqual(cmd.SourceUri, g)))
         {
             throw new SparqlUpdateException(string.Format("Could not find source graph <{0}>", cmd.SourceUri));
         }
         _manager.CopyGraph(cmd.SourceUri, cmd.DestinationUri);
     }
     catch
     {
         if (!cmd.Silent) throw;
     }
 }
 /// <summary>
 /// Processes a COPY command
 /// </summary>
 /// <param name="cmd">Copy Command</param>
 public void ProcessCopyCommand(CopyCommand cmd)
 {
     this.ProcessCommand(cmd);
 }
Example #3
0
        /// <summary>
        /// Processes a COPY command
        /// </summary>
        /// <param name="cmd">Copy Command</param>
        public void ProcessCopyCommand(CopyCommand cmd)
        {
            if (this._manager is IUpdateableGenericIOManager)
            {
                ((IUpdateableGenericIOManager)this._manager).Update(cmd.ToString());
            }
            else
            {
                try
                {
                    //If Source and Destination are equal this is a no-op
                    if (EqualityHelper.AreUrisEqual(cmd.SourceUri, cmd.DestinationUri)) return;

                    //Firstly check that appropriate IO Behaviour is provided
                    if (cmd.SourceUri == null || cmd.DestinationUri == null)
                    {
                        if ((this._manager.IOBehaviour & IOBehaviour.HasDefaultGraph) == 0) throw new SparqlUpdateException("The underlying store does not provide support for an explicit unnamed Default Graph required to process this command");
                    }
                    IOBehaviour desired = cmd.DestinationUri == null ? IOBehaviour.OverwriteDefault : IOBehaviour.OverwriteNamed;
                    if ((this._manager.IOBehaviour & desired) == 0) throw new SparqlUpdateException("The underlying store does not provide the required IO Behaviour to implement this command");

                    Graph source = new Graph();
                    this._manager.LoadGraph(source, cmd.SourceUri);
                    source.BaseUri = cmd.SourceUri;

                    //If the Manager supports delete ensure the Destination Graph is deleted
                    if (this._manager.DeleteSupported)
                    {
                        try
                        {
                            this._manager.DeleteGraph(cmd.DestinationUri);
                        }
                        catch (Exception ex)
                        {
                            throw new SparqlUpdateException("Unable to process a COPY command as unable to ensure that the Destination Graph was deleted prior to moving the data from the Source Graph", ex);
                        }
                    }

                    //Load Destination Graph and ensure it is empty
                    Graph dest = new Graph();
                    this._manager.LoadGraph(dest, cmd.DestinationUri);
                    dest.BaseUri = cmd.DestinationUri;
                    dest.Clear();

                    //Transfer the data and update both the Graphs
                    dest.Merge(source);
                    this._manager.SaveGraph(dest);
                }
                catch
                {
                    if (!cmd.Silent) throw;
                }
            }
        }
        /// <summary>
        /// Processes a COPY command
        /// </summary>
        /// <param name="cmd">Copy Command</param>
        public void ProcessCopyCommand(CopyCommand cmd)
        {
            if (this._manager is IUpdateableGenericIOManager)
            {
                ((IUpdateableGenericIOManager)this._manager).Update(cmd.ToString());
            }
            else
            {
                try
                {
                    Graph source = new Graph();
                    this._manager.LoadGraph(source, cmd.SourceUri);
                    source.BaseUri = cmd.SourceUri;

                    //If the Manager supports delete ensure the Destination Graph is deleted
                    if (this._manager.DeleteSupported)
                    {
                        try
                        {
                            this._manager.DeleteGraph(cmd.DestinationUri);
                        }
                        catch (Exception ex)
                        {
                            throw new SparqlUpdateException("Unable to process a MOVE command as unable to ensure that the Destination Graph was deleted prior to moving the data from the Source Graph", ex);
                        }
                    }

                    //Load Destination Graph and ensure it is empty
                    Graph dest = new Graph();
                    this._manager.LoadGraph(dest, cmd.DestinationUri);
                    dest.BaseUri = cmd.DestinationUri;
                    dest.Clear();

                    //Transfer the data and update both the Graphs
                    dest.Merge(source);
                    this._manager.SaveGraph(dest);
                }
                catch
                {
                    if (!cmd.Silent) throw;
                }
            }
        }
 /// <summary>
 /// Processes a COPY command
 /// </summary>
 /// <param name="cmd">Copy Command</param>
 /// <param name="context">SPARQL Update Evaluation Context</param>
 protected virtual void ProcessCopyCommandInternal(CopyCommand cmd, SparqlUpdateEvaluationContext context)
 {
     cmd.Evaluate(context);
 }
 /// <summary>
 /// Processes a COPY command
 /// </summary>
 /// <param name="cmd">Copy Command</param>
 public void ProcessCopyCommand(CopyCommand cmd)
 {
     this.ProcessCopyCommandInternal(cmd, this.GetContext());
 }