From d7881ff69cc6e479d82ac3be37921ed5729490ff Mon Sep 17 00:00:00 2001 From: Sirieam Marie Hunke <hunke@itc.rwth-aachen.de> Date: Fri, 20 Sep 2024 13:06:06 +0000 Subject: [PATCH] More cleaning --- src/GraphDeployer/Deployer.cs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/GraphDeployer/Deployer.cs b/src/GraphDeployer/Deployer.cs index df91678..4069238 100644 --- a/src/GraphDeployer/Deployer.cs +++ b/src/GraphDeployer/Deployer.cs @@ -68,7 +68,7 @@ public class Deployer // RDF URIs public static Uri CoscineEntitiesGraphDeployed { get; } = new("https://purl.org/coscine/entities/graph#deployed"); public static Uri CoscineTermsDeployedVersion { get; } = new("https://purl.org/coscine/terms/deployed#version"); - + public async Task<bool> RunAsync(GraphDeployerOptions opts) { // Check if the graph deployer is enabled @@ -154,18 +154,21 @@ public class Deployer var deployedGraph = deployedGraphsList.FirstOrDefault((g) => g.Uri == graphId); var hasChanged = deployedGraph is null || !deployedGraph.FileHashes.Contains(currentRun[graphId]) || opts.Redeploy; - if (hasChanged) + if (hasChanged) { _logger.LogDebug("The graph has changed."); - } else + } + else { _logger.LogDebug("The graph has not changed."); } - if(deployedGraph is null) + if (deployedGraph is null) { _logger.LogDebug("Deployed graph is null"); - } else { + } + else + { _logger.LogDebug("Deployed hash: {hash}", string.Join(',', deployedGraph.FileHashes)); } @@ -230,8 +233,8 @@ public class Deployer var resourceTypeStructuralGraphs = _resourceTypeStructuralData.ConvertToLinkedDataAsync(resourceTypeInformations); _logger.LogInformation("Storing the graphs..."); - await StoreGraphs(roleStructuralGraphs); - await StoreGraphs(resourceTypeStructuralGraphs); + await StoreSql2LinkedGraphs(roleStructuralGraphs); + await StoreSql2LinkedGraphs(resourceTypeStructuralGraphs); _logger.LogInformation("All structural graphs stored successfully.\n"); _logger.LogInformation("SQL to Linked Data migration completed successfully."); @@ -334,14 +337,14 @@ public class Deployer /// </summary> /// <param name="graphs">An asynchronous enumerable of RDF graphs (<see cref="IAsyncEnumerable{IGraph}"/>) to be stored.</param> /// <returns>A task representing the asynchronous operation of storing the graphs.</returns> - public async Task StoreGraphs(IAsyncEnumerable<IGraph> graphs) + public async Task StoreSql2LinkedGraphs(IAsyncEnumerable<IGraph> graphs) { var formatEnum = RdfFormat.TextTurtle; var format = "text/turtle"; await foreach (var graph in graphs) { - Console.WriteLine($" ({graph.BaseUri})"); + _logger.LogInformation($"Processing graph: {graph.BaseUri}"); try { @@ -368,15 +371,11 @@ public class Deployer ); } - Console.WriteLine($" - Graph {graph.BaseUri} added successfully"); - Console.WriteLine(); + _logger.LogInformation($"Graph {graph.BaseUri} added successfully."); } catch (Exception e) { - Console.Error.WriteLine($"Error on ({graph.BaseUri}):"); - Console.Error.WriteLine(e); - Console.Error.WriteLine(e.InnerException); - Console.Error.WriteLine(); + _logger.LogError(e, $"Error on processing graph: {graph.BaseUri}"); } } } -- GitLab