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