Skip to content
Snippets Groups Projects
Commit 0ab09f62 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix: Use PURLs

parent 7eb6f2fa
Branches
Tags
1 merge request!17Fix: Use PURLs
......@@ -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}'. ");
}
}
......
......@@ -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'. ");
}
}
......
......@@ -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/");
......
......@@ -62,7 +62,9 @@ namespace SQL2Linked
}
}
public void AssertToGraphUriNode(IGraph graph, string graphSubject, string graphPredicate, string graphObject)
public void AssertToGraphUriNode(IGraph graph, string graphSubject, string graphPredicate, string? graphObject)
{
if (graphObject != null)
{
graph.Assert(
new Triple(
......@@ -72,8 +74,11 @@ namespace SQL2Linked
)
);
}
}
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)
{
if (graphObject != null)
{
graph.Assert(
new Triple(
......@@ -83,8 +88,11 @@ namespace SQL2Linked
)
);
}
}
public void AssertToGraphBlankAndUriNode(IGraph graph, IBlankNode graphSubject, string graphPredicate, string graphObject)
public void AssertToGraphBlankAndUriNode(IGraph graph, IBlankNode graphSubject, string graphPredicate, string? graphObject)
{
if (graphObject != null)
{
graph.Assert(
new Triple(
......@@ -96,3 +104,4 @@ namespace SQL2Linked
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment