Exemplo n.º 1
0
        private static bool GraphUpdateSettingRdfTypes(IDatasetChange change)
        {
            var update = change as GraphUpdate;

            return(update != null &&
                   update.AddedQuads.All(q => q.Predicate.Equals(Node.ForUri(Rdf.type))) &&
                   (update.AddedQuads.Any(q => q.Object.Equals(Node.ForUri(Foaf.Person))) ||
                    update.AddedQuads.Any(q => q.Object.Equals(Node.ForUri(Foaf.Agent)))));
        }
Exemplo n.º 2
0
        public IEnumerable <SparqlUpdateCommand> CreateCommands(IDatasetChange change)
        {
            var changeType = change.GetType();

            if (_commandFactories.ContainsKey(changeType))
            {
                return(_commandFactories[changeType](change));
            }

            throw new ArgumentOutOfRangeException("change", string.Format("Unsupported dataset change type {0}", changeType.Name));
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public override IDatasetChange MergeWith(IDatasetChange other)
        {
            if (other is GraphReconstruct)
            {
                return(other);
            }

            var otherUpdate       = (GraphUpdate)other;
            var removalsCombined  = RemovedQuads.Union(otherUpdate.RemovedQuads);
            var additionsCombined = AddedQuads.Union(otherUpdate.AddedQuads);

            return(new GraphUpdate(Entity, Graph, removalsCombined.ToArray(), additionsCombined.ToArray()));
        }
Exemplo n.º 4
0
        private void AppendAndMerge(IDatasetChange datasetChange)
        {
            var nextChange = datasetChange;

            lock (_syncLock)
            {
                var current = ChangesFor(datasetChange.Graph);

                if (current.Count > 0 && current.Peek().CanMergeWith(nextChange))
                {
                    var previousChange = current.Pop();
                    nextChange = previousChange.MergeWith(nextChange);
                }

                current.Push(nextChange);
            }
        }
Exemplo n.º 5
0
        /// <inheritdoc/>
        public void Add(IDatasetChange datasetChange)
        {
            if (datasetChange.IsEmpty)
            {
                return;
            }

            if (datasetChange.Graph == null)
            {
                FreezeCurrentChanges();
                _frozenChanges.Add(datasetChange);
            }
            else
            {
                AppendAndMerge(datasetChange);
            }
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 public override bool CanMergeWith(IDatasetChange other)
 {
     return((other is GraphUpdate || other is GraphReconstruct) && base.CanMergeWith(other));
 }
Exemplo n.º 7
0
 /// <summary>Merges this change the with another change.</summary>
 public abstract IDatasetChange MergeWith(IDatasetChange other);
Exemplo n.º 8
0
 /// <summary>Determines whether this instance can be merged with another.</summary>
 /// <param name="other">The other change.</param>
 public virtual bool CanMergeWith(IDatasetChange other)
 {
     return(Graph == other.Graph);
 }
Exemplo n.º 9
0
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 private IEnumerable <SparqlUpdateCommand> CreateCommands(IDatasetChange change)
 {
     return(_sparqlCommandFactory.CreateCommands(change));
 }
Exemplo n.º 11
0
 /// <inheritdoc />
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     return(MergeWith((dynamic)other));
 }
Exemplo n.º 12
0
 /// <inheritdoc />
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     throw new InvalidOperationException("Cannot merge RemoveReferences with any other change");
 }
Exemplo n.º 13
0
 /// <inheritdoc />
 public override bool CanMergeWith(IDatasetChange other)
 {
     return(false);
 }
Exemplo n.º 14
0
 /// <inheritdoc />
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     throw new InvalidOperationException("Cannot merge EntityDelete with any other change");
 }