diff --git a/src/GraphDeployer/GraphDeployer.csproj b/src/GraphDeployer/GraphDeployer.csproj index 984abe4b609cb32bbcd240d51930b21c4a4b0f01..8b8d84622b644cbccf87113da6f964d3e195d050 100644 --- a/src/GraphDeployer/GraphDeployer.csproj +++ b/src/GraphDeployer/GraphDeployer.csproj @@ -7,7 +7,7 @@ <AssemblyName>Coscine.GraphDeployer</AssemblyName> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> - <Version>1.2.7</Version> + <Version>1.2.8</Version> </PropertyGroup> <PropertyGroup> diff --git a/src/GraphDeployer/Program.cs b/src/GraphDeployer/Program.cs index 3ff8947d6e5432f66fdc73f72d6da99dbfc32a91..7190b847586fb0e15c3c872bbceda32175a2d985 100644 --- a/src/GraphDeployer/Program.cs +++ b/src/GraphDeployer/Program.cs @@ -114,11 +114,12 @@ public class Program var currentGraph = Helpers.WrapRequest(() => _rdfStoreConnector.GetGraph(graphName)); + // Project the triples for easier comparison + var projectedGraph = graph.Triples.Select(ProjectTriple).ToList(); + var projectedCurrentGraph = currentGraph.Triples.Select(ProjectTriple).ToList(); + var graphWasChanged = graph.Triples.Count != currentGraph.Triples.Count - || graph.Triples.Any((triple) => !currentGraph.Triples.Any((currentTriple) => - (triple.Subject.Equals(currentTriple.Subject) || (triple.Subject.NodeType == NodeType.Blank && currentTriple.Subject.NodeType == NodeType.Blank) - && triple.Predicate.Equals(currentTriple.Predicate) - && triple.Object.Equals(currentTriple.Object) || (triple.Object.NodeType == NodeType.Blank && currentTriple.Object.NodeType == NodeType.Blank)))); + || projectedGraph.Except(projectedCurrentGraph).Any(); if (graphWasChanged) { @@ -141,9 +142,9 @@ public class Program else { _logger.LogInformation("Skipping {graphName}", graphName); - } } + queries.Add($"rdf_loader_run ();"); queries.Add($"DELETE from DB.DBA.load_list where 1=1;"); @@ -233,4 +234,11 @@ public class Program LogInnerException(ex.InnerException); } } + + private static string ProjectTriple(Triple triple) + { + return $"{(triple.Subject.NodeType == NodeType.Blank ? "BLANK" : triple.Subject.ToString())}," + + $"{triple.Predicate.ToString()}," + + $"{(triple.Object.NodeType == NodeType.Blank ? "BLANK" : triple.Object.ToString())}"; + } } \ No newline at end of file