Skip to main content
Sign in
Snippets Groups Projects
Commit 77f7ba3e authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix: Reinstate Catalog Relations

parent 11089c38
No related branches found
No related tags found
1 merge request!29Fix: Working new version
Pipeline #1220472 passed
......@@ -3,6 +3,7 @@ using Coscine.ApiClient.Core.Model;
using Newtonsoft.Json;
using SQL2Linked.Utils;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked.Implementations;
......@@ -120,7 +121,32 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.FoafHomepage} {resourceGraphName}'. ");
AssertToGraphLiteralNode(graph, resourceGraphName, RdfUris.CoscineTermsResourceDeleted, entry.Deleted.ToString().ToLower(), new Uri("http://www.w3.org/2001/XMLSchema#boolean"));
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.CoscineTermsResourceDeleted} {entry.Deleted}'. ");
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.CoscineTermsResourceDeleted} {entry.Deleted}'. ");
// Reinstate the catalog assignments
var oldResourceGraphResponse = await _adminApi.GetMetadataGraphAsync(
resourceGraphName.AbsoluteUri,
RdfFormat.TextTurtle
);
if (oldResourceGraphResponse is not null)
{
var oldResourceGraph = new Graph();
var ttlparser = new TurtleParser();
ttlparser.Load(oldResourceGraph, new StringReader(oldResourceGraphResponse.Data.Content));
foreach (var result in oldResourceGraph.GetTriplesWithPredicate(RdfUris.DcatCatalog))
{
if (result.Object.NodeType == NodeType.Uri)
{
var catalogedUri = result.Object as IUriNode;
if (catalogedUri is not null)
{
AssertToGraphUriNode(graph, resourceGraphName, RdfUris.DcatCatalog, catalogedUri.Uri);
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcatCatalog} {catalogedUri.Uri}'. ");
}
}
}
}
foreach (var projectResource in entry.ProjectResources)
{
......@@ -151,7 +177,7 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
if (entry.DateCreated is not null && entry.DateCreated.HasValue)
{
AssertToGraphLiteralNode(graph, resourceGraphName, RdfUris.DcTermsCreated, entry.DateCreated.Value.ToString(), new Uri("http://www.w3.org/2001/XMLSchema#dateTime"));
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcTermsCreated} {entry.DateCreated}'. ");
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcTermsCreated} {entry.DateCreated}'. ");
}
graphs.Add(graph);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment