From 56e6202713b57bccc689a4e147c0e440d385bd05 Mon Sep 17 00:00:00 2001 From: Hanna Fuehr <fuehr@itc.rwth-aachen.de> Date: Mon, 8 Aug 2022 09:31:53 +0200 Subject: [PATCH] Update: Considering remarks (coscine/issues#2084) --- .../Implementations/ResourceStructuralData.cs | 29 ++++++++++--------- src/SQL2Linked/Program.cs | 16 +++++----- src/SQL2Linked/StructuralData.cs | 23 +++++++++++++++ 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/SQL2Linked/Implementations/ResourceStructuralData.cs b/src/SQL2Linked/Implementations/ResourceStructuralData.cs index 251d546..cb4636a 100644 --- a/src/SQL2Linked/Implementations/ResourceStructuralData.cs +++ b/src/SQL2Linked/Implementations/ResourceStructuralData.cs @@ -53,14 +53,14 @@ namespace SQL2Linked.Implementations { if (entry.VisibilityId == visibility.Id && visibility.DisplayName.Contains("Public")) { - AssertToGraphUriNode(graph, resourceGraphName, cosc + "terms/resource#visibility", cosc + $"terms/vivibility#public"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#visibility {cosc}terms/vivibility#public'. "); + AssertToGraphUriNode(graph, resourceGraphName, cosc + "terms/resource#visibility", cosc + $"terms/visibility#public"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#visibility {cosc}terms/visibility#public'. "); break; } else if (entry.VisibilityId == visibility.Id && visibility.DisplayName.Contains("Project Members")) { - AssertToGraphUriNode(graph, resourceGraphName, cosc + "terms/resource#visibility", cosc + $"terms/vivibility#projectMember"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#visibility {cosc}terms/vivibility#projectMember'. "); + AssertToGraphUriNode(graph, resourceGraphName, cosc + "terms/resource#visibility", cosc + $"terms/visibility#projectMember"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#visibility {cosc}terms/visibility#projectMember'. "); break; } } @@ -88,7 +88,7 @@ namespace SQL2Linked.Implementations Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcterms}creator {cosc}users/{entry.Creator}'. "); AssertToGraphLiteralNode(graph, resourceGraphName, cosc + "terms/resource#archived", entry.Archived.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#boolean")); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#archived {entry.Archived.ToString()}'. "); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#archived {entry.Archived}'. "); AssertToGraphUriNode(graph, resourceGraphName, foaf + "homepage", resourceGraphName); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {foaf}homepage {resourceGraphName}'. "); @@ -110,27 +110,28 @@ namespace SQL2Linked.Implementations Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcat}catalog {result[0].ToString()}'. "); } - AssertToGraphUriNode(graph, resourceGraphName, rdf + "type", acl + "Authorization"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {rdf}type {acl}Authorization'. "); + var blankNode= graph.CreateBlankNode(entry.Id.ToString()); + + AssertToGraphBlankAndUriNode(graph, blankNode, rdf + "type", acl + "Authorization"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {rdf}type {acl}Authorization'. "); foreach (var projectResource in projectResources) { if (entry.Id == projectResource.ResourceId) { - AssertToGraphUriNode(graph, resourceGraphName, acl + "agentGroup", $"{resourceUrlPrefix}/{projectResource.ProjectId}"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {acl}agentGroup {resourceUrlPrefix}/{projectResource.ProjectId}'. "); + AssertToGraphBlankAndUriNode(graph, blankNode, acl + "agentGroup", $"{resourceUrlPrefix}/{projectResource.ProjectId}"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}agentGroup {resourceUrlPrefix}/{projectResource.ProjectId}'. "); break; } } - AssertToGraphUriNode(graph, resourceGraphName, acl + "accessTo", resourceGraphName); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {acl}accessTo {resourceGraphName}'. "); + AssertToGraphBlankAndUriNode(graph, blankNode, acl + "accessTo", resourceGraphName); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {resourceGraphName}'. "); - AssertToGraphUriNode(graph, resourceGraphName, acl + "mode", acl + "Control"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {acl}accessTo {acl}Control'. "); + AssertToGraphBlankAndUriNode(graph, blankNode, acl + "mode", acl + "Control"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {acl}Control'. "); graphs.Add(graph); - } return graphs; } diff --git a/src/SQL2Linked/Program.cs b/src/SQL2Linked/Program.cs index b9d0aa6..ef892ef 100644 --- a/src/SQL2Linked/Program.cs +++ b/src/SQL2Linked/Program.cs @@ -9,17 +9,17 @@ if (dummyMode) Console.WriteLine("\nBegin SQL 2 Linked Data migration"); -var roleStructuralData = new RoleStructuralData(); -roleStructuralData.Migrate(dummyMode); +//var roleStructuralData = new RoleStructuralData(); +//roleStructuralData.Migrate(dummyMode); -var userStructuralData = new UserStructuralData(); -userStructuralData.Migrate(dummyMode); +//var userStructuralData = new UserStructuralData(); +//userStructuralData.Migrate(dummyMode); -var resourceTypeStructuralData = new ResourceTypeStructuralData(); -resourceTypeStructuralData.Migrate(dummyMode); +//var resourceTypeStructuralData = new ResourceTypeStructuralData(); +//resourceTypeStructuralData.Migrate(dummyMode); -var projectStructuralData = new ProjectStructuralData(); -projectStructuralData.Migrate(dummyMode); +//var projectStructuralData = new ProjectStructuralData(); +//projectStructuralData.Migrate(dummyMode); var resourceStructuralData = new ResourceStructuralData(); resourceStructuralData.Migrate(dummyMode); diff --git a/src/SQL2Linked/StructuralData.cs b/src/SQL2Linked/StructuralData.cs index 6815744..ee37d5d 100644 --- a/src/SQL2Linked/StructuralData.cs +++ b/src/SQL2Linked/StructuralData.cs @@ -77,5 +77,28 @@ namespace SQL2Linked ) ); } + + public void AssertToGraphBlankAndUriNode(IGraph graph, string graphSubject, string graphPredicate, string graphObject) + { + graph.Assert( + new Triple( + graph.CreateBlankNode(graphSubject), + graph.CreateUriNode(new Uri(graphPredicate)), + graph.CreateUriNode(new Uri(graphObject)) + ) + ); + } + + public void AssertToGraphBlankAndUriNode(IGraph graph, IBlankNode graphSubject, string graphPredicate, string graphObject) + { + graph.Assert( + new Triple( + graphSubject, + graph.CreateUriNode(new Uri(graphPredicate)), + graph.CreateUriNode(new Uri(graphObject)) + ) + ); + } + } } -- GitLab