diff --git a/src/SQL2Linked/Implementations/ProjectStructuralData.cs b/src/SQL2Linked/Implementations/ProjectStructuralData.cs index 5106892511407d609bbf23e32c8fe7af3174d4f1..0e0fb883afbcb589b7c204a9a188de1901189468 100644 --- a/src/SQL2Linked/Implementations/ProjectStructuralData.cs +++ b/src/SQL2Linked/Implementations/ProjectStructuralData.cs @@ -36,11 +36,14 @@ namespace SQL2Linked.Implementations IEnumerable<ProjectResource> projectResources = ProjectResourceModel.GetAll(); var graphs = new List<IGraph>(); - string projectUrlPrefix = "https://hdl.handle.net/" + Prefix; + var projectUrlHandlePrefix = "https://hdl.handle.net/" + Prefix; + var projectUrlPrefix = "https://purl.org/coscine/projects"; + var resourceUrlPrefix = "https://purl.org/coscine/resources"; foreach (var entry in entries) { var projectGraphName = $"{projectUrlPrefix}/{entry.Id}"; + var projectHandleName = $"{projectUrlHandlePrefix}/{entry.Id}"; var graph = new Graph(); graph.BaseUri = new Uri(projectGraphName); @@ -107,8 +110,8 @@ namespace SQL2Linked.Implementations AssertToGraphLiteralNode(graph, projectGraphName, cosc + "terms/project#slug", entry.Slug); Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {cosc}terms/project#slug {entry.Slug}'. "); - AssertToGraphUriNode(graph, projectGraphName, foaf + "homepage", projectGraphName); - Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {foaf}homepage {projectGraphName}'. "); + AssertToGraphUriNode(graph, projectGraphName, foaf + "homepage", projectHandleName); + Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {foaf}homepage {projectHandleName}'. "); foreach (var projectRole in projectRoles) { @@ -137,8 +140,8 @@ namespace SQL2Linked.Implementations { if (entry.Id == projectResource.ProjectId) { - AssertToGraphUriNode(graph, projectGraphName, dcat + "catalog", $"{projectUrlPrefix}/{projectResource.ResourceId}"); - Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}catalog {projectUrlPrefix}/{projectResource.ResourceId}'. "); + AssertToGraphUriNode(graph, projectGraphName, dcat + "catalog", $"{resourceUrlPrefix}/{projectResource.ResourceId}"); + Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {dcat}catalog {resourceUrlPrefix}/{projectResource.ResourceId}'. "); } } diff --git a/src/SQL2Linked/Implementations/ResourceStructuralData.cs b/src/SQL2Linked/Implementations/ResourceStructuralData.cs index c603d164133929ffc3925ccc0b0f5ce5795ab983..376f6ba88fb4c9e4b3aef97f4688f3f2414f4638 100644 --- a/src/SQL2Linked/Implementations/ResourceStructuralData.cs +++ b/src/SQL2Linked/Implementations/ResourceStructuralData.cs @@ -38,11 +38,14 @@ namespace SQL2Linked.Implementations IEnumerable<License> licenses = LicenseModel.GetAll(); var graphs = new List<IGraph>(); - string resourceUrlPrefix = "https://hdl.handle.net/" + Prefix; + var resourceUrlHandlePrefix = "https://hdl.handle.net/" + Prefix; + var projectUrlPrefix = "https://purl.org/coscine/projects"; + var resourceUrlPrefix = "https://purl.org/coscine/resources"; foreach (var entry in entries) { var resourceGraphName = $"{resourceUrlPrefix}/{entry.Id}"; + var resourceHandleName = $"{resourceUrlHandlePrefix}/{entry.Id}"; var graph = new Graph(); graph.BaseUri = new Uri(resourceGraphName); @@ -53,8 +56,8 @@ namespace SQL2Linked.Implementations AssertToGraphUriNode(graph, resourceGraphName, rdf + "type", pim + "Storage"); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {rdf}type {pim}Storage'. "); - AssertToGraphUriNode(graph, resourceGraphName, dcat + "service", cosc + $"resourcetype/{entry.TypeId}"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcat}service {cosc}resourcetype/{entry.TypeId}'. "); + AssertToGraphUriNode(graph, resourceGraphName, dcat + "service", cosc + $"resourcetypes/{entry.TypeId}"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcat}service {cosc}resourcetypes/{entry.TypeId}'. "); AssertToGraphLiteralNode(graph, resourceGraphName, dcterms + "title", entry.ResourceName); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {dcterms}title {entry.ResourceName}'. "); @@ -122,7 +125,7 @@ namespace SQL2Linked.Implementations AssertToGraphLiteralNode(graph, resourceGraphName, cosc + "terms/resource#archived", entry.Archived.ToString().ToLower(), 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}'. "); - AssertToGraphUriNode(graph, resourceGraphName, foaf + "homepage", resourceGraphName); + AssertToGraphUriNode(graph, resourceGraphName, foaf + "homepage", resourceHandleName); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {foaf}homepage {resourceGraphName}'. "); AssertToGraphLiteralNode(graph, resourceGraphName, cosc + "terms/resource#deleted", entry.Deleted.ToString().ToLower(), new Uri("http://www.w3.org/2001/XMLSchema#boolean")); @@ -154,8 +157,8 @@ namespace SQL2Linked.Implementations AssertToGraphBlankAndUriNode(graph, blankNode, rdf + "type", acl + "Authorization"); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {rdf}type {acl}Authorization'. "); - AssertToGraphBlankAndUriNode(graph, blankNode, acl + "agentGroup", $"{resourceUrlPrefix}/{projectResource.ProjectId}"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}agentGroup {resourceUrlPrefix}/{projectResource.ProjectId}'. "); + AssertToGraphBlankAndUriNode(graph, blankNode, acl + "agentGroup", $"{projectUrlPrefix}/{projectResource.ProjectId}"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}agentGroup {projectUrlPrefix}/{projectResource.ProjectId}'. "); AssertToGraphBlankAndUriNode(graph, blankNode, acl + "accessTo", resourceGraphName); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {resourceGraphName}'. "); @@ -163,8 +166,11 @@ namespace SQL2Linked.Implementations AssertToGraphBlankAndUriNode(graph, blankNode, acl + "default", resourceGraphName); Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}default {resourceGraphName}'. "); - AssertToGraphBlankAndUriNode(graph, blankNode, acl + "mode", acl + "Control"); - Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {acl}Control'. "); + AssertToGraphBlankAndUriNode(graph, blankNode, acl + "mode", acl + "Read"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {acl}Read'. "); + + AssertToGraphBlankAndUriNode(graph, blankNode, acl + "mode", acl + "Write"); + Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{blankNode} {acl}accessTo {acl}Write'. "); } } diff --git a/src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs b/src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs index d5fc3b2497a9f7a3ddc1c0e23f30faecc275cb27..06040e19323407d51ca45acd4232cd61f391c438 100644 --- a/src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs +++ b/src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs @@ -6,7 +6,7 @@ namespace SQL2Linked.Implementations { public class ResourceTypeStructuralData : StructuralData<ResourceType, ResourceTypeModel> { - public readonly string ResourceTypeUrlPrefix = "https://purl.org/coscine/resourcetype"; + public readonly string ResourceTypeUrlPrefix = "https://purl.org/coscine/resourcetypes"; public readonly Uri rdf = new("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); public readonly Uri dcat = new("http://www.w3.org/ns/dcat#"); public readonly Uri dcterms = new("http://purl.org/dc/terms/"); diff --git a/src/SQL2Linked/SQL2Linked.csproj b/src/SQL2Linked/SQL2Linked.csproj index 6bd0d57e29934dd4758969b8bfcf362ac893b506..533909de7cbb76622150bcc7f5bdd43f53d8ef90 100644 --- a/src/SQL2Linked/SQL2Linked.csproj +++ b/src/SQL2Linked/SQL2Linked.csproj @@ -5,7 +5,7 @@ <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> - <Version>0.1.5</Version></PropertyGroup> + <Version>0.1.6</Version></PropertyGroup> <ItemGroup> <PackageReference Include="Coscine.Database" Version="2.*-*" /> diff --git a/src/SQL2Linked/StructuralData.cs b/src/SQL2Linked/StructuralData.cs index 9f9f113569964718b67b037da6c7cc0a856c485c..0b86a3aa6bf1e17e5c4003c939c186e9cf384c2a 100644 --- a/src/SQL2Linked/StructuralData.cs +++ b/src/SQL2Linked/StructuralData.cs @@ -62,37 +62,46 @@ namespace SQL2Linked } } - public void AssertToGraphUriNode(IGraph graph, string graphSubject, string graphPredicate, string graphObject) + public void AssertToGraphUriNode(IGraph graph, string graphSubject, string graphPredicate, string? graphObject) { - graph.Assert( - new Triple( - graph.CreateUriNode(new Uri(graphSubject)), - graph.CreateUriNode(new Uri(graphPredicate)), - graph.CreateUriNode(new Uri(graphObject)) - ) - ); + if (graphObject != null) + { + graph.Assert( + new Triple( + graph.CreateUriNode(new Uri(graphSubject)), + graph.CreateUriNode(new Uri(graphPredicate)), + graph.CreateUriNode(new Uri(graphObject)) + ) + ); + } } - public void AssertToGraphLiteralNode(IGraph graph, string graphSubject, string graphPredicate, string graphObject, Uri? objectType = null) + public void AssertToGraphLiteralNode(IGraph graph, string graphSubject, string graphPredicate, string? graphObject, Uri? objectType = null) { - graph.Assert( - new Triple( - graph.CreateUriNode(new Uri(graphSubject)), - graph.CreateUriNode(new Uri(graphPredicate)), - graph.CreateLiteralNode(graphObject, objectType) - ) - ); + if (graphObject != null) + { + graph.Assert( + new Triple( + graph.CreateUriNode(new Uri(graphSubject)), + graph.CreateUriNode(new Uri(graphPredicate)), + graph.CreateLiteralNode(graphObject, objectType) + ) + ); + } } - public void AssertToGraphBlankAndUriNode(IGraph graph, IBlankNode graphSubject, string graphPredicate, string 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)) - ) - ); + if (graphObject != null) + { + graph.Assert( + new Triple( + graphSubject, + graph.CreateUriNode(new Uri(graphPredicate)), + graph.CreateUriNode(new Uri(graphObject)) + ) + ); + } } } }