diff --git a/src/SQL2Linked/Implementations/ResourceStructuralData.cs b/src/SQL2Linked/Implementations/ResourceStructuralData.cs index 251d546a293a53102422f7c9bccd5fe3c5730881..cb4636a0b20a9e5ba15a0c8481b06847206c2e8d 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 b9d0aa6a150c349541fa09512110b842c5e6e833..ef892ef9c43815772ee8283dc56d9535a6bf50a0 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 6815744df2697ba9ff694ef242be8ee5600b6c34..ee37d5d5d89d06edc309534b5fc8ef99335c67a4 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)) + ) + ); + } + } }