Esempio 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)))));
        }
Esempio 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));
        }
Esempio 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()));
        }
Esempio 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);
            }
        }
Esempio n. 5
0
        /// <inheritdoc/>
        public void Add(IDatasetChange datasetChange)
        {
            if (datasetChange.IsEmpty)
            {
                return;
            }

            if (datasetChange.Graph == null)
            {
                FreezeCurrentChanges();
                _frozenChanges.Add(datasetChange);
            }
            else
            {
                AppendAndMerge(datasetChange);
            }
        }
Esempio n. 6
0
 /// <inheritdoc />
 public override bool CanMergeWith(IDatasetChange other)
 {
     return((other is GraphUpdate || other is GraphReconstruct) && base.CanMergeWith(other));
 }
Esempio n. 7
0
 /// <summary>Merges this change the with another change.</summary>
 public abstract IDatasetChange MergeWith(IDatasetChange other);
Esempio 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);
 }
Esempio n. 9
0
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     throw new NotImplementedException();
 }
 private IEnumerable <SparqlUpdateCommand> CreateCommands(IDatasetChange change)
 {
     return(_sparqlCommandFactory.CreateCommands(change));
 }
Esempio n. 11
0
 /// <inheritdoc />
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     return(MergeWith((dynamic)other));
 }
Esempio n. 12
0
 /// <inheritdoc />
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     throw new InvalidOperationException("Cannot merge RemoveReferences with any other change");
 }
Esempio n. 13
0
 /// <inheritdoc />
 public override bool CanMergeWith(IDatasetChange other)
 {
     return(false);
 }
Esempio n. 14
0
 /// <inheritdoc />
 public override IDatasetChange MergeWith(IDatasetChange other)
 {
     throw new InvalidOperationException("Cannot merge EntityDelete with any other change");
 }